Telemetry
StockMarketABM.MarketTelemetryMod manages rolling market snapshots. It keeps current best bid/ask, midprice, and last trade data in memory, maintains bounded buffers for recent ticks and configurable OHLCV bars, and exposes an on-demand API for retrieving the current top-of-book depth. Helper utilities are provided for batching tick/bar buffers to persistent storage when needed. StockMarketABM.OrderFlowMod complements this with an order-flow log that records every add, cancel, trade, and expiry event and offers a flush queue for archival.
StockMarketABM.MarketTelemetryMod.default_telemetry_config — Methoddefault_telemetry_config() -> TelemetryConfigReturn the default telemetry configuration (top 5 depth levels, sampling every 10 ticks, windows sized for 500 depth snapshots, 1 000 ticks, and bars of 10 000 time units).
StockMarketABM.MarketTelemetryMod.get_depth_levels — Methodget_depth_levels(market, instrument; levels=nothing) -> NamedTupleCollect the current depth snapshot up to levels price levels per side. When levels === nothing, the depth level configured in TelemetryConfig is used. Returns a named tuple (bids, asks) with vectors of (price, qty) pairs.
StockMarketABM.MarketTelemetryMod.initialize_telemetry! — Methodinitialize_telemetry!(market; configs, now)Attach telemetry state for every instrument in market. Optional configs override the default TelemetryConfig, and now sets the starting timestamp for bar aggregation.
StockMarketABM.MarketTelemetryMod.pop_bar_flush_batch! — Methodpop_bar_flush_batch!(market) -> Vector{BarRecord}Return and clear the batch of OHLCV bars that exceeded the in-memory window.
StockMarketABM.MarketTelemetryMod.pop_tick_flush_batch! — Methodpop_tick_flush_batch!(market) -> Vector{TickRecord}Return and clear tick snapshots that fell out of the ring buffer.
StockMarketABM.MarketTelemetryMod.prepare_tick! — Methodprepare_tick!(market, instrument, now)Roll bar intervals as needed before processing an event at now.
StockMarketABM.MarketTelemetryMod.record_trade! — Methodrecord_trade!(market, instrument, price, qty, now)Update last trade details and fold the execution into the current OHLCV bar.
StockMarketABM.MarketTelemetryMod.register_instrument_telemetry! — Methodregister_instrument_telemetry!(market, instrument, cfg; now)Create telemetry buffers for a newly listed instrument.
StockMarketABM.MarketTelemetryMod.update_book_metrics! — Methodupdate_book_metrics!(market, instrument, now)Refresh best bid/ask/mid snapshots and append to the tick history. Also samples depth when the configured cadence elapses.