Betfair Exchange API Bot Coding: Execution Under Minimum Liquidity
Order matching on the Betfair Exchange collapses into a brutal game of milliseconds and partial fills the moment you drop below a certain liquidity threshold, and your bot's execution logic either survives that environment or gets shredded by it. Most developers test their Betfair Exchange API bot coding against liquid Premier League markets, then watch their edge evaporate in thin greyhound or lower-tier tennis books. That is a coding failure, not a market failure.

The Liquidity Floor Is a Moving Target, Not a Constant
Minimum liquidity is not a fixed number you hardcode into a config file. The available volume on a Betfair exchange market fluctuates by the second, and your execution layer must treat every order against a live snapshot, never against a cached figure from three seconds ago. 📉 If your bot fires a back bet at odds of 4.2 based on a stale price, you are not trading — you are donating to the market makers. Pull the available-to-back and available-to-lay figures directly from the streaming API, and recalculate your stake sizing against the real depth at that exact tick. Anything less is amateur hour.

Order Types That Actually Work in Thin Books
Market orders in a minimum liquidity environment are financial suicide. The spread widens, and a fill-or-kill market order will either get rejected or sweep through three price levels you never intended to touch. 💀 Your bot must default to limit orders with a defined price tolerance, and it must implement a proper unmatched-bet persistence strategy. Betfair gives you the persistence type control for a reason — LAPSE, PERSIST, and MARKET_ON_CLOSE behave wildly differently when the book is thin. A LAPSE order simply dies when the market turns in-play, which is often exactly what you want to avoid getting caught in a liquidity vacuum.
Partial Fill Handling and the Re-Entry Loop
Here is where ninety percent of bots break. Your bot places a £200 back at 3.5, but the book only absorbs £60. Now you hold an unmatched £140 sitting in the market, and your position sizing is completely off. The execution engine must detect the partial fill within one heartbeat cycle, cancel the residual unmatched portion if your strategy demands full size, and either re-price or abandon. 🔄 Build a strict state machine: PENDING, PARTIAL, FILLED, CANCELLED. Without this, your risk exposure silently drifts and your staking model thinks it has a position it does not actually hold.
Latency, Heartbeats, and the Cost of Being Slow
In minimum liquidity markets, the order book updates far less frequently than in liquid ones, which sounds like an advantage until you realize that every update is a larger relative shift. Your bot's heartbeat interval must be tuned tighter than the market's average update frequency, otherwise you are reacting to ghosts. ⚡ The streaming API connection needs aggressive reconnect logic with exponential backoff, and your order placement path must bypass any unnecessary middleware. Every millisecond of overhead between signal generation and order submission is a millisecond the book has to move against you.
Stake Sizing Against Real Depth, Not Assumed Depth
Size your order as a fraction of the actual available volume at your target price — never more than thirty percent of the visible depth, and often far less in the thinnest books. If the available-to-back at 3.5 is £150 and your model wants £180, you do not place £180 and hope. You place £45, monitor the fill, and ladder the rest only if liquidity replenishes. This is the discipline that separates a bot that grinds out small edges from one that blows up on a single illiquid afternoon fixture. The exchange does not care about your model's assumptions; it only fills what the counterparty is willing to take.