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:
updateis called once per input point and is O(1) in the series length. It returnsNonewhile the indicator is still warming up andSome(value)once a defined value exists.resetclears 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§
Required Methods§
Sourcefn update(&mut self, input: Self::Input) -> Option<f64>
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.
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".