Skip to main content

Indicator

Trait Indicator 

Source
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§

Source

type Output: Clone + Debug

Concrete output type for this indicator (e.g., f64 or a struct).

Required Methods§

Source

fn next(&mut self, candle: &Candle) -> Option<Self::Output>

Feed one candle; returns Some(output) once warmup is satisfied, otherwise None.

Source

fn reset(&mut self)

Reset to initial state.

Source

fn warmup_period(&self) -> usize

Number of candles required before the first valid output.

Source

fn clone_boxed(&self) -> Box<dyn Indicator<Output = Self::Output>>

Clone into a boxed trait object.

Provided Methods§

Source

fn calculate(&self, candles: &[Candle]) -> Vec<Option<Self::Output>>

Batch compute over a candle series (default streaming loop).

Implementors§