pub struct BarBuilder { /* private fields */ }Expand description
Provides a generic bar builder for aggregation.
Implementations§
Source§impl BarBuilder
impl BarBuilder
Sourcepub fn new(bar_type: BarType, price_precision: u8, size_precision: u8) -> Self
pub fn new(bar_type: BarType, price_precision: u8, size_precision: u8) -> Self
Creates a new BarBuilder instance.
§Panics
Panics if bar_type.aggregation_source is not AggregationSource::Internal.
Sourcepub fn set_adjustment(
&mut self,
adjustment: Decimal,
mode: ContinuousFutureAdjustmentType,
)
pub fn set_adjustment( &mut self, adjustment: Decimal, mode: ContinuousFutureAdjustmentType, )
Configures the per-tick continuous-future price adjustment.
Adjustment applies on ingress in Self::update and Self::update_bar, so the running
OHLC state is always in the adjusted (common) frame. The adjustment configuration is
retained across Self::reset so it spans subsequent bars within the same continuous-
future segment.
§Panics
Panics if scaling the spread adjustment to the fixed-point representation overflows.
Sourcepub fn update(&mut self, price: Price, size: Quantity, ts_init: UnixNanos)
pub fn update(&mut self, price: Price, size: Quantity, ts_init: UnixNanos)
Updates the builder state with the given price, size, and init timestamp.
§Panics
Panics if high or low values are unexpectedly None when updating.
Sourcepub fn update_bar(&mut self, bar: Bar, volume: Quantity, ts_init: UnixNanos)
pub fn update_bar(&mut self, bar: Bar, volume: Quantity, ts_init: UnixNanos)
Updates the builder state with a completed bar, its volume, and the bar init timestamp.
§Panics
Panics if high or low values are unexpectedly None when updating.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Resets per-bar OHLCV state.
Adjustment configuration set via Self::set_adjustment is retained across resets so it
spans subsequent bars within the same continuous-future segment.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BarBuilder
impl RefUnwindSafe for BarBuilder
impl Send for BarBuilder
impl Sync for BarBuilder
impl Unpin for BarBuilder
impl UnsafeUnpin for BarBuilder
impl UnwindSafe for BarBuilder
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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