Skip to main content

Crate chronicle_core

Crate chronicle_core 

Source
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 OrderId to 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.
BookConfig
Static configuration for one crate::Book.
DepthLevel
One aggregated price level in an L2 depth snapshot.
EventBuffer
Caller-owned, pre-allocated event sink for one or more commands.
LevelState
One price level’s persisted state (ARCHITECTURE.md section 10.2, level arrays): list ends, aggregate quantity, and order count.
LiveOrderState
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.
ParticipantId
Caller-supplied participant identifier. Zero is a valid participant.
SnapshotState
The complete structural state of a crate::Book, captured for persistence by chronicle-wal (ARCHITECTURE.md section 10).

Enums§

BookError
Errors returned by book construction and by every book command.
CancelReason
Why an order was cancelled.
ExecutionEvent
One execution event. Every variant carries the seq of the command that produced it.
OrderType
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).