pub struct TimeBarAggregator<H>where
H: FnMut(Bar),{ /* 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.
Implementations§
Source§impl<H> TimeBarAggregator<H>where
H: FnMut(Bar) + 'static,
impl<H> TimeBarAggregator<H>where
H: FnMut(Bar) + 'static,
Sourcepub fn new(
bar_type: BarType,
price_precision: u8,
size_precision: u8,
clock: Rc<RefCell<dyn Clock>>,
handler: H,
await_partial: bool,
build_with_no_updates: bool,
timestamp_on_close: bool,
interval_type: BarIntervalType,
time_bars_origin: Option<DateTime<Utc>>,
composite_bar_build_delay: i32,
) -> Self
pub fn new( bar_type: BarType, price_precision: u8, size_precision: u8, clock: Rc<RefCell<dyn Clock>>, handler: H, await_partial: bool, build_with_no_updates: bool, timestamp_on_close: bool, interval_type: BarIntervalType, time_bars_origin: Option<DateTime<Utc>>, composite_bar_build_delay: i32, ) -> Self
Creates a new TimeBarAggregator
instance.
§Panics
This function panics:
- If
instrument.id
is not equal to thebar_type.instrument_id
. - If
bar_type.aggregation_source
is not equal toAggregationSource::Internal
.
Sourcepub fn start(&mut self, callback: NewBarCallback<H>) -> Result<()>
pub fn start(&mut self, callback: NewBarCallback<H>) -> Result<()>
Starts the time bar aggregator.
pub fn start_batch_time(&mut self, time_ns: UnixNanos)
Trait Implementations§
Source§impl<H> BarAggregator for TimeBarAggregator<H>where
H: FnMut(Bar) + 'static,
impl<H> BarAggregator for TimeBarAggregator<H>where
H: FnMut(Bar) + 'static,
Source§fn 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)
fn set_is_running(&mut self, value: bool)
Source§fn update(&mut self, price: Price, size: Quantity, ts_event: UnixNanos)
fn update(&mut self, price: Price, size: Quantity, ts_event: UnixNanos)
Updates theaggregator with the given price and size.
fn update_bar(&mut self, bar: Bar, volume: Quantity, ts_init: UnixNanos)
fn start_batch_update(&mut self, handler: Box<dyn FnMut(Bar)>)
fn stop_batch_update(&mut self)
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.
fn handle_bar(&mut self, bar: Bar)
Auto Trait Implementations§
impl<H> Freeze for TimeBarAggregator<H>where
H: Freeze,
impl<H> !RefUnwindSafe for TimeBarAggregator<H>
impl<H> !Send for TimeBarAggregator<H>
impl<H> !Sync for TimeBarAggregator<H>
impl<H> Unpin for TimeBarAggregator<H>where
H: Unpin,
impl<H> !UnwindSafe for TimeBarAggregator<H>
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