Quant Sandbox
DerivativesPortfolio & RiskFixed IncomeCorporate FinanceProbability & MeasureStochastic ModelsMarket MicrostructureGuide
Guide
Derivatives pricing0 / 17
01Forwards, calls and puts02Combining positions03Arbitrage and the forward price04Put–call parity05The one-step binomial model06Risk-neutral probabilities07Multi-step trees and backward induction08American options and early exercise09Delta and hedging10Geometric Brownian motion11The Black–Scholes formula12The Greeks: gamma, vega, theta and rho13Options on dividend-paying stocks, indices, currencies and futures14Implied volatility and the volatility smile15Stochastic volatility and the Heston model16Static replication: Breeden–Litzenberger and Carr–Madan17Exotic options: barriers, Asians and digitals
Portfolio & risk0 / 12
01Returns and volatility02Diversification and correlation03The efficient frontier and the capital market line04Risk aversion and the optimal complete portfolio05CAPM, beta and the security market line06Performance measures: Sharpe, Treynor, Jensen and information ratio07Factor models and systematic risk08The Fama–French factor models09Value at Risk and expected shortfall10Systemic risk and contagion11Portfolio constraints and the no-short-sales frontier12Estimating expected returns and covariances
Fixed income0 / 10
01Bond prices and yields02Duration and convexity03Immunization and duration matching04Spot rates, forward rates and the yield curve05Non-parallel curve moves and key-rate durations06Bond futures and the cheapest-to-deliver07Interest rate swaps08Callable bonds and negative convexity09Credit risk: default probabilities and credit spreads10Real rates, inflation and inflation-linked bonds
Corporate finance0 / 10
01Interest, compounding and discounting02Annuities, perpetuities and loan amortization03Net present value and internal rate of return04Project risk: sensitivity, scenarios and Monte Carlo NPV05The weighted average cost of capital06Capital structure and the Modigliani–Miller theorems07Dividends, payout policy and the dividend discount model08Discounted cash flow valuation09Relative valuation with multiples10Real options: the value of flexibility
Probability and measure0 / 13
01Measuring the size of sets02σ-algebras and Borel sets03Lebesgue measure and null sets04Measurable functions05The Lebesgue integral06Convergence theorems07Probability spaces and Kolmogorov's axioms08Random variables and their distributions09Expectation, variance and inequalities10Independence and product measures11Modes of convergence and the law of large numbers12Conditional probability and conditional expectation13Measure theory in option pricing
Stochastic models0 / 17
01Random walks and Brownian motion02The law of large numbers and the central limit theorem03Probability spaces, σ-algebras and random variables04Filtrations, adapted processes and stopping times05Conditional expectation and martingales06Properties of Brownian motion07The reflection principle and first passage times08The Brownian bridge09The Itô integral10Itô's lemma11Kolmogorov equations and the Feynman–Kac formula12Change of measure and Girsanov's theorem13Monte Carlo option pricing14Simulating SDEs: the Euler–Maruyama scheme15Correlated Brownian motions and multi-asset models16Mean reversion: Ornstein–Uhlenbeck and Vasicek17Jumps and the Merton jump-diffusion model
Market microstructure0 / 11
01Market makers and liquidity02The limit order book03Queue position and fill probability04Adverse selection and informed trading05The Glosten–Milgrom model06Measuring and decomposing the bid–ask spread07Informed trading and Kyle's lambda08Price impact and optimal execution09Inventory risk and quote skewing10Optimal quoting: the Avellaneda–Stoikov model11Market making profit and loss attribution
Knowledge graph

© 2026 Quant Sandbox · A study aid for quantitative finance

Privacy & dataNo cookies

This site does not use cookies and asks for no personal data. It keeps a few small settings in your browser's local storage — your chosen theme and language, the sidebar layout, and your progress and answers in the Guides — so it remembers them on your next visit. This data never leaves your device; clearing your browser storage removes it. Inputs you change can also be captured in the page URL, so you can share or bookmark a specific setup. The site uses Vercel Web Analytics, a privacy-friendly, cookieless service that records only anonymous, aggregated usage (such as page views) without identifying you or tracking you across other sites.

Guides/Market microstructure/03

Queue position and fill probability

Lesson 3 of 11 · 1 min read

A limit order earns the spread only if someone trades against it. "The limit order book" showed that orders resting at one price are served in the order they arrived. This lesson asks what that rule means for a single resting order: how long it waits, how likely it is to trade within a given time, and what it costs to move it. The answers decide whether a market maker (a trader who keeps buy and sell quotes in the book) actually collects the spread it quotes.

Throughout, a buy limit order of qqq shares rests at the best bid, and AAA shares are queued in front of it. Time is measured in minutes and sizes in shares.

The queue at a price

Under price–time priority, orders at the same price trade in the order they arrived, first in, first out. A new order joins at the back of the queue. Your order trades only after every share ahead of you has either been executed or cancelled. What counts is shares, not orders: 1,260 shares ahead of you is 1,260 shares ahead, whether they sit in three orders or in thirty.

