Docs / Concepts / Foundations
RealArchitecture
The kernel, its components, and the order things happen in.
Kernel
One engine owns the clock, cache, message bus, risk checks, the venue and the strategies. Strategy commands and order events go through one first-in, first-out work queue, so a handler that reacts to an event can never reorder events already queued.
Per market data item
- Check the item's time is not before the previous item.
- Advance the clock; for each timer due, handle venue arrivals up to that time, then call the owning strategy's
on_timer. - Handle venue arrivals up to the item's time.
- Close any subscribed bars whose period has ended and deliver
on_bar. - Write the item to the cache and publish it on the bus; for a quote, the venue matches resting orders and held stops are checked.
- Call every strategy's
on_quote,on_tradeoron_bar. - After a quote, sample equity.
Why single-threaded
One ordered event loop is what makes a run repeatable. Speed is meant to come from compiled code, not from shared-state concurrency.
Components
- Message bus: typed topics, in-order delivery, delivery log
- Cache: instruments and market data, every write validated
- Risk checks: every order checked before a venue sees it
- Orders and Execution: order lifecycle
- Positions and portfolio: positions and profit and loss from fills