BarAggregator

Trait BarAggregator 

Source
pub trait BarAggregator: Any + Debug {
    // Required methods
    fn bar_type(&self) -> BarType;
    fn is_running(&self) -> bool;
    fn set_is_running(&mut self, value: bool);
    fn update(&mut self, price: Price, size: Quantity, ts_init: UnixNanos);
    fn update_bar(&mut self, bar: Bar, volume: Quantity, ts_init: UnixNanos);
    fn start_batch_update(
        &mut self,
        handler: Box<dyn FnMut(Bar)>,
        time_ns: UnixNanos,
    );
    fn stop_batch_update(&mut self);

    // Provided methods
    fn handle_quote(&mut self, quote: QuoteTick) { ... }
    fn handle_trade(&mut self, trade: TradeTick) { ... }
    fn handle_bar(&mut self, bar: Bar) { ... }
    fn stop(&mut self) { ... }
}
Expand description

Trait for aggregating incoming price and trade events into time-, tick-, volume-, or value-based bars.

Implementors receive updates and produce completed bars via handlers, with support for batch updates.

Required Methods§

Source

fn bar_type(&self) -> BarType

The BarType to be aggregated.

Source

fn is_running(&self) -> bool

If the aggregator is running and will receive data from the message bus.

Source

fn set_is_running(&mut self, value: bool)

Sets the running state of the aggregator (receiving updates when true).

Source

fn update(&mut self, price: Price, size: Quantity, ts_init: UnixNanos)

Updates the aggregator with the given price and size.

Source

fn update_bar(&mut self, bar: Bar, volume: Quantity, ts_init: UnixNanos)

Source

fn start_batch_update( &mut self, handler: Box<dyn FnMut(Bar)>, time_ns: UnixNanos, )

Incorporates an existing bar and its volume into aggregation at the given init timestamp.

Source

fn stop_batch_update(&mut self)

Starts batch mode, sending bars to the supplied handler for the given time context.

Provided Methods§

Source

fn handle_quote(&mut self, quote: QuoteTick)

Updates the aggregator with the given quote.

Source

fn handle_trade(&mut self, trade: TradeTick)

Updates the aggregator with the given trade.

Source

fn handle_bar(&mut self, bar: Bar)

Updates the aggregator with the given bar.

Source

fn stop(&mut self)

Stops batch mode and restores the standard bar handler. Stop the aggregator, e.g., cancel timers. Default is no-op.

Implementations§

Source§

impl dyn BarAggregator

Source

pub fn as_any(&self) -> &dyn Any

Returns a reference to this aggregator as Any for downcasting.

Source

pub fn as_any_mut(&mut self) -> &mut dyn Any

Returns a mutable reference to this aggregator as Any for downcasting.

Implementors§

Source§

impl<H> BarAggregator for RenkoBarAggregator<H>
where H: FnMut(Bar) + 'static,

Source§

impl<H> BarAggregator for TickBarAggregator<H>
where H: FnMut(Bar) + 'static,

Source§

impl<H> BarAggregator for TimeBarAggregator<H>
where H: FnMut(Bar) + 'static,

Source§

impl<H> BarAggregator for ValueBarAggregator<H>
where H: FnMut(Bar) + 'static,

Source§

impl<H> BarAggregator for VolumeBarAggregator<H>
where H: FnMut(Bar) + 'static,