mirror of
https://github.com/laoxong/nofx.git
synced 2026-06-04 09:58:22 +08:00
fix the arrary out of range (#782)
This commit is contained in:
@@ -42,6 +42,14 @@ func Get(symbol string) (*Data, error) {
|
||||
return nil, fmt.Errorf("获取4小时K线失败: %v", err)
|
||||
}
|
||||
|
||||
// 检查数据是否为空
|
||||
if len(klines3m) == 0 {
|
||||
return nil, fmt.Errorf("3分钟K线数据为空")
|
||||
}
|
||||
if len(klines4h) == 0 {
|
||||
return nil, fmt.Errorf("4小时K线数据为空")
|
||||
}
|
||||
|
||||
// 计算当前指标 (基于3分钟最新数据)
|
||||
currentPrice := klines3m[len(klines3m)-1].Close
|
||||
currentEMA20 := calculateEMA(klines3m, 20)
|
||||
|
||||
Reference in New Issue
Block a user