How an exchange matches orders: price-time priority
Inside a matching engine: which order is filled first, what makers and takers are, and why partial fills happen.
Every centralised exchange has a matching engine: software that receives orders and decides which ones trade with each other. Most engines follow the same simple rule.
Price-time priority
- Best price first. The highest bid and the lowest ask have priority.
- Then first come, first served. Among orders at the same price, the earlier order is filled first.
This rule is fair and predictable: improving your price or arriving earlier gets you filled sooner.
What happens when an order arrives
- If a buy order's price is at or above the best ask, it trades immediately against waiting sell orders, starting from the cheapest. The incoming order is the taker; the waiting orders are makers.
- If it does not reach the best ask, it is added to the order book and waits. It becomes a maker when someone later trades against it.
Partial fills
If an incoming order is larger than the amount at the best price, it takes all of it and continues to the next price level (for a market order) or rests in the book with the remaining amount (for a limit order). One order can therefore produce several trades at different prices.
Market and limit orders inside the engine
- A market order keeps taking liquidity until it is completely filled or the book runs out.
- A limit order only trades at its price or better.
- Stop orders wait outside the book until their trigger price is reached, then enter as market or limit orders.
Why it matters to you
Understanding matching explains slippage, why limit orders may never fill, and why fees often differ for makers and takers. Read Reading an order book and Spread and slippage.
Blog posts are for education and information only and are not investment, legal or tax advice.
