Limit Order Book Demo
> live demo · C++ matching engine, ported to the browser

Limit Order Book

Place buy and sell orders and watch them match by price-time priority, the same rules real exchanges use. This page runs a JavaScript port of the C++ engine, with the same order types and matching logic. Click a price in the book to fill in the ticket, or turn on simulated traders.

best bid–
best ask–
spread–
last trade–
orders / trades0 / 0

order ticket

Simulated traders add, cancel and cross orders around a drifting price.

order book top 8 levels

pricesizeorders
spread –mid –

trades

No trades yet. Send an order that crosses the spread.

your resting orders

idsidepriceremainingqueue position

Price-time priority

The best price fills first. At the same price, whoever arrived first fills first, so each level is a FIFO queue.

O(1) cancels

Every order id maps straight to its spot in its queue, so a cancel never scans the book. Price levels sit in a sorted map with the best price first.

Integer ticks

Prices are stored in cents, not floats, so 100.10 + 0.20 is exactly 100.30. Trades print at the resting order's price.