1个不稳定版本

0.1.0 2020年11月18日

#2#ema

Download history • Rust 包仓库 15/week @ 2024-03-11 • Rust 包仓库 18/week @ 2024-03-18 • Rust 包仓库 29/week @ 2024-03-25 • Rust 包仓库 53/week @ 2024-04-01 • Rust 包仓库 10/week @ 2024-04-08 • Rust 包仓库 9/week @ 2024-04-15 • Rust 包仓库 22/week @ 2024-04-22 • Rust 包仓库 8/week @ 2024-04-29 • Rust 包仓库 18/week @ 2024-05-06 • Rust 包仓库 12/week @ 2024-05-13 • Rust 包仓库 19/week @ 2024-05-20 • Rust 包仓库 7/week @ 2024-05-27 • Rust 包仓库 14/week @ 2024-06-03 • Rust 包仓库 10/week @ 2024-06-10 • Rust 包仓库 10/week @ 2024-06-17 • Rust 包仓库 17/week @ 2024-06-24 • Rust 包仓库

每月 51 次下载
用于 6 crates

MIT 许可证

4KB
55

指数移动平均(EMA)

 use ta_common::traits::Indicator;
 use ema_rs::EMA;
 let mut ema = EMA::new(5);
 assert_eq!(ema.next(81.59), 81.59);
 assert_eq!(ema.next(81.06), 81.41333333333334);
 assert_eq!(ema.next(82.87), 81.8988888888889);
 assert_eq!(ema.next(83.00), 82.26592592592594);
 assert_eq!(ema.next(83.61), 82.71395061728396);
 assert_eq!(ema.next(83.15), 82.85930041152264);
 assert_eq!(ema.next(82.84), 82.8528669410151);
 assert_eq!(ema.next(83.99), 83.23191129401008);
 assert_eq!(ema.next(84.55), 83.67127419600672);
 assert_eq!(ema.next(84.36), 83.9008494640045);
 assert_eq!(ema.next(85.53), 84.44389964266966);
 assert_eq!(ema.next(86.54), 85.14259976177978);
 assert_eq!(ema.next(86.89), 85.7250665078532);

计算

ema= (1-k) emaprev. + k * input;
k=2/(N+1);
N=period;

依赖项

~10KB