[][src]Struct sma_rs::SMA

pub struct SMA { /* fields omitted */ }

Build Status

#SMA(Simple Moving Average)

use ta_common::traits::Indicator;
use sma_rs::SMA;
let mut sma = SMA::new(5);
assert_eq!(sma.next(81.59), None);
assert_eq!(sma.next(81.06), None);
assert_eq!(sma.next(82.87), None);
assert_eq!(sma.next(83.00), None);
assert_eq!(sma.next(83.61), Some(82.426));
assert_eq!(sma.next(83.15), Some(82.73799999999999));
assert_eq!(sma.next(82.84), Some(83.09399999999998));
assert_eq!(sma.next(83.99), Some(83.31799999999998));
assert_eq!(sma.next(84.55), Some(83.62799999999999));
assert_eq!(sma.next(84.36), Some(83.77799999999999));
assert_eq!(sma.next(85.53), Some(84.25399999999998));
assert_eq!(sma.next(86.54), Some(84.99399999999997));
assert_eq!(sma.next(86.89), Some(85.57399999999997));
assert_eq!(sma.next(87.77), Some(86.21799999999996));
assert_eq!(sma.next(87.29), Some(86.80399999999996));

Implementations

impl SMA[src]

pub fn new(period: u32) -> SMA[src]

pub fn get_total(&self) -> f64[src]

Trait Implementations

impl Indicator<f64, Option<f64>> for SMA[src]

Auto Trait Implementations

impl RefUnwindSafe for SMA

impl Send for SMA

impl Sync for SMA

impl Unpin for SMA

impl UnwindSafe for SMA

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.