Skip to content

Matching engine: order priority and allocation

A matching engine applies a venue's rules to match compatible orders and allocate fills. Price-time priority is common but not universal: FIFO, pro-rata and hybrid algorithms also exist.

Who this is for — Anyone who wants to understand why two orders at the same price can receive different fills and why behaviour changes across products or venues.

A matching engine is the system within an electronic venue that matches compatible buying and selling interest according to the market's rulebook. It determines which orders can cross, the sequence in which quantity is allocated and which executions are reported to participants. It does not forecast price or discretionarily select the “best trade”: it applies rules and parameters defined by the venue.

In plain terms — Price determines which orders are compatible; the algorithm determines who receives the available quantity. “First come, first served” is only one of the possible methods.

The engine must be distinguished from the broker. The intermediary receives the client's order, performs checks and decides how to route it according to the instructions and obligations that apply. It may send the order to an exchange, market maker, ECN or ATS, or internalise it. The matching engine instead operates within the boundaries of a single venue or execution system. Investor.gov notes that the route, timing and place of execution affect the final result.


Essential sequence

A typical pipeline includes:

  1. receiving and validating the message: instrument, side, quantity, price, permissions and risk controls;
  2. sequencing accepted events, including new orders, amendments and cancellations;
  3. checking for a cross between the aggressive order and opposing interest;
  4. price priority, where applicable: a buy meets the lowest asks and a sale meets the highest bids;
  5. allocating quantity among eligible orders at the same price;
  6. reporting the trade and updating the order book, remaining quantities and order states.

Some functions may be distributed among gateways, a risk engine and the central matching engine. Technical architecture varies; what matters to a trader is the published rulebook, not the name of a software component.


Price-time, pro-rata and hybrid algorithms

Price-time priority, often called FIFO within the same price level, allocates quantity to the oldest order first. It is common, but not universal. CME Group documents FIFO, FIFO with dedicated priorities, pro-rata, threshold pro-rata, configurable and hybrid algorithms for its markets. Different products on the same infrastructure may use different algorithms.

With three resting orders at the same price — A for 50 contracts, B for 30 and C for 20 — an aggressive order for 40 produces different outcomes:

Simplified algorithm Possible allocation
FIFO, A is oldest A receives 40; B and C receive zero
Pure pro-rata A 20, B 12, C 8
Hybrid one portion follows FIFO and the remainder is allocated pro-rata

Actual algorithms may add rounding, minimum allocations, top-order priority, lead-market-maker priority or residual-allocation rules. The example illustrates the principle; it does not reproduce a product specification. To explain why an order received a fill, the contract, session and algorithm in force must be identified.

Article 28 of MiFID II requires European investment firms to handle otherwise comparable client orders according to the time they are received and through rapid, fair and expeditious procedures. This requirement concerns the firm's handling of client orders; it does not prove that every venue must allocate fills through a price-time algorithm. Confusing these two levels leads to incorrect generalisations.


How order types enter the process

Type Relationship with the matching engine
if accepted, seeks available opposing interest; it may receive multiple fills, a partial fill or no fill
may attack the book within its limit or rest; queue position depends on the algorithm
may be held by the broker or venue; before the trigger it is not necessarily present in the executable book

A large market order does not authorise the engine to invent counterparties. It consumes available liquidity while rules, protections and quantity permit. A limit order is not necessarily passive: if it crosses the opposite price, it may execute immediately. A stop adds an earlier stage because the system must first determine whether the activation condition has been met.


Elements that change the outcome

Beyond its base algorithm, a venue may provide opening or closing auctions, iceberg or reserve orders, implied quantities, self-trade prevention, price bands, message limits and pre-trade controls. Some rules determine whether priority is lost or retained after an amendment. Increasing quantity or changing price, for example, may assign a new timestamp; there is no single rule valid for every market.

A market maker is a participant or intermediary that quotes prices and supplies liquidity under its own obligations and incentives. The matching engine is the infrastructure that applies rules to admitted interest, including market-maker orders. The two roles are not interchangeable.

Analysing an execution requires at least the order state, timestamps, the price and quantity of every fill, venue, product algorithm, time in force and amendment rules. A candlestick chart alone cannot reconstruct queue position or the amount of quantity ahead of an order.

Common mistake — Attributing every missed fill to a broker problem without checking priority, algorithm, quantity ahead in the queue and venue rules.


Sources