Betfair Exchange API Bot Coding: Execution Under Minimum Liquidity

Minimum liquidity is where lazy betting bots go to die, and if your Betfair Exchange API execution logic was written for the thick markets of a Saturday Premier League kickoff, it will get shredded the moment you point it at a Tuesday afternoon greyhound card. The brutal truth is that most bot coders never test under thin books, and the exchange punishes that arrogance with slippage, partial fills, and unmatched orders that rot on the ladder until the price moves against you.

The Real Mechanics of a Thin Order Book

When available liquidity drops below a few hundred pounds on either side, the spread widens and the queue position game flips completely. Your bot cannot assume that a back bet at the best price will fill just because the price is showing. At minimum liquidity, a single matched contract can move the touch, and your aggressive IOC orders will eat through three or four price levels before the matching engine even acknowledges the request. I have seen bots coded with a fixed stake of twenty quid take a seven-tick worst-case execution because the coder never implemented a depth check against the Betfair Exchange API price ladder before firing.

The fix is not elegant, but it works: pull the full market book via the listMarketBook endpoint, calculate the aggregate volume within your acceptable slippage tolerance, and abort the order if the total matched size at or better than your limit price falls below your threshold. Never let the bot fire blind into an empty book. 🎯

Order Types That Survive Low Liquidity

Limit-on-close and fill-or-kill are your only friends here. Market orders on a thin market are financial suicide, and any coder who defaults to a marketable bet without a size cap deserves the losses. Use fill-or-kill for entries where you need the full stake matched at a specific price, and use passive limit orders with a generous persistence policy when you are willing to wait for liquidity to come to you. The key coding pattern is a pre-trade liquidity audit that queries the available size at your target price, compares it against your minimum acceptable fill ratio, and only then constructs the placeOrders payload.

Latency and Partial Fill Management

Under minimum liquidity, partial fills are not an edge case, they are the default outcome. Your bot must maintain a state machine that tracks every unmatched remainder, re-evaluates the book on each stream update, and decides whether to cancel, amend, or chase. The killer mistake is treating a partial fill as a completed trade and moving on. I have audited bots that left orphaned unmatched bets sitting on the exchange for hours because the reconciliation loop only checked matched amounts and ignored the size remaining. 😤 That is not a bug, that is a design failure, and it bleeds money silently.

Wire your stream listener to the MCM message type, parse the unmatched order delta on every update, and enforce a hard timeout that cancels any order unfilled after a configurable window. Combine that with a circuit breaker that halts trading if the book depth collapses below your floor, and you have an execution layer that respects the reality of thin markets instead of pretending they do not exist.

Stake Sizing Against Visible Depth

Fixed staking is a trap under minimum liquidity. Your stake must be a function of the visible matched volume at your target price, capped at a percentage you define, typically no more than twenty to thirty percent of the available size. Code the sizing logic to recalculate on every book refresh, not once at order construction. If the depth evaporates between your calculation and your submission, the fill-or-kill flag catches it. If you skip the flag, you are gambling, not trading. 🔥 The Betfair Exchange API gives you every tool to do this properly, and the coders who ignore the depth data are the ones funding the rest of us.

The minimum viable execution stack under thin liquidity is a pre-trade depth audit, a size-capped fill-or-kill order, a reconciliation loop that tracks unmatched remainders, and a hard cancel timeout. Anything less and your bot is just a donation machine with extra steps.