pub trait Indicator {
type Input;
type Output;
// Required methods
fn update(&mut self, input: Self::Input) -> Option<Self::Output>;
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.
Every indicator in Wickra implements this trait. The contract is:
updateis called once per input point and must be O(1) in the input length. Pre-existing buffered state may be touched, but no full recomputation over the entire series is permitted.- The returned
Option<Output>isNonewhile the indicator is still in its warmup phase (insufficient inputs to produce a defined value), andSomeonce it is ready. resetclears all state, returning the indicator to the exact configuration it had immediately after construction.
Implementors that consume scalar prices use Input = f64 so they automatically
gain access to chaining via Chain.
Required Associated Types§
Required Methods§
Sourcefn update(&mut self, input: Self::Input) -> Option<Self::Output>
fn update(&mut self, input: Self::Input) -> Option<Self::Output>
Feed one new data point into the indicator and return the freshly computed
output, or None if the indicator is still warming up.
Sourcefn reset(&mut self)
fn reset(&mut self)
Reset all internal state, leaving the indicator equivalent to a freshly constructed instance with the same parameters.
Sourcefn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
Number of inputs required before the first non-None output can be produced.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".