Take a best bid of 99.97 with A=1,260A = 1{,}260A=1,260 shares ahead of your q=400q = 400q=400. Nothing happens to your order until AAA has fallen to zero, and then it fills gradually as further sell volume arrives.

What moves you forward

Only two things shrink the number of shares ahead of you:

  1. Market sell orders hit the bid. They are matched against the front of the queue at the best bid, so each one removes its size from AAA. Market buy orders trade at the ask and leave your queue alone.
  2. Cancellations ahead of you. A trader who changes their mind removes their shares and everyone behind moves forward.

New orders arriving at 99.97 join behind you and cancellations behind you do not matter, so neither changes AAA.

Waiting time

Suppose sell volume hits the bid at a constant vvv shares per minute and cancellations ahead of you remove ccc shares per minute. The queue ahead then shrinks linearly:

A(t)=A−(v+c) t.A(t) = A - (v + c)\,t.A(t)=A−(v+c)t.

Your first share can trade once A(t)A(t)A(t) reaches zero. Solving for ttt gives the waiting time:

W≈Av+c.W \approx \frac{A}{v + c}.W≈v+cA​.

With A=1,260A = 1{,}260A=1,260, v=300v = 300v=300 and c=100c = 100c=100 the combined rate is 400 shares a minute and W≈3.15W \approx 3.15W≈3.15 minutes.

Real flow is not constant: market orders arrive at random times with random sizes. The formula still gives the typical wait, but individual waits scatter around it. Over the time t0=A/(v+c)t_0 = A/(v+c)t0​=A/(v+c) the removed volume has a standard deviation of σt0\sigma\sqrt{t_0}σt0​​, where σ2=λE[S2]\sigma^2 = \lambda E[S^2]σ2=λE[S2] is the variance of sell volume per minute (defined in the next section). Dividing a quantity in shares by the speed v+cv + cv+c converts it to minutes:

sd(W)≈σA(v+c)3/2.\text{sd}(W) \approx \frac{\sigma\sqrt{A}}{(v+c)^{3/2}}.sd(W)≈(v+c)3/2σA​​.

In the example σ≈245\sigma \approx 245σ≈245, so the standard deviation is about 1.1 minutes: an order that is expected to wait 3.15 minutes can easily wait two or five.

Fill probability

To go from an average wait to a probability, model the sell volume itself. Market sell orders arrive at random times at rate λ\lambdaλ per minute, and each has an independent random size SSS with mean μs\mu_sμs​ and second moment E[S2]E[S^2]E[S2]. Over a horizon of hhh minutes the number of orders NNN is Poisson with mean λh\lambda hλh, and the total volume is the random sum

V=S1+S2+⋯+SN.V = S_1 + S_2 + \cdots + S_N.V=S1​+S2​+⋯+SN​.

Its mean follows from E[V]=E[N] μsE[V] = E[N]\,\mu_sE[V]=E[N]μs​. For the variance, add the variance of the sizes and the variance of the count:

E[V]=λh μs,Var(V)=E[N] Var(S)+Var(N) μs2=λh (E[S2]−μs2)+λh μs2=λh E[S2].E[V] = \lambda h\,\mu_s, \qquad \text{Var}(V) = E[N]\,\text{Var}(S) + \text{Var}(N)\,\mu_s^2 = \lambda h\,\big(E[S^2] - \mu_s^2\big) + \lambda h\,\mu_s^2 = \lambda h\,E[S^2].E[V]=λhμs​,Var(V)=E[N]Var(S)+Var(N)μs2​=λh(E[S2]−μs2​)+λhμs2​=λhE[S2].

This is the same structure as the walk in "Random walks and Brownian motion": a sum of independent steps whose mean grows with time hhh and whose standard deviation grows with h\sqrt{h}h​.

Cancellations ahead remove another c hc\,hch shares. The first share of your order trades if the volume plus the cancellations reach A+1A + 1A+1 shares. When many orders arrive, the sum VVV is close to normal, and with Φ\PhiΦ the standard normal distribution function

P(fill)≈1−Φ ⁣(A+1−λh μs−c hλh E[S2]).P(\text{fill}) \approx 1 - \Phi\!\left(\frac{A + 1 - \lambda h\,\mu_s - c\,h}{\sqrt{\lambda h\,E[S^2]}}\right).P(fill)≈1−Φ(λhE[S2]​A+1−λhμs​−ch​).

If sizes are exponential, E[S2]=2μs2E[S^2] = 2\mu_s^2E[S2]=2μs2​. Orders of mean 100 shares arriving 3 times a minute give 300 shares of sell volume per minute and λE[S2]=60,000\lambda E[S^2] = 60{,}000λE[S2]=60,000, a standard deviation of 245 shares.

