pub trait Indicator: Send + Sync {
type Output: Clone + Debug;
// Required methods
fn next(&mut self, candle: &Candle) -> Option<Self::Output>;
fn reset(&mut self);
fn warmup_period(&self) -> usize;
fn clone_boxed(&self) -> Box<dyn Indicator<Output = Self::Output>>;
// Provided method
fn calculate(&self, candles: &[Candle]) -> Vec<Option<Self::Output>> { ... }
}Expand description
Core interface for all streaming technical indicators.
Implementations should be stateful and cheap to next(). The default
calculate helper performs a streaming pass over a slice of candles.
Required Associated Types§
Required Methods§
Sourcefn next(&mut self, candle: &Candle) -> Option<Self::Output>
fn next(&mut self, candle: &Candle) -> Option<Self::Output>
Feed one candle; returns Some(output) once warmup is satisfied, otherwise None.
Sourcefn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
Number of candles required before the first valid output.
Sourcefn clone_boxed(&self) -> Box<dyn Indicator<Output = Self::Output>>
fn clone_boxed(&self) -> Box<dyn Indicator<Output = Self::Output>>
Clone into a boxed trait object.