Struct trade_aggregation::GenericAggregator
source · pub struct GenericAggregator<C, R, T> { /* private fields */ }
Expand description
An Aggregator
that is generic over
the type of Candle being produced,
as well as by which rule the candle is created
Implementations§
source§impl<C, R, T> GenericAggregator<C, R, T>
impl<C, R, T> GenericAggregator<C, R, T>
sourcepub fn new(aggregation_rule: R, include_trade_that_triggered_rule: bool) -> Self
pub fn new(aggregation_rule: R, include_trade_that_triggered_rule: bool) -> Self
Create a new instance with a concrete aggregation rule and an empty candle.
§Arguments:
aggregation_rule
: The rule that dictates when to trigger the creation of a new candle.
include_trade_that_triggered_rule
: If true, the trade that triggered a rule is included in the current candle
as well as the next one.
During some aggregations, the desired behaviour is that the trade that crosses the trigger boundary
is included in both the current and next candle.
Examples uses include ensuring the close and open price of the current and next candle are equal.
If that’s desired, set the field to true during construction of Self
.
E.g on Tradingview the time aggregation would have this set to false
, which may create gaps between close and open of subsequent candles.
Trait Implementations§
source§impl<C, R, T> Aggregator<C, T> for GenericAggregator<C, R, T>
impl<C, R, T> Aggregator<C, T> for GenericAggregator<C, R, T>
source§fn update(&mut self, trade: &T) -> Option<C>
fn update(&mut self, trade: &T) -> Option<C>
source§fn unfinished_candle(&self) -> &C
fn unfinished_candle(&self) -> &C
Candle
.
Accessing a Candle
using this method does not guarantee that the AggregationRule
is respected.
It is generally advised to call update
instead and use the resulting Candle
if its Some
.Auto Trait Implementations§
impl<C, R, T> Freeze for GenericAggregator<C, R, T>
impl<C, R, T> RefUnwindSafe for GenericAggregator<C, R, T>
impl<C, R, T> Send for GenericAggregator<C, R, T>
impl<C, R, T> Sync for GenericAggregator<C, R, T>
impl<C, R, T> Unpin for GenericAggregator<C, R, T>
impl<C, R, T> UnwindSafe for GenericAggregator<C, R, T>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)