This is the companion piece to our Python-to-Rust migration write-up. That post covered the latency work — why we moved a live market-making bot's hot path off a slow control loop and into a Rust sidecar. This one covers what the speed is *for*: the anti-pickoff logic that decides whether a market maker on the Polymarket prediction market earns a small, reliable edge or bleeds money every time the market moves. Client and product stay anonymous; the venue does not.
Why a tight spread is a losing spread
A completed pair earns a small, reliable amount. A single naked leg loses several times that. So the entire economics of the strategy live in one number: how often a resting quote gets picked off before it can be cancelled. Tighten the spread to win more fills and you also shorten the distance the underlying has to travel before your quote is stale — you win more often and lose bigger. The job is not to quote as tight as possible; it is to quote just tight enough to trade while keeping a stale quote alive for as few milliseconds as possible. Everything below is a different attack on that same window.
Pre-signing and dynamic requoting shrink the pickoff window
The first lever is latency, and the trick is to do the expensive work early. The order is fully formed and cryptographically signed *before* it needs to be sent, so the actual place-or-cancel carries almost no compute — it is a pre-built message going out on the wire. A low-latency Rust sidecar watches the exchange feed continuously and signals a cancel the instant the underlying moves against a resting leg. Detection happens in milliseconds off the live feed, not on the next tick of a multi-second poll. A narrower “price moved → stale quote gone” window means fewer toxic fills, and it is the whole reason the rest of the defences get a chance to fire in time.
Order-book imbalance: stop buying the leg the market left
The exact thresholds — how much skew triggers a pause, how wide the hysteresis band sits, how long the blackout runs — are proprietary and stay out of this post. The mechanism is the transferable part: a directional filter sitting in front of the quoting loop, turning off the side of the book that has become a liability rather than trying to trade it faster.
Short-lived orders and an event-reactive requote loop
Quotes are posted at least a tick inside the spread and kept deliberately short-lived: cancelled and reposted as the book updates rather than left resting to age into a liability. The requote loop is event-reactive, not fixed-interval — a mid-move on the market WebSocket wakes it early instead of waiting out a poll, and that wake-up is throttled so a burst of updates cannot thrash the loop into cancel/replace spam. The effect is that the freshest quotes appear exactly when the market is moving, which is precisely when a stale quote is most dangerous.
Post-only enforcement, in two layers
A market maker that accidentally crosses the book becomes a fee-paying taker — the opposite of the job. Post-only enforcement makes that structurally impossible, and we enforce it twice:
- Client-side: before sending, the system fetches the book, rounds the price defensively away from the cross, and refuses — raising an error — any quote that would be marketable. A marketable quote never leaves the process.
- Server-side: the venue's own post-only flag rejects a marketable order outright rather than filling it as a taker. It is the backstop for anything the client-side check misjudges.
A pickoff scenario, defended
Put it together on a concrete move. The maker is resting a buy on UP just below mid and a matching bid on DOWN, aiming to assemble the sub-$1 pair. The underlying ticks up sharply. The DOWN bid is now stale-high, and a counterparty hits it — the maker is left holding a naked DOWN leg while UP is the leg that is winning. This is the exact event that used to leak money on a slow control loop. Now the defences fire together:
- The Rust sidecar sees the move on the feed and cancels the lagging leg in milliseconds.
- The WebSocket-reactive requote loop wakes early and reprices instead of waiting for the next tick.
- The imbalance guard, seeing the book skew toward UP, pauses further DOWN buys so the position cannot get worse.
- Post-only enforcement guarantees none of the corrective quotes cross the book and pay taker fees.
Then the endgame matters. To flatten the residual naked DOWN leg, the system *sells that one leg* rather than buying its complement and merging the pair. Buying the other leg to merge locks the loss in more expensively and burns merge gas; selling the single leg closes the exposure directly and cheaply. Reacting fast is only half of it — reacting the right way is the other half.
| Defence layer | What it does | Failure it prevents |
|---|---|---|
| Pre-signed place/cancel | Signs the order before it is needed | Cancel too slow to beat the move |
| Rust feed sidecar | Detects the adverse move in ms | Stale quote resting into a fill |
| Imbalance guard | Pauses buys on the abandoned leg | Volunteering for the losing side |
| Event-reactive requote | Reprices on a mid-move, throttled | Old quotes aging through a poll |
| Post-only (two layers) | Refuses any marketable quote | Crossing the book as a taker |
None of these are exotic on their own. What makes them work is that they are wired to fire in the same few milliseconds, off the same live feed, on the one event that decides whether the strategy is profitable. That coordination — not any single clever rule — is the anti-pickoff system.
If you are building an automated trading or market-making system and fighting the same problem — a strategy that is correct in backtests but leaks money on live moves — that is the shape of work we do. See the full build in our Polymarket trading system case study, or read how we approach AI agents and bots.
Frequently asked questions.
Need this done instead of just read about it?
99 Francs is a senior product studio working outcome-based: no upfront payment, a fixed price per phase, and you pay at the end of a phase — only once you've seen it working. Tell us what you're building, and we'll reply with a phased plan and a fixed quote within one working day.