The wait is about A/(v+c)A/(v+c)A/(v+c), and the fill probability is 1−Φ(z)1 - \Phi(z)1−Φ(z) with zzz the shares still to be removed, in standard deviations of the sell volume. The normal approximation is rough when only a few orders arrive per minute.

Worked example

Waiting, and the chance of a fill

  1. Sell volume and cancellations together remove this many shares per minute.

    v+c=300+100\displaystyle v + c = 300 + 100v+c=300+100=400
  2. Expected wait for the 1,260 shares ahead, in minutes.

    W=1260/400\displaystyle W = 1260 / 400W=1260/400=3.15
  3. After two minutes 800 shares are gone and this many remain ahead.

    A=1260−2⋅400\displaystyle A = 1260 - 2 \cdot 400A=1260−2⋅400=460
  4. Over the next minute sell orders (3 a minute, mean size 100) and cancellations remove this many shares on average.

    λh μs+c h=3⋅100+100\displaystyle \lambda h\,\mu_s + c\,h = 3 \cdot 100 + 100λhμs​+ch=3⋅100+100=400
  5. Standard deviation of the sell volume, with E[S2]=2⋅1002=20,000E[S^2] = 2 \cdot 100^2 = 20{,}000E[S2]=2⋅1002=20,000.

    λh E[S2]=3⋅20000\displaystyle \sqrt{\lambda h\,E[S^2]} = \sqrt{3 \cdot 20000}λhE[S2]​=3⋅20000​=244.95
  6. Distance to the front in standard deviations.

    z=460+1−400244.95\displaystyle z = \frac{460 + 1 - 400}{244.95}z=244.95460+1−400​=0.249
  7. Probability that the order starts to fill within the minute.

    P(fill)=1−Φ(0.249)\displaystyle P(\text{fill}) = 1 - \Phi(0.249)P(fill)=1−Φ(0.249)=0.4017

With only three orders a minute the sum is skewed and the normal approximation is coarse: simulating the same queue many times gives a fill chance of about a third rather than 40%. Many orders per minute make it accurate.

The figure draws the queue as blocks of 100 shares, with your order outlined and the front on the right, and plots the one-minute fill probability against the number of shares ahead. Start at the defaults: 1,260 shares ahead, an expected wait of 3.15 minutes, and a one-minute fill probability of only 0.02%. Press Simulate 1 minute to see random sell volume and cancellations eat the front, and press it again until your order starts to fill. Then raise the sell volume to 600 per minute, or drag the starting position to 400, and watch the curve and the readouts change.

Queue position and the chance of a fillOpen in Order Book
300 / min
01000
100 / min
0400
1260
02000
front →← backyour order
Fill within 1 minute
Shares ahead
1260
Expected wait
3.15 min
Fill within 1 minute
0.02%
Filled
0 of 400 shares

Losing priority

Priority is built only by waiting. Changing the price means cancelling and entering a new order at the other level, which joins the back of that queue. Raising the size usually does the same, because the extra shares cannot jump ahead of orders that arrived before them. Cancelling and re-entering at the same price also sends you to the back.

Suppose you have waited two minutes in the example, so 460 shares are ahead and the remaining wait is 460/400=1.15460/400 = 1.15460/400=1.15 minutes. If 500 shares have joined behind you meanwhile and you now cancel and re-enter, you start again with 960 shares ahead and a wait of 960/400=2.4960/400 = 2.4960/400=2.4 minutes. This is why makers leave resting orders alone unless the market gives them a reason to move.

Which fills you get

Your bid trades only when sellers push through the level, and an order at the back trades only after all the volume ahead of it has been consumed. So the fills you receive are not a random sample of market conditions. Orders near the front fill in quiet trading; orders at the back fill when selling is heavy and persistent, which is also when the price is more likely to keep falling after the fill. A queue position is therefore a choice about both how often to trade and in what conditions.

Summary

  • Orders at one price trade first in, first out; your order trades only after all AAA shares ahead are executed or cancelled.
  • Market sells at the bid and cancellations ahead are the only things that move you forward, giving an expected wait of about A/(v+c)A/(v + c)A/(v+c).
  • Sell volume over a horizon is a compound Poisson sum with mean λh μs\lambda h\,\mu_sλhμs​ and variance λh E[S2]\lambda h\,E[S^2]λhE[S2], which gives P(fill)≈1−Φ(z)P(\text{fill}) \approx 1 - \Phi(z)P(fill)≈1−Φ(z).
  • Cancelling and re-entering sends you to the back of the queue, so moving an order costs the time already waited.
  • Back-of-queue fills tend to come when selling is heavy, so the price often continues to fall afterwards.
Try itOpen the Limit Order Book lab
3 questions on this lesson at the end of the series
Previous · 02The limit order bookNext · 04Adverse selection and informed trading
Connections

Queue position and fill probability

Open the full graph
Builds on
07.02The limit order book06.01Random walks and Brownian motion
Leads to
07.04Adverse selection and informed trading07.11Market making profit and loss attribution
See it in the knowledge graph
Labs for this lesson
Order Book