pub trait BarAggregator: Any + Debug {
Show 14 methods
// Required methods
fn bar_type(&self) -> BarType;
fn is_running(&self) -> bool;
fn set_await_partial(&mut self, value: bool);
fn set_is_running(&mut self, value: bool);
fn update(&mut self, price: Price, size: Quantity, ts_event: 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);
fn await_partial(&self) -> bool;
fn set_partial(&mut self, partial_bar: Bar);
// 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 partial and batch updates.
Required Methods§
Sourcefn is_running(&self) -> bool
fn is_running(&self) -> bool
If the aggregator is running and will receive data from the message bus.
fn set_await_partial(&mut self, value: bool)
Sourcefn set_is_running(&mut self, value: bool)
fn set_is_running(&mut self, value: bool)
Enables or disables awaiting a partial bar before full aggregation.
Sourcefn update(&mut self, price: Price, size: Quantity, ts_event: UnixNanos)
fn update(&mut self, price: Price, size: Quantity, ts_event: UnixNanos)
Sets the running state of the aggregator (receiving updates when true
).
Updates the aggregator with the given price and size.
fn update_bar(&mut self, bar: Bar, volume: Quantity, ts_init: UnixNanos)
Sourcefn start_batch_update(
&mut self,
handler: Box<dyn FnMut(Bar)>,
time_ns: UnixNanos,
)
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.
Sourcefn stop_batch_update(&mut self)
fn stop_batch_update(&mut self)
Starts batch mode, sending bars to the supplied handler for the given time context.
Sourcefn await_partial(&self) -> bool
fn await_partial(&self) -> bool
Stops batch mode and restores the standard bar handler.
Sourcefn set_partial(&mut self, partial_bar: Bar)
fn set_partial(&mut self, partial_bar: Bar)
Returns true
if awaiting a partial bar before processing updates.
Sets the initial values for a partially completed bar.
Provided Methods§
Sourcefn handle_quote(&mut self, quote: QuoteTick)
fn handle_quote(&mut self, quote: QuoteTick)
Updates the aggregator with the given quote.
Sourcefn handle_trade(&mut self, trade: TradeTick)
fn handle_trade(&mut self, trade: TradeTick)
Updates the aggregator with the given trade.
Sourcefn handle_bar(&mut self, bar: Bar)
fn handle_bar(&mut self, bar: Bar)
Updates the aggregator with the given bar.