pub struct Wma { /* private fields */ }Expand description
Weighted Moving Average indicator.
Assigns linearly increasing weights to more recent prices. Most recent price has weight = period, oldest has weight = 1.
§Formula
WMA = (P11 + P22 + … + Pn*n) / (1 + 2 + … + n)
where n = period and Pn is the most recent price.
§Example
use quant_indicators::{Indicator, Wma};
use quant_primitives::Candle;
use chrono::Utc;
use rust_decimal_macros::dec;
let ts = Utc::now();
let candles: Vec<Candle> = (0..20).map(|i| {
Candle::new(dec!(100), dec!(110), dec!(90), dec!(100) + rust_decimal::Decimal::from(i), dec!(1000), ts).unwrap()
}).collect();
let wma = Wma::new(20).unwrap();
let series = wma.compute(&candles).unwrap();Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Wma
impl RefUnwindSafe for Wma
impl Send for Wma
impl Sync for Wma
impl Unpin for Wma
impl UnsafeUnpin for Wma
impl UnwindSafe for Wma
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