|
BetaTrader
A HFT Eco-System
|
The exchange_state module acts as the authoritative repository for all active order entities and global sequence generators within the exchange.
State is precarious in a high-frequency trading system. exchange_state provides the single source of truth for "active" orders and ensures that every new Order or Trade across the entire cluster (all partitions) receives a globally unique, monotonically increasing identifier.
OrderManager logic for tracking order existence.OrderIDs.TradeIDs.ClientOrderID (from FIX) and OrderID (internal).| Component | Description |
|---|---|
**OrderManager** | The memory store for live orders. Partition workers use this to find orders for cancellation or modification. |
**OrderIDGenerator** | Fast, in-memory atomic counter for rapid order assignment. |
**TradeIDGenerator** | Persistence-aware generator that ensures IDs never repeat even after a server crash. |
OrderManager within a partition is the exclusive owner of order memory. Moving orders between partitions is explicitly forbidden.OrderIDGenerator uses pure atomics, allowing it to be shared across partitions without causing contention.