How do exchange order matching engines prioritise trades?
An exchange order matching engine prioritises trades by price first, then by time, and sometimes by other rules such as order size or visibility. A market order will generally trade ahead of any resting limit order at the same price, because a market order is treated as the most aggressive price level available. The engine’s job is to pair buyers and sellers as quickly as possible while following a strict set of rules, and those rules determine whose order fills first when multiple orders compete.
The core priority: price
The matching engine’s first rule is simple: the best price wins. A buy order at a higher price beats a buy order at a lower price. A sell order at a lower price beats a sell order at a higher price. This is true regardless of when the orders were placed.
So if you place a limit buy at $10.00 and someone else has a limit buy at $10.05, the $10.05 order sits ahead of yours in the queue. If a seller accepts $10.05, that order fills first. Your $10.00 order only gets a chance if the price drops back to your level.
For sell orders, the logic is reversed. The lowest ask wins. A sell at $10.00 beats a sell at $10.02. The engine always matches the highest bid with the lowest ask.
Time priority: the tie-breaker
When two orders sit at the same price, the engine uses time to decide who goes first. The order that arrived earlier gets priority. This is often called a "first in, first out" or FIFO system.
Here is how it works in practice:
- A limit buy order for 100 shares at $10.00 arrives at 09:30:01.
- A second limit buy order for 100 shares at $10.00 arrives at 09:30:05.
- A seller hits the bid with a market order to sell 150 shares at $10.00.
- The first order fills completely (100 shares). The remaining 50 shares go to the second order.
Time priority rewards patience. If you cancel and resubmit the same order, you lose your place in the queue. This is why some traders use hidden or iceberg orders - to avoid revealing their full size and to keep a favourable time priority position.
Market orders: the aggressive side
A market order is always treated as aggressive. It does not rest on the book; it immediately consumes the best available opposite orders. In terms of priority, a market order effectively jumps to the front of the queue because it is willing to take whatever price is available.
For example, if the best ask is $10.00 and you send a market buy, you fill at $10.00. You do not wait in line behind other buyers at $10.00 because you are not resting at a limit price. You are taking the ask. The matching engine gives your order top priority because you are crossing the spread.
This is also why market orders can cause slippage. If there is not enough volume at the best ask, your order will eat into the next available prices, filling at progressively worse levels.
Stop orders: triggered, then prioritised
A stop order does not participate in matching until it is triggered. Once the stop price is reached, the order converts into a market order or a limit order, depending on the type. At that moment, it is treated like any other newly arrived order.
This is a critical point. A stop order does not have time priority until it becomes active. When a stop triggers, it is placed at the back of the queue at that price level. If many stops trigger at once - often the case during a sharp move - the queue is flooded, and later-triggered orders may fill at worse prices.
Consider a stop sell at $9.95. The market drops to $9.95. Your stop becomes a market sell. But if there are already many sell orders resting at $9.95 from earlier, your order sits behind them. If the market moves down quickly, your order may fill at $9.90 or lower.
Size and Hidden Orders: Exceptions to the Rules
Most matching engines use price-time priority, but some include a size component. A large order at the same price may get priority over a smaller one if the exchange uses a pro-rata model. In a pro-rata system, orders are filled proportionally to their size. This is more common on futures exchanges than on stock exchanges.
Hidden orders and iceberg orders complicate time priority. An iceberg order shows only a small portion of its total size to the market. The visible part sits in the queue like any other order. When that visible part fills, the next slice becomes visible and is placed at the back of the queue. The hidden portion does not get time priority while it is invisible.
This means a large iceberg order may not fill as quickly as its total size suggests, because each visible slice must work through the queue anew.
What happens during high volatility
Volatility changes how priority works in practice. When prices move fast, the queue at a given price can empty quickly. Market orders sweep through multiple price levels, and limit orders may be cancelled or re-priced rapidly.
In these conditions, time priority can become less meaningful. An order resting at $10.00 may get filled when the market briefly trades through that price, but if the move is violent, the engine may execute several trades at different prices in quick succession. The key is that the matching engine still follows the same rules - price first, then time - but the speed and volume of orders can make the outcome feel less predictable.
A note on exchange-specific rules
Different exchanges may tweak these rules. Some use a "maker-taker" fee model that rewards orders that add liquidity, but this does not change matching priority. Others may use price-time priority with a randomisation element to discourage gaming. A few exchanges prioritise larger orders even at worse prices, though this is rare.
Before trading on any venue, read its order matching documentation. The general principles above hold for most major exchanges, but the details matter. A few seconds of reading can save you from a fill you did not expect.
Not financial advice. munchcoin.xyz publishes market data and general information about digital assets. Crypto assets are volatile and you can lose everything you put in. Nothing here is a recommendation to buy, sell or hold, and we make no price predictions.
Prices are sourced from third parties and may be delayed or wrong. Verify anything you intend to act on against a primary source.