Polymarket Bot is an open-source, production-ready automated trading bot for Polymarket β the world's largest prediction market. Built in Python on top of the official
py-clob-client, it scans markets, evaluates configurable strategies, and places orders on the Polymarket CLOB API automatically, 24/7.
If you searched for "polymarket bot", "polymarket trading bot", "polymarket python bot", "polymarket api bot", or "prediction market bot" β you're in the right place.
- What is Polymarket Bot?
- Features
- How It Works
- Quick Start
- Installation
- Configuration
- Trading Strategies
- Usage Examples
- Architecture
- Risk Management
- Deployment (VPS / Docker)
- FAQ
- Disclaimer
- Contributing
- License
Polymarket is a decentralized prediction market built on Polygon where users trade YES/NO shares on real-world events β elections, crypto prices, sports, geopolitics. Each share resolves to either $1.00 (correct) or $0.00 (wrong), so the live price effectively reflects the market-implied probability.
Polymarket Bot is a Python toolkit that automates trading on Polymarket. Instead of manually clicking through markets, the bot:
- Connects to the Polymarket CLOB API and Gamma API
- Discovers active markets matching your filters (volume, category, spread)
- Evaluates each market against pluggable strategies (mean-reversion, market-making, arbitrage, ML signals)
- Places, monitors, and cancels orders programmatically with full position and risk management
- Logs every action and exposes Prometheus-style metrics
This is not a simulator and not a backtesting-only tool β it places real orders on the production Polymarket CLOB. Polymarket has no testnet, so always start with small position sizes.
- π Official SDK integration β uses
py-clob-clientv2 with EIP-712 signing - π Multi-strategy engine β mean-reversion, market-making, arbitrage, custom user strategies
- π Three Polymarket APIs covered β CLOB (trading), Gamma (markets), Data (positions)
- π WebSocket streaming β real-time order book updates instead of polling
- π‘οΈ Risk management β position limits, max drawdown, kill-switch, daily loss caps
- π Backtester β replay historical orderbook data before going live
- π§ͺ Dry-run mode β simulate trades without placing real orders
- π³ Docker-ready β one-command deployment to any VPS
- π Structured logging β JSON logs, Prometheus metrics, Grafana dashboard included
- βοΈ Fully configurable β YAML config, no code changes needed for new strategies
- π Secure secrets β
.envbased, supports HashiCorp Vault and AWS Secrets Manager - π§© Pluggable β write a 30-line strategy class and the bot picks it up
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Polymarket Bot Engine β
β β
β ββββββββββββββ ββββββββββββββ β
β β Gamma API ββββββΆβ Market β β
β β (discover)β β Filter β β
β ββββββββββββββ βββββββ¬βββββββ β
β β β
β ββββββββββββββ βββββββΌβββββββ β
β β CLOB WS ββββββΆβ Strategy β β
β β (prices) β β Evaluator β β
β ββββββββββββββ βββββββ¬βββββββ β
β β β
β ββββββββββββββ βββββββΌβββββββ β
β β Risk βββββββ Order β β
β β Manager β β Builder β β
β βββββββ¬βββββββ βββββββ¬βββββββ β
β β β β
β ββββββββββββ¬ββββββββ β
β βΌ β
β βββββββββββββββββ β
β β CLOB POST ββββΆ Polymarket β
β β /order β β
β βββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
The bot's main loop runs every scan_interval seconds:
- Fetch active markets from the Gamma API
- Filter by volume, spread, and category
- Subscribe to live orderbook updates via WebSocket
- Evaluate each strategy against the live state
- Validate the trade with the Risk Manager (caps, drawdown, allowance)
- Sign the order with EIP-712 and post it to the CLOB
- Track the fill and update the position ledger
# 1. Clone the repository
git clone https://github.com/YOUR-USERNAME/polymarket-bot.git
cd polymarket-bot
# 2. Install dependencies
pip install -e .
# 3. Configure credentials (see "Configuration" below)
cp .env.example .env
# edit .env with your Polygon private key + funder address
# 4. Run a dry-run with the built-in mean-reversion strategy
polymarket-bot run --strategy mean_reversion --dry-run
# 5. Go live (real orders!)
polymarket-bot run --strategy mean_reversionThat's it. The bot is now scanning Polymarket markets and printing every decision it makes.
- Python 3.10 or newer
- A Polygon wallet with USDC (PoS) for trading
- Either an email/Magic-wallet Polymarket account (signature_type=1, recommended) or a MetaMask/EOA wallet (signature_type=0, requires manual allowance approval)
pip install polymarket-botgit clone https://github.com/YOUR-USERNAME/polymarket-bot.git
cd polymarket-bot
pip install -e ".[dev]"docker pull ghcr.io/YOUR-USERNAME/polymarket-bot:latest
docker run --env-file .env ghcr.io/YOUR-USERNAME/polymarket-bot:latestAll credentials live in .env. Copy .env.example and fill in the blanks:
# Required
POLYMARKET_PRIVATE_KEY=0xabc... # Your Polygon wallet private key
POLYMARKET_FUNDER_ADDRESS=0xdef... # The address holding your USDC
POLYMARKET_SIGNATURE_TYPE=1 # 0=EOA/MetaMask, 1=Magic/Email, 2=Browser proxy
# Optional β auto-derived from private key if omitted
POLYMARKET_API_KEY=
POLYMARKET_API_SECRET=
POLYMARKET_API_PASSPHRASE=
# Endpoints (defaults shown)
POLYMARKET_CLOB_HOST=https://clob.polymarket.com
POLYMARKET_GAMMA_HOST=https://gamma-api.polymarket.com
POLYMARKET_DATA_HOST=https://data-api.polymarket.com
POLYMARKET_CHAIN_ID=137Strategy parameters live in config.yaml:
strategy:
name: mean_reversion
params:
lower_bound: 0.05
upper_bound: 0.30
min_volume_usd: 50000
max_spread: 0.03
risk:
max_position_size_usd: 25
max_open_positions: 5
daily_loss_limit_usd: 100
kill_switch_drawdown_pct: 20
execution:
scan_interval_seconds: 30
order_type: GTC # GTC, FOK, GTD
dry_run: falseThe bot ships with several reference strategies. Each lives in src/polymarket_bot/strategies/ and inherits from BaseStrategy.
| Strategy | Description | Best for |
|---|---|---|
mean_reversion |
Buys oversold YES/NO shares (price < lower_bound) and exits at fair value | Long-tail political and crypto markets |
market_making |
Posts both sides of the book around the midpoint, earns the spread | High-volume liquid markets |
arbitrage |
Detects mispriced pairs across related markets (e.g., NegRisk events) | Multi-outcome events |
ml_signal |
Uses an external ML model (your own) to generate buy/sell signals | Quants with edge data |
momentum |
Follows price moves above a configurable Z-score | Breaking news markets |
# src/polymarket_bot/strategies/my_strategy.py
from polymarket_bot.strategies.base import BaseStrategy, Signal
class MyStrategy(BaseStrategy):
name = "my_strategy"
def evaluate(self, market, orderbook, position) -> Signal | None:
if orderbook.best_ask < 0.10 and market.volume_24h > 10_000:
return Signal.buy(
token_id=market.yes_token_id,
price=orderbook.best_ask,
size=10,
)
return NoneDrop the file in the strategies/ folder and run:
polymarket-bot run --strategy my_strategypolymarket-bot markets list --sort-by volume --limit 10polymarket-bot orderbook --market-id 0xabc...polymarket-bot portfoliopolymarket-bot backtest --strategy mean_reversion --from 2026-01-01 --to 2026-04-01polymarket-bot order place \
--token-id 71321... \
--side BUY \
--price 0.42 \
--size 25from polymarket_bot import PolymarketBot
from polymarket_bot.strategies import MeanReversionStrategy
bot = PolymarketBot.from_env()
bot.add_strategy(MeanReversionStrategy(lower=0.05, upper=0.30))
bot.run()polymarket-bot/
βββ src/polymarket_bot/
β βββ __init__.py
β βββ bot.py # Main orchestrator
β βββ cli.py # Command-line interface (Typer)
β βββ config.py # Pydantic settings
β βββ exchange/
β β βββ clob.py # CLOB API wrapper (orders, fills)
β β βββ gamma.py # Gamma API wrapper (market discovery)
β β βββ data.py # Data API wrapper (positions, P&L)
β β βββ websocket.py # CLOB WebSocket client
β βββ strategies/
β β βββ base.py # Abstract base class
β β βββ mean_reversion.py
β β βββ market_making.py
β β βββ arbitrage.py
β β βββ momentum.py
β βββ risk/
β β βββ manager.py # Pre-trade risk checks
β β βββ kill_switch.py # Emergency stop
β βββ utils/
β βββ logging.py
β βββ metrics.py # Prometheus exporters
βββ tests/
βββ examples/
βββ docs/
βββ Dockerfile
βββ docker-compose.yml
βββ config.yaml
The codebase follows strict layering: the strategy layer never touches HTTP, the CLI never touches the order signer. This makes it trivial to swap any layer (use a different exchange wrapper, plug in a different signer, etc.).
β οΈ Trading is risky. This bot can and will lose money. Never deploy capital you can't afford to lose.
Built-in safeguards:
- Position size cap β no single order exceeds
max_position_size_usd - Open position cap β refuses new orders past
max_open_positions - Daily loss limit β auto-pauses trading after
daily_loss_limit_usd - Drawdown kill-switch β bot exits all positions on
kill_switch_drawdown_pct - Allowance check β verifies USDC and CTF allowances before each session
- Stale orderbook detection β rejects trades on books older than 5 seconds
- Slippage guard β limits slippage on market orders
- Rate limit honoring β backs off on 429 responses
docker compose up -dIncludes the bot, Prometheus, and a pre-built Grafana dashboard at http://localhost:3000.
A reference unit file is provided at examples/polymarket-bot.service.
sudo cp examples/polymarket-bot.service /etc/systemd/system/
sudo systemctl enable --now polymarket-bot
sudo journalctl -u polymarket-bot -fFor minimal latency to the Polymarket CLOB (hosted on AWS eu-west-2), pick a London, Dublin, or Amsterdam VPS. Round-trip latency from Dublin is under 5ms; from US East Coast it's around 130ms.
Q: Is using a bot on Polymarket allowed? Yes. Polymarket exposes a public CLOB API specifically for programmatic trading. Many of the platform's most active traders use bots.
Q: Does Polymarket have a testnet? No. All API calls hit production. Always start with $1β$5 position sizes when testing new logic.
Q: How much capital do I need? The CLOB has a $1 minimum order. Realistically, $50β$200 lets you run multi-position strategies. The bot itself is free.
Q: What are the fees? Makers pay 0%. Taker fees vary by category (crypto ~1.80%, sports 0.75%, politics 1.00%, geopolitics 0%). The bot's risk module accounts for this when computing expected value.
Q: Can I run multiple strategies at once?
Yes. Pass --strategy s1,s2,s3 or list them in config.yaml under strategies:.
Q: Will this bot make me money? That depends entirely on the strategy and your edge. The included strategies are reference implementations, not alpha. If they printed money out of the box, we wouldn't be giving them away.
Q: Does it work with Polymarket US (the CFTC-regulated US version)?
The Polymarket US API uses Ed25519 auth and lives at api.polymarket.us. Support is on the roadmap β see #1.
Q: What's the difference vs. py-clob-client?
py-clob-client is the official low-level SDK. This project sits on top of it and adds market discovery, strategy framework, risk management, scheduling, logging, and a CLI.
This software is provided "as is", without warranty of any kind. Trading prediction markets involves substantial risk of loss. The authors and contributors are not responsible for any financial losses incurred by using this bot. You are responsible for understanding the strategies you deploy and complying with all applicable laws and Polymarket's Terms of Service. Polymarket may not be available in your jurisdiction.
This project is not affiliated with, endorsed by, or sponsored by Polymarket. "Polymarket" is a trademark of its respective owner.
Contributions are welcome and encouraged! Whether it's a new strategy, a bug fix, a doc improvement, or a translation β open a PR.
- Fork the repo
- Create a feature branch (
git checkout -b feat/my-strategy) - Run
pre-commit installandpytest - Open a Pull Request
See CONTRIBUTING.md for details.
- Add a new reference strategy
- Improve test coverage
- Translate the README to your language
- Build out the Grafana dashboard
- Write a tutorial blog post (we'll link to it)
If this project saves you time, please star the repo β it helps other Polymarket traders find it.
Polymarket/py-clob-clientβ the official Python CLOB SDK this bot is built onPolymarket/py-clob-client-v2β newer v2 SDKPolymarket/agentsβ official LLM-driven agent reference- Polymarket Docs β the canonical API reference
Distributed under the MIT License. See LICENSE for details.
Keywords: polymarket, polymarket bot, polymarket trading bot, polymarket api, polymarket python, prediction market bot, prediction market trading, automated trading bot, crypto prediction market, CLOB API, py-clob-client, algorithmic trading, market making bot, arbitrage bot, polymarket automation, polygon trading bot, USDC trading bot, polymarket clob, polymarket gamma api, polymarket websocket.