From 13e6f9e7f611910c28d39ccd8075fb7fea14824f Mon Sep 17 00:00:00 2001 From: Liu Xiang Qian Date: Sun, 2 Nov 2025 22:11:27 +0800 Subject: [PATCH 1/2] fix: Correct 4h kline data storage in WebSocket monitor Fixed critical bug where 4h kline data was incorrectly stored with 3m kline data, causing data mismatch. Changes: - Changed `m.klineDataMap4h.Store(s, klines)` to `klines4h` - Updated log message to use `len(klines4h)` instead of `len(klines)` This bug would cause 4h kline queries to return 3m data, leading to incorrect technical indicator calculations. Fixes: #260 Related: #176 --- market/monitor.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/market/monitor.go b/market/monitor.go index 337640d8..23e126d9 100644 --- a/market/monitor.go +++ b/market/monitor.go @@ -106,8 +106,8 @@ func (m *WSMonitor) initializeHistoricalData() error { return } if len(klines4h) > 0 { - m.klineDataMap4h.Store(s, klines) - log.Printf("已加载 %s 的历史K线数据-4h: %d 条", s, len(klines)) + m.klineDataMap4h.Store(s, klines4h) + log.Printf("已加载 %s 的历史K线数据-4h: %d 条", s, len(klines4h)) } }(symbol) } From 3dfdd79a8c3e6f9a178885808657b2dffabd9ef8 Mon Sep 17 00:00:00 2001 From: Liu Xiang Qian Date: Mon, 3 Nov 2025 21:52:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91?= =?UTF-8?q?=20Trader=20=E6=97=B6=20AI=20=E6=A8=A1=E5=9E=8B=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 问题描述 编辑 Trader 配置时,保存提示"AI模型配置不存在或未启用"错误。 ## 根本原因 - 数据库存储的模型 ID 是完整格式(如 `admin_deepseek`) - API 返回时将其转换为 provider 格式(`deepseek`) - 前端 enabledModels 列表中是完整 ID - 导致前端用 `deepseek` 查找 `admin_deepseek` 时失败 ## 修复方案 移除 handleGetTraderConfig 中的模型 ID 转换逻辑, 返回完整的模型 ID,保持与前端模型列表格式一致。 Fixes #335 --- api/server.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/api/server.go b/api/server.go index ad16470a..92270715 100644 --- a/api/server.go +++ b/api/server.go @@ -801,14 +801,8 @@ func (s *Server) handleGetTraderConfig(c *gin.Context) { } } - // AIModelID 应该已经是 provider(如 "deepseek"),直接使用 - // 如果是旧数据格式(如 "admin_deepseek"),提取 provider 部分 + // 返回完整的模型ID,不做转换,保持与前端模型列表一致 aiModelID := traderConfig.AIModelID - // 兼容旧数据:如果包含下划线,提取最后一部分作为 provider - if strings.Contains(aiModelID, "_") { - parts := strings.Split(aiModelID, "_") - aiModelID = parts[len(parts)-1] - } result := map[string]interface{}{ "trader_id": traderConfig.ID,