pub struct Resampler { /* private fields */ }Expand description
Roll a stream of candles up to a coarser timeframe.
Used to derive 5m bars from a 1m feed, or 1h bars from 5m bars, without touching the original tick stream. The output timeframe’s bucket must be a strict multiple of the input timeframe’s bucket, but this is not enforced — callers are responsible for picking sensible aggregations.
Implementations§
Source§impl Resampler
impl Resampler
Sourcepub fn new(timeframe: Timeframe) -> Self
pub fn new(timeframe: Timeframe) -> Self
Build a resampler targeting the given output timeframe.
Sourcepub fn push(&mut self, candle: Candle) -> Result<Option<Candle>>
pub fn push(&mut self, candle: Candle) -> Result<Option<Candle>>
Push a finer-grained candle. Returns the coarser candle that just closed, if any.
§Errors
Returns Error::Malformed if candle.timestamp falls into a bucket
strictly before the currently open bar — out-of-order candles are not
supported, matching crate::aggregator::TickAggregator::push.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Resampler
impl RefUnwindSafe for Resampler
impl Send for Resampler
impl Sync for Resampler
impl Unpin for Resampler
impl UnsafeUnpin for Resampler
impl UnwindSafe for Resampler
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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