A market making bot for Polymarket prediction markets. This bot automates the process of providing liquidity to markets on Polymarket by maintaining orders on both sides of the book with configurable parameters. A summary of my experience running this bot is available here
Poly-Maker is a comprehensive solution for automated market making on Polymarket. It includes:
- Real-time order book monitoring via WebSockets
- Position management with risk controls
- Customizable trade parameters fetched from Google Sheets
- Automated position merging functionality
- Sophisticated spread and price management
The repository consists of several interconnected modules:
poly_data: Core data management and market making logicpoly_merger: Utility for merging positions (based on open-source Polymarket code)poly_stats: Account statistics trackingpoly_utils: Shared utility functionsdata_updater: Separate module for collecting market information
- Python 3.9+
- uv - Fast Python package installer and resolver
- Node.js (for poly_merger)
- Google Sheets API credentials
- Polymarket account and API credentials
- Clone the repository:
git clone https://github.com/yourusername/poly-maker.git
cd poly-maker
- Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh- Install Python dependencies:
# Install all dependencies (creates .venv automatically)
uv sync
# Or with dev dependencies (pytest, ruff, black, ty)
uv sync --all-extras- Install Node.js dependencies for the merger:
cd poly_merger
npm install
cd ..
- Set up environment variables:
cp .env.example .env
- Configure your credentials in
.env:
PK: Your private key for PolymarketBROWSER_ADDRESS: Your wallet address
Make sure your wallet has done at least one trade thru the UI so that the permissions are proper.
-
Set up Google Sheets integration:
- Create a Google Service Account and download credentials to the main directory
- Copy the sample Google Sheet
- Add your Google service account to the sheet with edit permissions
- Update
SPREADSHEET_URLin your.envfile
-
Update market data:
- Run
uv run python update_markets.pyto fetch all available markets - This should run continuously in the background (preferably on a different IP than your trading bot)
- Add markets you want to trade to the "Selected Markets" sheet. You'd wanna select markets from the "Volatility Markets" sheet.
- Configure corresponding parameters in the "Hyperparameters" sheet. Default parameters that worked well in November are there.
- Run
-
Start the market making bot:
uv run python main.pyThe bot is configured via a Google Spreadsheet with several worksheets:
- Selected Markets: Markets you want to trade
- All Markets: Database of all markets on Polymarket
- Hyperparameters: Configuration parameters for the trading logic
The poly_merger module is a particularly powerful utility that handles position merging on Polymarket. It's built on open-source Polymarket code and provides a smooth way to consolidate positions, reducing gas fees and improving capital efficiency.
The bot includes telemetry infrastructure for monitoring performance and operations:
Access the Grafana dashboard at http://localhost:3000 (default credentials: admin/admin)
run the docker container for the dashboard if its not already running:
docker run -d \
-p 3000:3000 \
-v grafana_data:/var/lib/grafana \
--name grafana \
grafana/grafana
The dashboard provides real-time visibility into:
- Trading performance metrics
- Order execution tracking
- System health and operations
- Configure ClickHouse credentials in your
.envfile:
CLICKHOUSE_HOST=your-clickhouse-host
CLICKHOUSE_PORT=9440
CLICKHOUSE_USER=your-username
CLICKHOUSE_PASSWORD=your-password
- Start the OpenTelemetry Collector (collects metrics, logs, and traces):
cd telemetry
./run_collector.shThis runs a Docker container that receives telemetry data and exports it to ClickHouse.
- Import the dashboard into Grafana:
- Navigate to Dashboards → Import
- Upload
telemetry/grafana_operational_dash.json - Configure the ClickHouse datasource connection
- This code interacts with real markets and can potentially lose real money
- Test thoroughly with small amounts before deploying with significant capital
- The
data_updateris technically a separate repository but is included here for convenience
MIT