# Queue Position and Limit Order Fill Probability

First-in, first-out queues at a price, how long a limit order waits, the chance it fills, why moving it costs priority, and why fills come before price moves.

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 $q$ shares rests at the best bid, and $A$ 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{,}260$ shares ahead of your $q = 400$. Nothing happens to your order until $A$ 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 $A$. 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 $A$.

## Waiting time

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

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

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

$$
W \approx \frac{A}{v + c}.
$$

With $A = 1{,}260$, $v = 300$ and $c = 100$ the combined rate is 400 shares a minute and $W \approx 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 $t_0 = A/(v+c)$ the removed volume has a standard deviation of $\sigma\sqrt{t_0}$, where $\sigma^2 = \lambda E[S^2]$ is the variance of sell volume per minute (defined in the next section). Dividing a quantity in shares by the speed $v + c$ converts it to minutes:

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

In the example $\sigma \approx 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 $S$ with mean $\mu_s$ and second moment $E[S^2]$. Over a horizon of $h$ minutes the number of orders $N$ is Poisson with mean $\lambda h$, and the total volume is the random sum

$$
V = S_1 + S_2 + \cdots + S_N.
$$

Its mean follows from $E[V] = E[N]\,\mu_s$. For the variance, add the variance of the sizes and the variance of the count:

$$
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].
$$

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

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

$$
P(\text{fill}) \approx 1 - \Phi\!\left(\frac{A + 1 - \lambda h\,\mu_s - c\,h}{\sqrt{\lambda h\,E[S^2]}}\right).
$$

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

> The wait is about $A/(v+c)$, and the fill probability is $1 - \Phi(z)$ with $z$ 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$$ → **400**
2. Expected wait for the 1,260 shares ahead, in minutes.
   $$W = 1260 / 400$$ → **3.15**
3. After two minutes 800 shares are gone and this many remain ahead.
   $$A = 1260 - 2 \cdot 400$$ → **460**
4. Over the next minute sell orders (3 a minute, mean size 100) and cancellations remove this many shares on average.
   $$\lambda h\,\mu_s + c\,h = 3 \cdot 100 + 100$$ → **400**
5. Standard deviation of the sell volume, with $E[S^2] = 2 \cdot 100^2 = 20{,}000$.
   $$\sqrt{\lambda h\,E[S^2]} = \sqrt{3 \cdot 20000}$$ → **244.95**
6. Distance to the front in standard deviations.
   $$z = \frac{460 + 1 - 400}{244.95}$$ → **0.249**
7. Probability that the order starts to fill within the minute.
   $$P(\text{fill}) = 1 - \Phi(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.

*[Interactive figure: queue fill](https://quantsandbox.dev/guide/microstructure/queue-position)*

## 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.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.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 $A$ 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)$.
- Sell volume over a horizon is a compound Poisson sum with mean $\lambda h\,\mu_s$ and variance $\lambda h\,E[S^2]$, which gives $P(\text{fill}) \approx 1 - \Phi(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.

[Open the Limit Order Book lab](https://quantsandbox.dev/order-book)

## Interactive labs

- [Order Book Simulator: Slippage and Queues](https://quantsandbox.dev/order-book)

## Practice questions

### 1. Two buy limit orders rest at 99.97. Which one fills first when a market sell order arrives?

- a) The one that arrived first
- b) The larger one
- c) They split the sell order pro rata
- d) The one from the market maker

**Answer:** a) The one that arrived first

Price–time priority serves orders at the same price in order of arrival. Size and identity do not matter.

### 2. 900 shares are ahead of your order. Sell volume hits the bid at 250 shares per minute and cancellations ahead remove 50 shares per minute. What is the expected wait in minutes?

**Answer:** 3

The combined rate is $250 + 50 = 300$ shares a minute, so $W \approx 900/300 = 3$ minutes.

### 3. You cancel a resting buy order and enter it again at the same price. Where does the new order join the queue?

- a) At the back
- b) At its old place
- c) At the front, because it is the newest
- d) In the middle

**Answer:** a) At the back

Priority belongs to the original order. A re-entered order is a new order and goes to the back of the queue at that price.

---

Source: https://quantsandbox.dev/guide/microstructure/queue-position

Previous lesson: [Limit Order Book: Price–Time Priority and Slippage](https://quantsandbox.dev/guide/microstructure/limit-order-book)

Next lesson: [Adverse Selection: Markouts and Toxic Flow](https://quantsandbox.dev/guide/microstructure/adverse-selection)
