In one sentence
Queue position modelling works out where your unmatched bet sits in line at its price and how quickly the money ahead of you is likely to clear.
How it works
Betfair matches bets at each price on a first come, first served basis. If you ask to back at 2.50 and £300 is already waiting there, that £300 is matched before a penny of yours. Your bet waits in the pink "available to lay" column until layers come along and take that price.
Two things move you up the line. Layers taking the price match the money at the front, and people ahead of you cancel. Both arrive at uneven, random times, so a sensible model treats them as a random flow with an average rate.
The trade-off is simple. Joining a queue gets you a better price than taking one, but you might never be matched, and the bets that do get matched are often the ones you would rather not have (the price was about to move against you).
The maths
- T: expected time until your bet is fully matched.
- Q ahead: money in front of you at your price.
- rm: rate at which money is matched at that price (£ per minute).
- rc: rate at which money ahead of you is cancelled.
- S: your own stake.
- Nt: number of matching trades in time t, assumed to follow a Poisson distribution with rate λ per minute.
- k: number of average-sized trades needed to clear everything ahead of you plus your stake.
In plain English: the line shrinks from matching and cancellations, then your own stake needs matching; randomness decides whether it happens in time.
Worked betting example
Pre-match, you place a £100 back on Over 2.5 goals at 2.50 behind £300 already waiting. From recent data, layers take about £40 a minute at this price and about £10 a minute of the money ahead is cancelled.
Step 1, reach the front: 300 ÷ (40 + 10) = 6 minutes.
Step 2, get your own £100 matched: 100 ÷ 40 = 2.5 minutes.
Expected wait ≈ 8.5 minutes.
Now the uncertainty. Ignore cancellations and suppose matching trades arrive at 2 per minute, averaging £20 each. You need £400 of matching, which is 20 trades. Over 10 minutes the expected number of trades is 20, and the Poisson chance of at least 20 is about 53%. With kick-off in 10 minutes, it is close to a coin flip whether you get fully matched.
If that is not good enough, you could take the best available back price in the blue column now and accept shorter odds. If there is a gap in the ladder, asking for one tick shorter than 2.50 puts you at the front of a new, empty queue.
Where it's good
- Pre-match football trading, where you must decide whether an unmatched bet will fill before kick-off.
- Scalping, where getting matched first at a price is the whole game.
- Comparing the cost of waiting (missed fills) with the cost of crossing (paying a tick or more).
- Setting sensible cancel-and-replace rules for bots.
Limitations and pitfalls
- Betfair does not show your exact place in the queue; you must track the ladder yourself and estimate it.
- Rates change sharply, especially in the last minutes before kick-off or after a goal, so averages go stale fast.
- Adverse selection: fills tend to happen just before the price moves against you, so a filled bet is worth less than it looks.
- Cancellations ahead of you are not evenly spread; large wall orders often vanish all at once.
- Betfair's in-play bet delay means in-play queue dynamics differ from pre-match.
- Money from Betfair's cross-matching can match your bet without anyone hitting your exact price, which simple models miss.
How to build it
- Log ladder changes at your price from the Betfair Stream API (betfairlightweight) to estimate matching and cancellation rates.
- scipy.stats.poisson gives fill probabilities; a small simulation in numpy handles uneven trade sizes.
- Tip: measure how the price moved in the minute after your fills to see how much adverse selection costs you.
Related methods
- Poisson processes are the standard model for random arrival of trades.
- Birth-death processes model the queue growing and shrinking at the same time.
- Order book imbalance hints which queues are likely to clear first.
- Market impact is the cost of skipping the queue altogether.