Building a Polymarket Trading Bot: Order Book Monitoring, Slippage Handling, and Position Sizing
Most first-attempt Polymarket bots place a market order and call it done. That works fine on liquid, high-volume markets, but Polymarket has thousands of long-tail markets with thin order books and wide bid-ask spreads, where a naive market order can fill at a price far from the quote seen just a moment earlier.
Polymarket's API is split into two services. The Gamma API handles public, read-only market discovery. The CLOB API handles order books, prices, and actual trading. Reading market data requires no authentication, while placing orders does.
A solid bot workflow starts by discovering a market and pulling its order book, then calculating edge by comparing a model's estimated probability against the market's implied probability. Position sizing should use a fractional-Kelly approach, capped by a hard maximum exposure per market, since that cap matters more for risk control than the Kelly fraction itself. Before filling an order, checking remaining order book depth prevents chasing slippage with repeated market orders on a thin book.
Lessons worth passing on: poll less and cache more rather than hammering the API on a flat interval, log every trade the bot decided not to make since that data reveals whether the edge threshold is actually calibrated, and treat correlated markets as one combined position rather than separate independent bets, since they often share the same underlying real-world event.
https://github.com/casatrick/polymarket-arbitrage-bot-python
Comments
Post a Comment