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)]