#移动平均 # #指数 #DEMA

nightly dema-rs

在Rust中的双指数移动平均(DEMA)实现

1 个不稳定版本

0.1.0 2020年11月18日

#15 in #移动平均

MIT 协议

5KB
70

双指数移动平均

use dema_rs::DEMA;
use ta_common::traits::Indicator;
let mut ema = DEMA::new(5);
assert_eq!(ema.next(81.59), None);
assert_eq!(ema.next(81.06), None);
assert_eq!(ema.next(82.87), None);
assert_eq!(ema.next(83.00), None);
assert_eq!(ema.next(83.61), None);
assert_eq!(ema.next(83.15), None);
assert_eq!(ema.next(82.84), None);
assert_eq!(ema.next(83.99), None);
assert_eq!(ema.next(84.55), Some(84.15945181120765));
assert_eq!(ema.next(84.36), Some(84.37935138613696));
assert_eq!(ema.next(85.53), Some(85.12493437653475));
assert_eq!(ema.next(86.54), Some(86.06242299709658));
assert_eq!(ema.next(86.89), Some(86.72659316211335));
assert_eq!(ema.next(87.77), Some(87.5288251063304));
assert_eq!(ema.next(87.29), Some(87.64550318083462));

计算

DEMA=2*EMAn(输入) -EMA(EMAn(输入));
n=周期

依赖项

~14KB