pub struct Smma { /* private fields */ }Expand description
Smoothed Moving Average — Wilder’s running moving average, also known as RMA.
Seeded with the simple average of the first period inputs, then advanced
by SMMA_t = (SMMA_{t-1} * (period - 1) + price_t) / period. This is an
exponential average with a slow 1 / period smoothing factor and is the
average underlying Wilder’s RSI and ATR. The first output lands after
exactly period inputs.
§Example
use wickra_core::{Indicator, Smma};
let mut indicator = Smma::new(3).unwrap();
let mut last = None;
for i in 0..80 {
last = indicator.update(100.0 + f64::from(i));
}
assert!(last.is_some());Implementations§
Trait Implementations§
Source§impl Indicator for Smma
impl Indicator for Smma
Source§fn batch_fast_into(&mut self, inputs: &[f64], out: &mut [f64])
fn batch_fast_into(&mut self, inputs: &[f64], out: &mut [f64])
SIMD kernel: the same seed mean, then Wilder’s smoothing
y = ((period − 1) / period) · y + x / period as a linear-recurrence
scan. Agrees with the exact batch to within a few units in the last
place (the division per step becomes two multiplies, and the scan
reassociates the recurrence); warmup NaNs and length are identical.
Afterwards the SMMA continues streaming from the kernel’s last value.
Source§fn update(&mut self, input: f64) -> Option<f64>
fn update(&mut self, input: f64) -> Option<f64>
None if there is no value for this input. Read moreSource§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Source§fn is_ready(&self) -> bool
fn is_ready(&self) -> bool
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
Source§fn batch_nan_into(&mut self, inputs: &[Self::Input], out: &mut [f64])
fn batch_nan_into(&mut self, inputs: &[Self::Input], out: &mut [f64])
Auto Trait Implementations§
impl Freeze for Smma
impl RefUnwindSafe for Smma
impl Send for Smma
impl Sync for Smma
impl Unpin for Smma
impl UnsafeUnpin for Smma
impl UnwindSafe for Smma
Blanket Implementations§
Source§impl<T> BatchExt for Twhere
T: Indicator,
impl<T> BatchExt for Twhere
T: Indicator,
Source§fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
None during warmup) per input.Source§impl<T> BatchNanExt for T
impl<T> BatchNanExt for T
Source§fn batch_nan(&mut self, inputs: &[f64]) -> Vec<f64>
fn batch_nan(&mut self, inputs: &[f64]) -> Vec<f64>
f64 per input, warmup positions filled with NaN, bit-for-bit equal
to replaying update.Source§fn batch_fast(&mut self, inputs: &[f64]) -> Vec<f64>
fn batch_fast(&mut self, inputs: &[f64]) -> Vec<f64>
Indicator::batch_fast_into) into a fresh
vector: within the indicator’s documented tolerance of
batch_nan, deterministic across platforms.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more