Skip to content
Preptima
hardCodingDesignSeniorStaff

How would you design an order book, and what makes it hard?

7 min readUpdated 2026-08-15

Answer

Short answer

An order book is price levels in price order, each holding a time-ordered queue of orders, plus an ID index so a cancel is O(1); the hard parts are that cancels dominate the flow, the feed must be gap-checked and recoverable, and replay must be deterministic and allocation-free.

Was this answer helpful?

Likely follow-ups

  • How do you recover a book mid-session from a snapshot while increments are still arriving?
  • What changes if the venue allocates pro-rata within a price level instead of first-in-first-out?
  • How would you test that your book is correct, given that the venue is the only source of truth?
  • Where does self-match prevention belong, and what does it do to time priority?
  • How do you shard a book across cores without losing per-instrument determinism?

Related questions

Masterclass guide

Further reading