Rs
Module 13Order BookLesson 1 of 718 min

Order Book Design

Bids/asks maps, ticks, and invariants.

Design

Bids: price→size sorted ascending keys; best bid = last key

Asks: best ask = first key

Invariant

best bid < best ask (no lock/cross in simple model)

Ticks

i64 cents avoid float keys.

Challenge

Sketch OrderId priority queues as a comment (pro systems).

Tips
  • Integer ticks
  • BBO from map ends
  • Real books need order IDs

Try it live

Order Book DesignRust 2021
Loading editor…
Output
Press Run to compile and execute.