Quant Memo
Core

Price-Time Priority Matching Rules

Most exchanges decide who gets filled first with a simple rule — best price wins, and among orders at the same price, whoever arrived first gets filled first — and a backtest that doesn't enforce this rule as strictly as the real exchange does will overstate how often a strategy's resting orders actually get filled.

Prerequisites: Order Book Reconstruction from Message Feeds

If two traders both want to buy at the exact same price, who gets filled when a seller shows up? Most order-driven exchanges answer this with price-time priority: orders are ranked first by price (a higher bid or lower ask always wins over a worse one), and among orders tied at the same price, strictly by the order in which they arrived — first in, first filled. This is a deceptively simple rule with an outsized effect on backtest realism, because a resting order's fill probability depends heavily on how much size is queued ahead of it, and only a simulator that tracks time priority correctly can estimate that.

The rule, precisely

Given two resting buy orders, the one at the higher price always fills first regardless of when it arrived — price dominates time completely. Only when prices are equal does arrival time break the tie: an order that joined the queue at t=9:30:01t=9{:}30{:}01 has priority over one that joined at t=9:30:02t=9{:}30{:}02 at the same price, and stays ahead of it for as long as both remain resting. Critically, most exchanges treat a modification to an existing order (changing its size upward, or its price at all) as forfeiting time priority — the modified order goes to the back of the queue at its new terms, as if it were a fresh order, while a size decrease typically keeps priority since it can't disadvantage anyone else in the queue.

arrival order at the best bid → A (1st) B (2nd) C (3rd) incoming sell fills A first B resized → back of queue
At a single price level, orders queue strictly by arrival time; an incoming trade fills from the front. Increasing an order's size (right) forfeits its place, sending it to the back of the queue at its new terms.

Worked example: simulating a fill under time priority

A market-making strategy posts a bid of $50.00 for 500 shares when the queue at $50.00 already has 1,200 shares resting ahead of it from other participants. A sequence of incoming sell orders trades through the book: first 800 shares execute at $50.00, then another 900 shares. After the first 800 shares trade, only 800 of the 1,200 shares ahead have been consumed — the strategy's order still hasn't been touched at all. The second trade of 900 shares first clears the remaining 400 shares of queue still ahead, and the leftover 500 shares of that trade then fill the strategy's entire 500-share order. A simulator that ignored the 1,200 shares queued ahead and simply asked "did $50.00 trade at all" would have incorrectly filled the strategy's order on the very first trade — a full 900 shares and one extra trade too early.

What this means in practice

Any simulation of passive, resting orders needs to track queue position under price-time priority explicitly, not just whether a price level traded — otherwise fill rates and fill timing are both systematically too optimistic. This matters most for market-making and other liquidity-providing strategies, where the entire economics depends on realistic fill probability; a backtest that fills every resting order the instant its price trades is effectively assuming zero-latency, front-of-queue placement that no real participant gets.

Price-time priority ranks resting orders by price first, then strictly by arrival time among ties — and most exchanges reset an order's time priority whenever its size increases or its price changes. A simulator that fills resting orders the moment their price trades, without tracking how much size is queued ahead, will systematically overstate fill rates for passive strategies.

Don't assume a resized order keeps its queue position — increasing size (or moving price) typically sends an order to the back of the queue on real exchanges, and a simulator that doesn't model this will let strategies "cut the line" for free, inflating simulated fill rates versus what would actually happen live.

Related concepts

Practice in interviews

Further reading

  • Harris, Trading and Exchanges, ch. 15
ShareTwitterLinkedIn