Skip to main content

Indicator

Trait Indicator 

Source
pub trait Indicator {
    type Input: Copy;

    // Required methods
    fn update(&mut self, input: Self::Input) -> Option<f64>;
    fn reset(&mut self);
    fn warmup_period(&self) -> usize;
    fn is_ready(&self) -> bool;
    fn name(&self) -> &'static str;
}
Expand description

A streaming technical indicator.

The contract mirrors wickra-core’s trait so a no-alloc indicator here is a drop-in behavioural twin of its std counterpart:

  • update is called once per input point and is O(1) in the series length. It returns None while the indicator is still warming up and Some(value) once a defined value exists.
  • reset clears all state, leaving the indicator exactly as freshly constructed.

The associated Input is Copy (a price f64 or a Candle) so the update path never clones or allocates.

Required Associated Types§

Source

type Input: Copy

Type of one input data point (f64 for a price, Candle for an OHLC bar).

Required Methods§

Source

fn update(&mut self, input: Self::Input) -> Option<f64>

Feed one new data point in and return the freshly computed value, or None while still warming up.

Source

fn reset(&mut self)

Reset all internal state, leaving the indicator equivalent to a freshly constructed instance with the same parameters.

Source

fn warmup_period(&self) -> usize

Number of inputs required before the first non-None output.

Source

fn is_ready(&self) -> bool

Whether the indicator has produced at least one value since construction or the last reset.

Source

fn name(&self) -> &'static str

Stable, human-readable indicator name.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Indicator for Ema

Source§

impl<const N: usize> Indicator for Atr<N>

Source§

impl<const N: usize> Indicator for Roc<N>

Source§

impl<const N: usize> Indicator for Rsi<N>

Source§

impl<const N: usize> Indicator for Sma<N>