Polymarket HFT Bot
RLtradingcpppythonpytorch
A low-latency hybrid C++/Python trading framework for Polymarket BTC 15-minute prediction markets, pairing a C++23 execution engine with a PPO agent through pybind11.
What it is
The C++ layer ingests Polymarket CLOB and Binance aggTrade WebSocket feeds with sub-millisecond latency, maintaining a thread-safe L2 order book with live micro-price and volatility estimates. A log-normal probability model prices the contracts fairly and flags cross-venue arbitrage across Polymarket, Kalshi, and Binance. The Python layer runs a PPO agent with an LSTM actor-critic that learns entry and exit timing across the 15-minute contract lifecycle, with reward shaping for fees, gas, and inventory risk.
Why it matters
Short-dated prediction markets are thin, fast, and mispriced relative to spot — but exploiting that needs both microsecond execution and a policy that adapts to the contract's lifecycle. Splitting the system across C++ and Python gets both without compromising either.
Stack
C++23Python 3.11PyTorchGymnasiumboost::beastpybind11scipypy-clob-client