Good strategy, bad execution on Polymarket — need help improving my execution layer
Hi everyone, I’m working on a Polymarket trading bot. The strategy looks decent in backtests/paper trading, but live P&L is negative. I’m fairly confident the signal isn’t the main problem — execution is. I’m looking for engineering feedback, not signals or financial advice. Context: Strategy: Latency Arbitrage Markets: Bitcoin Up or Down 5m Stack: [Node], Polymarket CLOB API, Polygon, USDC Order…
You've built a Polymarket trading bot, but the live performance isn't reflecting the promising backtests and paper trading results. You're confident the strategy itself is sound, but the execution is the culprit behind the negative P&L. You're reaching out specifically for engineering guidance, not for opinions on the trading signals or financial advice.
Your strategy involves arbitrage in Bitcoin's Up or Down market within a 5-minute window. You're using Node.js, Polymarket's CLOB API, Polygon, and USDC as the currency. You're employing a FOK (Fill or Kill) order type and gathering data through polling, websockets, Gamma API, or Data API. Typically, your order size is around 5 SHARs. Your execution environment could be a VPS, home server, or even a local laptop. You've estimated the latency, though the exact figure is unknown.
The problems you're encountering in the live execution are substantial. The gap between the expected price and the actual fill price is significant, leading to partial fills that leave you with undesirable inventory. The canceling or replacing of orders is also too slow, causing you to chase price movements and end up with worse execution prices. The backtest assumes fills that don't materialize in the live environment. Moreover, there are API, gas, relayer, and rate-limiting errors that occur during execution.
You've already taken some steps to mitigate these issues. You've switched from market orders to limit orders, reduced your order size, widened your price bands, improved your logging, and implemented retries and rate limiting. You're open to more suggestions on these fronts.
What you're really seeking is help in modeling realistic fill probability on Polymarket, designing an optimal order manager for CLOB trading, handling latency and partial fills, and accurately backtesting with real order book data instead of estimated fills. You're also looking for open-source examples or tools for Polymarket CLOB execution and guidance on measuring execution quality, such as slippage, fill rate, and adverse selection.
If you've built execution bots for Polymarket or similar CLOBs, your feedback, code examples, documentation, or even a critique of your approach would be highly appreciated. You're willing to share anonymized logs or code snippets to facilitate this discussion.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.