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<SignedDuration>,
time_zone: TimeZone,
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<SignedDuration>, time_zone: TimeZone, bar_build_delay: u64, skip_first_non_full_bar: bool, ) -> Self
Creates a new TimeBarAggregator instance.
time_zone aligns day, week, month, and year boundaries to local civil time. Shorter
periods keep UTC alignment. time_bars_origin_offset shifts the nominal boundary;
bar_build_delay adds an elapsed delay in microseconds after each resolved boundary.
§Panics
Panics if bar_type.aggregation_source is not AggregationSource::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.
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
Source§fn set_is_running(&mut self, value: bool)
fn set_is_running(&mut self, value: bool)
true).Source§fn update(&mut self, price: Price, size: Quantity, ts_init: UnixNanos)
fn update(&mut self, price: Price, size: Quantity, ts_init: UnixNanos)
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)>, )
Source§fn set_historical_events(&mut self, events: Vec<TimeEvent>)
fn set_historical_events(&mut self, events: Vec<TimeEvent>)
TimeBarAggregator overrides)Source§fn set_clock(&mut self, clock: Rc<RefCell<dyn Clock>>)
fn set_clock(&mut self, clock: Rc<RefCell<dyn Clock>>)
TimeBarAggregator overrides)Source§fn build_bar(&mut self, event: &TimeEvent)
fn build_bar(&mut self, event: &TimeEvent)
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>>>)
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>>>>, )
TimeBarAggregator overrides.
Takes an optional Rc to create weak reference internally.Source§fn set_adjustment(
&mut self,
adjustment: Decimal,
mode: ContinuousFutureAdjustmentType,
)
fn set_adjustment( &mut self, adjustment: Decimal, mode: ContinuousFutureAdjustmentType, )
Source§fn set_build_with_no_updates(&mut self, value: bool)
fn set_build_with_no_updates(&mut self, value: bool)
TimeBarAggregator overrides.Source§fn is_historical(&self) -> bool
fn is_historical(&self) -> bool
false, TimeBarAggregator overrides.Source§fn handle_quote(&mut self, quote: QuoteTick)
fn handle_quote(&mut self, quote: QuoteTick)
Source§fn handle_trade(&mut self, trade: TradeTick)
fn handle_trade(&mut self, trade: TradeTick)
Source§fn handle_bar(&mut self, bar: Bar)
fn handle_bar(&mut self, bar: Bar)
Auto Trait Implementations§
impl !RefUnwindSafe for TimeBarAggregator
impl !Send for TimeBarAggregator
impl !Sync for TimeBarAggregator
impl !UnwindSafe for TimeBarAggregator
impl Freeze for TimeBarAggregator
impl Unpin for TimeBarAggregator
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
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> ⓘ
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