Order Book

The order_book module in market_model provides infrastructure for generating synthetic limit order book data.

Current status

The module exists with traits and placeholder implementations, but full L1/L2/L3 generation is not yet implemented. The planned architecture is described below.

Planned architecture

Three composable layers:

graph LR
    P[PriceProcess] --> OBS[OrderBookSimulator]
    OF[OrderFlowProcess] --> OBS
    OB[OrderBook depth] --> OBS
    OBS --> Runner[SimulationRunner]

OrderBookSimulator implements Simulatable with Output = BookSnapshot, which contains the full book state at each simulation step.

PriceProcess

The true mid-price driver. Any existing Simulatable process (GBM, Heston, etc.) serves as the price process.

OrderFlowProcess

Generates limit orders, market orders, and cancellations each step. Planned implementations:

  • Poisson: constant arrival rates.
  • Bilateral Hawkes: self-exciting intensities for bid and ask sides.
  • NoFlow: no arrivals, just BBO at mid +/- half-spread.

OrderBook depth

Controls the fidelity of the generated book:

LevelStateMatching
L1Best bid, best ask, sizeInstant fill at BBO
L2Aggregate volume per tickMarket orders sweep levels
L3FIFO queue per tickPrice-time priority

What is currently available

  • OrderFlowProcess trait and NoFlow implementation.
  • OrderBook struct stub.
  • The module structure is in place for future implementation.