pub struct RenkoBarAggregator<H>{
pub brick_size: PriceRaw,
/* private fields */
}
Expand description
Provides a means of building Renko bars aggregated from quote and trades.
Renko bars are created when the price moves by a fixed amount (brick size) regardless of time or volume. Each bar represents a price movement equal to the step size in the bar specification.
Fields§
§brick_size: PriceRaw
Implementations§
Source§impl<H> RenkoBarAggregator<H>
impl<H> RenkoBarAggregator<H>
Sourcepub fn new(
bar_type: BarType,
price_precision: u8,
size_precision: u8,
price_increment: Price,
handler: H,
await_partial: bool,
) -> Self
pub fn new( bar_type: BarType, price_precision: u8, size_precision: u8, price_increment: Price, handler: H, await_partial: bool, ) -> Self
Creates a new RenkoBarAggregator
instance.
§Panics
This function panics if:
instrument.id
is not equal to thebar_type.instrument_id
.bar_type.aggregation_source
is not equal toAggregationSource::Internal
.
Trait Implementations§
Source§impl<H> BarAggregator for RenkoBarAggregator<H>
impl<H> BarAggregator for RenkoBarAggregator<H>
Source§fn update(&mut self, price: Price, size: Quantity, ts_init: UnixNanos)
fn update(&mut self, price: Price, size: Quantity, ts_init: UnixNanos)
Apply the given update to the aggregator.
For Renko bars, we check if the price movement from the last close is greater than or equal to the brick size. If so, we create new bars.
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)
Source§fn 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.
Source§fn await_partial(&self) -> bool
fn await_partial(&self) -> bool
Stops batch mode and restores the standard bar handler.
fn update_bar(&mut self, bar: Bar, volume: Quantity, ts_init: UnixNanos)
Source§fn start_batch_update(&mut self, handler: Box<dyn FnMut(Bar)>, _: UnixNanos)
fn start_batch_update(&mut self, handler: Box<dyn FnMut(Bar)>, _: UnixNanos)
Incorporates an existing bar and its volume into aggregation at the given init timestamp.
Source§fn 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.
Source§fn 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.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<H> Freeze for RenkoBarAggregator<H>where
H: Freeze,
impl<H> !RefUnwindSafe for RenkoBarAggregator<H>
impl<H> !Send for RenkoBarAggregator<H>
impl<H> !Sync for RenkoBarAggregator<H>
impl<H> Unpin for RenkoBarAggregator<H>where
H: Unpin,
impl<H> !UnwindSafe for RenkoBarAggregator<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