My Polymarket Trading Bot in Rust After TypeScript Kept Missing Fills
A trader I was talking to recently said something that stuck with me: "I've blown accounts just from slow fills or missed order cancellations." He was talking about CEX perpetuals. But the problem is identical on Polymarket's CLOB - just measured in seconds instead of milliseconds. My TypeScript bot was averaging 340ms from signal detection to order placement on Polymarket's Central Limit Order Book. On a 5-minute market with a ~2.7-second mispricing window, that's 12% of the entire opportunity window consumed before a single byte hits Polymarket's servers. I was consistently entering at 74¢ when I'd detected the signal at 70¢. The market had already repriced against me. So I rewrote it in Rust. This article documents exactly what I found, what changed, and - critically - what didn't. Background: What My Bot Was Doing If you've read my earlier posts in this series ( architecture , Kelly Criterion sizing , last-60-seconds capture ), you know the context. But the short version: The bot targets Polymarket's 5-minute and 15-minute crypto up/down binary markets (BTC, ETH, XRP, SOL, DOGE, BNB). The strategy is simple: find markets that are briefly mispriced relative to real-time spot momentum, enter at a discount to fair value, hold to resolution. A 5-minute "XRP Up" market priced at 70¢ when spot momentum suggests 82% probability = +12¢ edge per dollar wagered. Do that 50 times a day with disciplined sizing and the math works - if you can actually get filled at the price you detected. The problem: by the time my TypeScript code detected the signal, formatted the order, opened an HTTP connection to Polymarket's CLOB API, waited for TLS handshake, serialized the payload, and received confirmation, the market had often moved to 74-76¢. I was paying for an edge I wasn't capturing. Profiling the TypeScript Bot: Where Was the 340ms Going? Before rewriting anything, I instrumented every stage of the order path. Here's what I found across 500 sampled trades: Stage Average time %