pub struct TickBarAggregator<H>where
H: FnMut(Bar),{ /* private fields */ }
Expand description
Provides a means of building tick bars aggregated from quote and trades.
When received tick count reaches the step threshold of the bar specification, then a bar is created and sent to the handler.
Implementations§
Source§impl<H> TickBarAggregator<H>where
H: FnMut(Bar),
impl<H> TickBarAggregator<H>where
H: FnMut(Bar),
Sourcepub fn new(
bar_type: BarType,
price_precision: u8,
size_precision: u8,
handler: H,
await_partial: bool,
) -> Self
pub fn new( bar_type: BarType, price_precision: u8, size_precision: u8, handler: H, await_partial: bool, ) -> Self
Creates a new TickBarAggregator
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
.
Trait Implementations§
Source§impl<H> BarAggregator for TickBarAggregator<H>where
H: FnMut(Bar),
impl<H> BarAggregator for TickBarAggregator<H>where
H: FnMut(Bar),
Source§fn update(&mut self, price: Price, size: Quantity, ts_event: UnixNanos)
fn update(&mut self, price: Price, size: Quantity, ts_event: UnixNanos)
Apply the given update to the aggregator.
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)
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 TickBarAggregator<H>where
H: Freeze,
impl<H> !RefUnwindSafe for TickBarAggregator<H>
impl<H> !Send for TickBarAggregator<H>
impl<H> !Sync for TickBarAggregator<H>
impl<H> Unpin for TickBarAggregator<H>where
H: Unpin,
impl<H> !UnwindSafe for TickBarAggregator<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