Matching Engine · price-time priority

Bid
Ask
Spread
Last

How it worksBehind the demo

01

Price-time priority

Orders queue at each price level in the order they arrived. Best price trades first; ties go to whoever got there first. Real exchanges match the same way.

02

O(1) cancels

A hash map points from order id straight to the order's node in the book, so a cancel unlinks it immediately. No scanning.

03

Partial fills

A big order eats through the opposing side level by level. Anything left over rests in the book as the new best quote.

Order Book click to fill the ticket
Spread Last
New Order
Trade Tape
No executions yet
Order Flow Simulator
Generates resting limits, aggressive markets, and cancels around the mid so the book stays alive. Everything you see is the engine matching in real time.
Design · ordered price levels + FIFO queues + id→order map · O(1) best quote, O(1) cancel, O(log P) to find a price level. Levels live in a sorted array here, so opening or closing one also shifts it; the Python and C++ engines use an ordered map.
Trades print at the resting order's price, so price improvement accrues to the aggressor. Client-side port of the Python engine.
Symbol prices are illustrative starting seeds, not a live quote feed. The simulator drives movement from there.