pub struct Momentum { /* private fields */ }Expand description
Momentum indicator.
Measures the rate of change in price over a specified period. Simple but effective for identifying trend strength.
§Formula
Momentum = Close - Close[n periods ago]
§Example
use quant_indicators::{Indicator, Momentum};
use quant_primitives::Candle;
use chrono::Utc;
use rust_decimal_macros::dec;
let ts = Utc::now();
let candles: Vec<Candle> = (0..15).map(|i| {
Candle::new(dec!(100), dec!(110), dec!(90), dec!(100) + rust_decimal::Decimal::from(i), dec!(1000), ts).unwrap()
}).collect();
let mom = Momentum::new(10).unwrap();
let series = mom.compute(&candles).unwrap();Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Momentum
impl RefUnwindSafe for Momentum
impl Send for Momentum
impl Sync for Momentum
impl Unpin for Momentum
impl UnsafeUnpin for Momentum
impl UnwindSafe for Momentum
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