#moving-average #sma #indicator

nightly sma-rs

Simple Moving Average (SMA) Implementation In Rust

5 releases

0.1.4 Dec 1, 2020
0.1.3 Nov 30, 2020
0.1.2 Nov 28, 2020
0.1.1 Nov 27, 2020
0.1.0 Nov 17, 2020

#13 in #moving-average

Download history 15/week @ 2024-06-08 16/week @ 2024-06-15 20/week @ 2024-06-22 5/week @ 2024-06-29 4/week @ 2024-07-06 26/week @ 2024-07-13 14/week @ 2024-07-20 53/week @ 2024-07-27 24/week @ 2024-08-03 13/week @ 2024-08-10 13/week @ 2024-08-17 12/week @ 2024-08-24 14/week @ 2024-08-31 9/week @ 2024-09-07 12/week @ 2024-09-14 22/week @ 2024-09-21

57 downloads per month
Used in 9 crates (6 directly)

MIT license

5KB
65 lines

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));

Dependencies

~10KB