mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-12 23:36:55 +08:00
fix(market): add 3m volume and ATR14 indicators to AI data (#830)
* Support 3m volume and ATR4 * test(market): add unit tests for Volume and ATR14 indicators - Add comprehensive tests for calculateIntradaySeries Volume collection - Add tests for ATR14 calculation with various data scenarios - Add edge case tests for insufficient data - Test Volume value precision and consistency with other indicators - All 8 test cases pass successfully Resolves code review blocking issue from PR #830
This commit is contained in:
@@ -227,6 +227,7 @@ func calculateIntradaySeries(klines []Kline) *IntradayData {
|
||||
MACDValues: make([]float64, 0, 10),
|
||||
RSI7Values: make([]float64, 0, 10),
|
||||
RSI14Values: make([]float64, 0, 10),
|
||||
Volume: make([]float64, 0, 10),
|
||||
}
|
||||
|
||||
// 获取最近10个数据点
|
||||
@@ -237,6 +238,7 @@ func calculateIntradaySeries(klines []Kline) *IntradayData {
|
||||
|
||||
for i := start; i < len(klines); i++ {
|
||||
data.MidPrices = append(data.MidPrices, klines[i].Close)
|
||||
data.Volume = append(data.Volume, klines[i].Volume)
|
||||
|
||||
// 计算每个点的EMA20
|
||||
if i >= 19 {
|
||||
@@ -261,6 +263,9 @@ func calculateIntradaySeries(klines []Kline) *IntradayData {
|
||||
}
|
||||
}
|
||||
|
||||
// 计算3m ATR14
|
||||
data.ATR14 = calculateATR(klines, 14)
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -440,6 +445,12 @@ func Format(data *Data) string {
|
||||
if len(data.IntradaySeries.RSI14Values) > 0 {
|
||||
sb.WriteString(fmt.Sprintf("RSI indicators (14‑Period): %s\n\n", formatFloatSlice(data.IntradaySeries.RSI14Values)))
|
||||
}
|
||||
|
||||
if len(data.IntradaySeries.Volume) > 0 {
|
||||
sb.WriteString(fmt.Sprintf("Volume: %s\n\n", formatFloatSlice(data.IntradaySeries.Volume)))
|
||||
}
|
||||
|
||||
sb.WriteString(fmt.Sprintf("3m ATR (14‑period): %.3f\n\n", data.IntradaySeries.ATR14))
|
||||
}
|
||||
|
||||
if data.LongerTermContext != nil {
|
||||
|
||||
Reference in New Issue
Block a user