PitchHut logo
Polymarket Trading Bot - Order Book Aware Risk Engine
Python Polymarket bot with slippage-aware sizing and fractional-Kelly risk logic.
Pitch

Most Polymarket bots place a market order and call it done - fine on liquid markets, costly on Polymarket's thin, long-tail ones. This bot checks order book depth before sizing, calculates edge as model vs. market probability, sizes positions with fractional Kelly capped by a hard max-exposure limit, and avoids chasing slippage on partial fills.

Description

A Python-based trading bot for Polymarket that treats risk management as a first-class problem instead of an afterthought. Most bot tutorials and starter templates place a market order and call it done - that works fine on high-liquidity markets like major elections, but Polymarket has thousands of long-tail markets with thin order books and wide bid-ask spreads, where that same approach quietly bleeds money through slippage. This project is built around three core ideas: knowing your actual edge before trading, sizing positions in proportion to that edge rather than a flat bet size, and never filling into a market order without first checking whether there's enough liquidity to support the trade at an acceptable price. How it works The bot connects to Polymarket's two public services - the Gamma API for market discovery and metadata, and the CLOB API for order books, prices, and trade execution. Reading market data requires no authentication, so anyone can inspect live order books and prices before ever connecting a wallet. For each candidate market, the bot pulls the current order book and midpoint price, compares that market-implied probability against its own model's probability estimate, and only considers entering a position when the disagreement (edge) clears a configurable minimum threshold - filtering out noise-level signals. Position sizing uses a fractional-Kelly approach, scaled down from full Kelly to account for model uncertainty, and capped by a hard maximum-exposure-per-market limit. That cap is intentional: it's the difference between a mispriced model costing you a bad trade versus costing you the account. Before any order is placed, the bot checks remaining order book depth at the target price rather than chasing fills with repeated market orders - a naive approach that compounds slippage on thin books. What's included

Market discovery and order book reading via the Gamma/CLOB APIs Edge calculation (model probability vs. market implied probability) Fractional-Kelly position sizing with hard exposure caps Partial-fill and slippage-aware order logic Logging of both executed trades and trades the bot chose to skip, for calibration review

What's next Moving from REST polling to Polymarket's WebSocket feed for lower-latency order book updates, and adding correlation-aware exposure limits across markets tied to the same underlying real-world event (for example, multiple Fed-rate-cut contracts that aren't truly independent bets even though they're separate markets). Built for: developers and traders exploring prediction market automation who want a starting point that treats slippage, adverse selection, and correlated exposure as real risks - not edge cases to handle later.

0 comments

No comments yet.

Sign in to be the first to comment.