Trading Dev AcademyFree quant education

Free lesson · HFT & microstructure

Queue position, fill probabilities and adverse selection

Open interactive lessonPractice calculationsExplore labs

Start with the idea

A passive quote earns spread only if it fills, and fills are not a random sample of all market states. The people willing to trade against you may know something your quote has not yet reflected.

Symbols, units & horizon
  • F: filled quantity in a simplified FIFO trade-only queue
  • q: own size
  • V: aggressive volume at the same price after arrival
  • A: quantity ahead, assumed unchanged except consumed by these trades
  • p_f: fill probability
  • s: spread capture per filled unit
  • a: expected adverse markout loss conditional on fill
  • f: fees net of rebates per filled unit
  • o: opportunity cost per unfilled attempted unit
  • EV: expected value per attempted unit, all values in matching currency or ticks

When and why to use this

Use queue and conditional-markout models when evaluating passive execution or market-making edge. They connect book prediction to actual realised fills.

For price–time priority, orders already ahead must be removed before yours can fill. Cancellations ahead help; cancellations behind do not. New orders at your price usually join behind, while hidden liquidity, pro-rata rules and venue-specific priority require different models.

A conservative replay needs exact order identity or a queue-position approximation with uncertainty. Merely touching your limit does not establish a fill. Moving a quote can lose priority; a cancel request leaves exposure live until it becomes effective.

Measure a signed markout after fills: for a passive buy, compare a later reference midpoint with the fill price. Separate spread earned from subsequent adverse movement and mark unfilled opportunities too. A strategy can have an attractive fill rate precisely because its quotes are stale.

F=min⁡(q,max⁡(0,V−A)),EV=pf(s−a−f)−(1−pf)o
Model assumptions, derivation and arithmetic

Queue position, fill probabilities and adverse selection

  1. Aggressive volume first consumes A units ahead. Only positive excess V−A can reach your order, capped at your own q.
  2. For expected quote value, condition on fill versus no fill. A fill produces s−a−f; no fill produces −o.
  3. Weight the two mutually exclusive outcomes by their probabilities. Estimate a conditional on fill, rather than using the unconditional price drift.
Work it by hand

A=100, V=130 and q=50 produce a 30-unit fill. If p_f=.4, spread capture=1 tick, adverse loss=.7, fee=.1 and missed-opportunity cost=.02, expected value=.4(.2)−.6(.02)=.068 tick per attempted unit.

Apply it in a strategy

  • Document venue priority, data granularity and how unknown cancellations are allocated.
  • Replay fills under conservative, central and optimistic queue assumptions; flag conclusions that depend on optimism.
  • Estimate markouts at multiple horizons and stratify by latency, imbalance and inventory.

Research deliverable

Produce a fill/markout table with queue assumptions, unfilled attempts, partial fills and a break-even adverse-selection threshold.

Python implementation

Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.

def fifo_fill(ahead,own,aggressive):
    if min(ahead,own,aggressive)<0: raise ValueError("Nonnegative quantities required")
    return min(own,max(0,aggressive-ahead))

def quote_ev(fill_prob,spread,adverse,fee,missed=0):
    if not 0<=fill_prob<=1: raise ValueError("Invalid probability")
    return fill_prob*(spread-adverse-fee)-(1-fill_prob)*missed

print(fifo_fill(100,50,130),quote_ev(.4,1,.7,.1,.02))

Continue learning

High-Frequency Trading: Signals, Queues & Execution — all lessons
  1. HFT economics and the information-to-fill timeline
  2. Order-book features: imbalance, microprice and event flow
  3. Volume clocks, trade imbalance and VPIN
  4. Queue position, fill probabilities and adverse selection
  5. Inventory-aware quoting and economic edge development
  6. Event-driven backtesting and order lifecycle correctness
  7. HFT research promotion, drift and operating limits

Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations