pub struct WeightedMovingAverage { /* private fields */ }Expand description
Weighted moving average (WMA).
A moving average that assigns weights that decrease in arithmetical progression. In an n-day WMA the latest day has weight n, the second latest n−1, etc., down to one.
§Formula
Where:
- WMAM - is the value of the WMA at time m
- n - is the period.
- pM - is the input value at a time period t.
§Example
use finlib_ta::indicators::WeightedMovingAverage;
use finlib_ta::Next;
let mut wma = WeightedMovingAverage::new(3).unwrap();
assert_eq!(wma.next(10.0), 10.0);
assert_eq!(wma.next(13.0), 12.0);
assert_eq!(wma.next(16.0), 14.0);
assert_eq!(wma.next(14.0), 14.5);§Links
Implementations§
Trait Implementations§
Source§impl Clone for WeightedMovingAverage
impl Clone for WeightedMovingAverage
Source§fn clone(&self) -> WeightedMovingAverage
fn clone(&self) -> WeightedMovingAverage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WeightedMovingAverage
impl Debug for WeightedMovingAverage
Source§impl Default for WeightedMovingAverage
impl Default for WeightedMovingAverage
Source§impl Display for WeightedMovingAverage
impl Display for WeightedMovingAverage
Source§impl Next<f64> for WeightedMovingAverage
impl Next<f64> for WeightedMovingAverage
Auto Trait Implementations§
impl Freeze for WeightedMovingAverage
impl RefUnwindSafe for WeightedMovingAverage
impl Send for WeightedMovingAverage
impl Sync for WeightedMovingAverage
impl Unpin for WeightedMovingAverage
impl UnwindSafe for WeightedMovingAverage
Blanket Implementations§
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
Mutably borrows from an owned value. Read more