pub struct MarketDataBus { /* private fields */ }Expand description
Broadcast bus for streaming market data events between JANUS modules.
The Data module publishes MarketDataEvents (trades, klines, order book
updates, etc.) and the Forward module subscribes to receive them for
real-time indicator calculation and strategy evaluation.
This is the in-process equivalent of the SignalBus
but for raw/normalised market data rather than trading signals.
§Example
use janus_core::market::{MarketDataBus, MarketDataEvent};
let bus = MarketDataBus::new(5000);
let mut rx = bus.subscribe();
// Publisher (Data module)
// bus.publish(some_event).unwrap();
// Consumer (Forward module)
// let event = rx.recv().await.unwrap();Implementations§
Source§impl MarketDataBus
impl MarketDataBus
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new market data bus with the given channel capacity.
A larger capacity reduces the chance of slow subscribers missing events but consumes more memory. 5 000 is a reasonable default for multi-asset 1-minute candle + trade ingestion.
Sourcepub fn publish(&self, event: MarketDataEvent) -> Result<usize>
pub fn publish(&self, event: MarketDataEvent) -> Result<usize>
Publish a market data event to all subscribers.
Returns the number of active receivers that will see the event.
Sourcepub fn subscribe(&self) -> Receiver<MarketDataEvent>
pub fn subscribe(&self) -> Receiver<MarketDataEvent>
Subscribe to the market data stream.
Sourcepub fn subscriber_count(&self) -> usize
pub fn subscriber_count(&self) -> usize
Current number of active subscribers.