Home / Wiki / O / Order Matching

Order Matching

Economics Markets and Financial TheoryUpdated 15 Nov 2026

Order matching is the process by which a trading venue pairs buy orders with sell orders to produce trades. It is carried out by a computer system called a matching engine, which applies a fixed set of rules to decide which orders trade, at what price and in what sequence. The rules are published by the venue and applied identically to every participant.

Matching rules shape how traders behave. They determine what an order must do to be filled first, and so they influence how prices are quoted, how much speed matters and how large orders are handled. Most stock and futures exchanges match orders continuously in a central limit order book, supplemented by auctions at particular times of day.

01

Continuous matching

In continuous trading, the venue keeps an order book of unfilled limit orders: bids to buy, ranked from the highest price down, and offers to sell, ranked from the lowest price up. When a new order arrives, the engine checks whether it can trade with the best order on the opposite side. A buy order can trade if its price is at or above the lowest offer, and a sell order can trade if its price is at or below the highest bid. A market order accepts any price and always qualifies.

If the incoming order can trade, it is matched against resting orders, starting with the best price and working outward until it is filled or no more orders qualify. The trade takes place at the price of the resting order, not the incoming one. Any unfilled remainder of a limit order is added to the book, where it waits for a later arrival. Price always comes first: a better-priced resting order is filled before a worse-priced one. The matching algorithm decides what happens among orders at the same price.

02

Matching algorithms

  • Price-time priority. Among orders at the same price, the one entered earliest is filled first, a rule of first in, first out. It is the standard on equity exchanges and most futures markets. It rewards being first in the queue, which is one source of the demand for low latency.
  • Pro rata. An incoming order is shared among all resting orders at the best price in proportion to their size. It is used in some interest rate futures and options markets. It rewards size over speed and encourages traders to post more quantity than they want.
  • Hybrid rules. Many venues mix the two, for example by giving a share to the first order at a new price or to designated market makers, and allocating the rest pro rata or by time.

Venues add further conditions. Displayed quantity normally ranks ahead of hidden quantity at the same price, so the reserve of an iceberg order waits behind visible orders. Self-trade prevention stops a firm's buy order from matching its own sell order.

03

Worked example

Suppose the offers in a book are 100 shares at 50.10 from trader A, entered first; 200 shares at 50.10 from trader B, entered later; and 300 shares at 50.12 from trader C. A market order to buy 400 shares arrives. Under price-time priority it takes 100 from A and 200 from B at 50.10, then the remaining 100 from C at 50.12. The buyer's average price is:

300×50.10+100×50.12400=50.105\frac{300 \times 50.10 + 100 \times 50.12}{400} = 50.105

Now suppose instead that the incoming order is for 150 shares. Under price-time priority, A is filled for 100 and B for 50. Under a pure pro rata rule, the 150 shares are divided in proportion to the resting sizes of 100 and 200, so A receives 50 and B receives 100.

04

Auctions

Continuous matching is not used at all times. At the start and end of the day, and after a halt, many exchanges run a call auction. Orders are collected over a period without trading, and the engine then calculates the single price at which the greatest quantity can be exchanged and executes all eligible orders at that price. The opening auction and the closing auction concentrate liquidity and produce reference prices that are harder to distort than a single trade. Some venues run a short batch auction at frequent intervals throughout the day in place of, or alongside, continuous trading.

05

Other models

Not all markets match orders in a central book. In dealer markets, such as much of foreign exchange and bond trading, a customer asks one or more dealers for a price and trades bilaterally. Dark pools match orders without displaying them, often at the midpoint of the public bid and offer. An electronic communication network operates an order book outside a traditional exchange. In decentralised finance, automated market makers replace matching altogether with a pricing formula applied to a pool of assets.

06

Performance and fairness

A matching engine must process orders in a strict, reproducible sequence, since under time priority the order of arrival determines who trades. Engines at major exchanges handle very large numbers of messages each second with processing times measured in microseconds, and their capacity is described in terms such as orders per second. Exchanges go to some lengths to treat participants equally, for example by equalising cable lengths within the data centre. Regulators require venues to publish their matching rules, to apply them without discrimination and to maintain controls, such as price bands and trading halts, that stop the engine from executing trades at clearly erroneous prices.

Last updated 15 Nov 2026