pub struct TimeBarAggregator {
pub historical_mode: bool,
/* private fields */
}Expand description
Provides a means of building time bars aggregated from quote and trades.
At each aggregation time interval, a bar is created and sent to the handler.
Fields§
§historical_mode: boolImplementations§
Source§impl TimeBarAggregator
impl TimeBarAggregator
Sourcepub fn new<H: FnMut(Bar) + 'static>(
bar_type: BarType,
price_precision: u8,
size_precision: u8,
clock: Rc<RefCell<dyn Clock>>,
handler: H,
build_with_no_updates: bool,
timestamp_on_close: bool,
interval_type: BarIntervalType,
time_bars_origin_offset: Option<TimeDelta>,
bar_build_delay: u64,
skip_first_non_full_bar: bool,
) -> Self
pub fn new<H: FnMut(Bar) + 'static>( bar_type: BarType, price_precision: u8, size_precision: u8, clock: Rc<RefCell<dyn Clock>>, handler: H, build_with_no_updates: bool, timestamp_on_close: bool, interval_type: BarIntervalType, time_bars_origin_offset: Option<TimeDelta>, bar_build_delay: u64, skip_first_non_full_bar: bool, ) -> Self
Creates a new TimeBarAggregator instance.
§Panics
This function panics if:
instrument.idis not equal to thebar_type.instrument_id.bar_type.aggregation_sourceis not equal toAggregationSource::Internal.
Sourcepub fn set_clock_internal(&mut self, clock: Rc<RefCell<dyn Clock>>)
pub fn set_clock_internal(&mut self, clock: Rc<RefCell<dyn Clock>>)
Sets the clock for the aggregator (internal method).
Sourcepub fn start_timer_internal(
&mut self,
aggregator_rc: Option<Rc<RefCell<Box<dyn BarAggregator>>>>,
)
pub fn start_timer_internal( &mut self, aggregator_rc: Option<Rc<RefCell<Box<dyn BarAggregator>>>>, )
Starts the time bar aggregator, scheduling periodic bar builds on the clock.
This matches the Cython start_timer() method exactly.
Creates a callback to build_bar using a weak reference to the aggregator.
§Panics
Panics if aggregator_rc is None and aggregator_weak hasn’t been set, or if timer registration fails.
Sourcepub fn set_historical_events_internal(&mut self, events: Vec<TimeEvent>)
pub fn set_historical_events_internal(&mut self, events: Vec<TimeEvent>)
Sets historical events (called by data engine after advancing clock)
Trait Implementations§
Source§impl BarAggregator for TimeBarAggregator
impl BarAggregator for TimeBarAggregator
Source§fn is_running(&self) -> bool
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)
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)
fn update(&mut self, price: Price, size: Quantity, ts_init: UnixNanos)
Updates the aggregator with the given price and size.
fn update_bar(&mut self, bar: Bar, volume: Quantity, ts_init: UnixNanos)
Source§fn set_historical_mode(
&mut self,
historical_mode: bool,
handler: Box<dyn FnMut(Bar)>,
)
fn set_historical_mode( &mut self, historical_mode: bool, handler: Box<dyn FnMut(Bar)>, )
Sets historical mode (default implementation does nothing, TimeBarAggregator overrides)
Source§fn set_historical_events(&mut self, events: Vec<TimeEvent>)
fn set_historical_events(&mut self, events: Vec<TimeEvent>)
Sets historical events (default implementation does nothing, TimeBarAggregator overrides)
Source§fn set_clock(&mut self, clock: Rc<RefCell<dyn Clock>>)
fn set_clock(&mut self, clock: Rc<RefCell<dyn Clock>>)
Sets clock for time bar aggregators (default implementation does nothing, TimeBarAggregator overrides)
Source§fn build_bar(&mut self, event: TimeEvent)
fn build_bar(&mut self, event: TimeEvent)
Builds a bar from a time event (default implementation does nothing, TimeBarAggregator overrides)
Source§fn set_aggregator_weak(&mut self, weak: Weak<RefCell<Box<dyn BarAggregator>>>)
fn set_aggregator_weak(&mut self, weak: Weak<RefCell<Box<dyn BarAggregator>>>)
Sets the weak reference to the aggregator wrapper (for historical mode).
Default implementation does nothing, TimeBarAggregator overrides.
Source§fn start_timer(
&mut self,
aggregator_rc: Option<Rc<RefCell<Box<dyn BarAggregator>>>>,
)
fn start_timer( &mut self, aggregator_rc: Option<Rc<RefCell<Box<dyn BarAggregator>>>>, )
Starts the timer for time bar aggregators.
Default implementation does nothing, TimeBarAggregator overrides.
Takes an optional Rc to create weak reference internally.
Source§fn handle_quote(&mut self, quote: QuoteTick)
fn handle_quote(&mut self, quote: QuoteTick)
Updates the aggregator with the given quote.
Source§fn handle_trade(&mut self, trade: TradeTick)
fn handle_trade(&mut self, trade: TradeTick)
Updates the aggregator with the given trade.
Source§fn handle_bar(&mut self, bar: Bar)
fn handle_bar(&mut self, bar: Bar)
Updates the aggregator with the given bar.
Auto Trait Implementations§
impl Freeze for TimeBarAggregator
impl !RefUnwindSafe for TimeBarAggregator
impl !Send for TimeBarAggregator
impl !Sync for TimeBarAggregator
impl Unpin for TimeBarAggregator
impl !UnwindSafe for TimeBarAggregator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more