2 Star 7 Fork 11

王布衣/engine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
exponential_moving_average.go 898 Bytes
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2024-01-28 11:03 . 新增实时计算EMA的函数
package realtime
import (
"gitee.com/quant1x/engine/factors"
"gitee.com/quant1x/pandas/formula"
)
// AlphaOfExponentialMovingAverage 计算EMA的alpha值
func AlphaOfExponentialMovingAverage(period int) float64 {
return formula.AlphaOfEMA(period)
}
// IncrementalExponentialMovingAverage 增量计算 指数移动平均线
func IncrementalExponentialMovingAverage(now, last, alpha float64) float64 {
return formula.EmaIncr(now, last, alpha)
}
// DynamicExponentialMovingAverage 动态EMA
//
// 返回当前值以及最高值和最低值
func DynamicExponentialMovingAverage(snapshot factors.QuoteSnapshot, last, alpha float64) (ema, emaHigh, emaLow float64) {
ema = IncrementalExponentialMovingAverage(snapshot.Price, last, alpha)
emaHigh = IncrementalExponentialMovingAverage(snapshot.High, last, alpha)
emaLow = IncrementalExponentialMovingAverage(snapshot.Low, last, alpha)
return
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/engine.git
git@gitee.com:quant1x/engine.git
quant1x
engine
engine
v1.7.3

搜索帮助