Tech, ExplainedFintech
Product

Matching engine

Buyers and sellers paired in microseconds.

BEFORE ITAFTER ITMatching engineICECME GroupLSEG (London Stock Exchange Group)Tradelab TechnologiesCOVERSOrder bookPrice-timepriorityMicrosecondsMarket dataOrder management system(OMS) for brokerssendsclient ordersHigh-frequencytrading (HFT)sends buy andsell quotesAlgorithmic tradingsendssmall orderssends matchedtradesClearing and settlementpublishesnew pricesFinancial data terminal↗ ASSET MANAGEMENTCONCEPTS IT USESFutures and options (F&O)BEFORE ITAFTER ITMatching engineICECME GroupLSEG (London Stock Exchange Group)Tradelab TechnologiesCOVERSOrder bookPrice-timepriorityMicrosecondsMarket dataOrder managementsystem (OMS)for brokerssendsclient ordersHigh-frequencytrading (HFT)sends buy andsell quotesAlgorithmictradingsendssmall orderssends matchedtradesClearingand settlementpublishesnew pricesFinancialdata terminal↗ ASSET MANAGEMENTCONCEPTS IT USESFutures and options (F&O)BEFORE ITOrder management system(OMS) for brokers↓ sends client ordersHigh-frequency trading (HFT)↓ sends buy and sell quotesAlgorithmic trading↓ sends small ordersMatching engineICECME GroupLSEG (London Stock Exchange Group)Tradelab TechnologiesOrder bookPrice-time priorityMicrosecondsMarket dataAFTER IT↓ sends matched tradesClearing and settlement↓ publishes new pricesFinancial data terminal↗ ASSET MANAGEMENTCONCEPTS IT USESFutures and options (F&O)
The matching engine receives orders from brokers, algorithms and high-frequency traders, matches them by price and then by time, and sends each trade to clearing and each new price to data terminals.
opens a page inside this one a page in the same scene a page in another scene a concept page a label only, with no page

A matching engine is the software at the centre of a stock exchange that matches each order to buy with an order to sell. It is used for shares, futures and options. It keeps an order book: a list of every buy order and every sell order that is waiting, sorted by price.

The engine follows a strict rule called price-time priority. The best price is matched first. For a buyer, the best price is the lowest selling price on offer. If two orders have the same price, the one that arrived first is matched first.

Imagine the order book for one share. Three sell orders are waiting. The first is 200 shares at ₹500.10, entered at 10:01 a.m. The second is 300 shares at ₹500.10, entered at 10:03 a.m. The third is 500 shares at ₹500.20. Now a buy order arrives for 400 shares, at any price up to ₹500.15. The engine fills 200 shares from the first seller and 200 shares from the second seller, all at ₹500.10. The third order is too expensive for this buyer, so it is not touched. The remaining 100 shares of the second seller stay in the book. All of this takes a few microseconds.

Orders reach the engine from brokers' order management systems, from funds' execution algorithms and from high-frequency trading firms. These firms place their servers inside the exchange's own data centre, to save microseconds. This is called co-location.

The engine must be fast, but it must also be fair and exact. Every order passes through the same queue. The same orders in the same sequence must always produce exactly the same trades. A backup copy of the engine runs in parallel, so that it can take over immediately if the main one fails.

After each match, the engine does two more things. It sends the trade to clearing and settlement, where the trade is guaranteed and settled. It also publishes the new price to the market data feed. Within moments, that price appears on every financial data terminal. India's exchanges now handle more options contracts than any other market in the world, so their matching engines are among the busiest anywhere.

Tech, Explained is a part of ingrid.fyi. Every page explains one piece of technology in plain words.