Expand description
chronicle-core: a single-threaded, deterministic limit order book and matching engine with zero steady-state heap allocation.
The design contract is docs/ARCHITECTURE.md in the repository. The
short version:
- Orders live in a fixed-capacity struct-of-arrays arena and are
named only by
OrderId. Raw slot handles never leave this crate. - Prices sit on a bounded tick grid. Active levels are tracked by hierarchical bitmaps, so best bid and best ask cost a few word reads, independent of how many levels are live.
- An open-addressed table with backward-shift deletion maps
OrderIdto arena slots at a load factor of at most 50 percent. - Every mutating command validates and preflights before it mutates, so every rejection is atomic. Execution events are written into a caller-owned buffer; a buffer that is too small is a typed error returned before any state changes.
This crate is strictly std-only, forbids unsafe code, reads no clock,
and uses no process-seeded randomness. It is the deterministic core
that chronicle-wal persists and chronicle-cli drives.
Structs§
- Book
- A single-instrument limit order book on one tick grid.
- Book
Config - Static configuration for one
crate::Book. - Depth
Level - One aggregated price level in an L2 depth snapshot.
- Event
Buffer - Caller-owned, pre-allocated event sink for one or more commands.
- Level
State - One price level’s persisted state (ARCHITECTURE.md section 10.2, level arrays): list ends, aggregate quantity, and order count.
- Live
Order State - Structural state of one live order, as persisted in a snapshot (ARCHITECTURE.md section 10.2, live slot records).
- OrderId
- Caller-supplied order identifier. Zero is reserved as the empty
sentinel of the lookup table and is rejected as
crate::BookError::InvalidOrderId. - Participant
Id - Caller-supplied participant identifier. Zero is a valid participant.
- Snapshot
State - The complete structural state of a
crate::Book, captured for persistence bychronicle-wal(ARCHITECTURE.md section 10).
Enums§
- Book
Error - Errors returned by book construction and by every book command.
- Cancel
Reason - Why an order was cancelled.
- Execution
Event - One execution event. Every variant carries the
seqof the command that produced it. - Order
Type - Order type, with time in force folded in (ARCHITECTURE.md section 3.3). Every variant executes; the types differ only in the section 7.3 remainder rules.
- Side
- Which side of the book an order belongs to.
- StpPolicy
- Self-trade prevention policy, carried by the incoming order with a book-level default (ARCHITECTURE.md section 7.5).