Design a Stock Exchange Order Book

Hard · Low-Level Design · about 50 minutes

Asked at Coinbase, Robinhood, Bloomberg, Block (Square), Goldman Sachs, Citadel, Jane Street, Hudson River Trading, Plaid, Ramp, Revolut, D. E. Shaw, Optiver, Rippling, Brex, Mercury, Kraken, Jump Trading, Susquehanna (SIG).

Design the order book and matching engine for one trading symbol. Traders submit limit orders (buy or sell, price, quantity) and market orders, and can cancel resting orders. Incoming orders match against the best opposite price first and, at the same price, the oldest order first. Report each trade.

Related guides