Skip to content

Commit

Permalink
feat: add unfinished_candle method
Browse files Browse the repository at this point in the history
  • Loading branch information
ivantrontal committed Apr 10, 2024
1 parent fb31dab commit b8aac61
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ pub trait Aggregator<Candle, T: TakerTrade> {
/// Some output only when a new candle has been created,
/// otherwise it returns None
fn update(&mut self, trade: &T) -> Option<Candle>;

/// 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
Expand Down Expand Up @@ -64,6 +69,10 @@ where
self.candle.update(trade);
None
}

fn unfinished_candle(&self) -> &C {
&self.candle
}
}

#[cfg(test)]
Expand Down

0 comments on commit b8aac61

Please # to comment.