From b8aac613a7a092753dd32e18d85b9097c641fd2b Mon Sep 17 00:00:00 2001 From: ivaaaan Date: Thu, 4 Apr 2024 21:40:40 +0700 Subject: [PATCH] feat: add unfinished_candle method --- src/aggregator.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/aggregator.rs b/src/aggregator.rs index 1d6c759..cd1665b 100644 --- a/src/aggregator.rs +++ b/src/aggregator.rs @@ -13,6 +13,11 @@ pub trait Aggregator { /// Some output only when a new candle has been created, /// otherwise it returns None fn update(&mut self, trade: &T) -> Option; + + /// Get a reference to an unfinished `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`. + fn unfinished_candle(&self) -> &Candle; } /// An `Aggregator` that is generic over @@ -64,6 +69,10 @@ where self.candle.update(trade); None } + + fn unfinished_candle(&self) -> &C { + &self.candle + } } #[cfg(test)]