From febe57c744002315e63adc72905e4ad17a1f942b Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Sun, 17 Aug 2025 11:41:47 +0800 Subject: [PATCH] =?UTF-8?q?trae=E8=A7=A3=E5=86=B3=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E7=9B=AE=E6=A0=87=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freqtrade/templates/freqaiprimer.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/freqtrade/templates/freqaiprimer.py b/freqtrade/templates/freqaiprimer.py index 7fe1e0dc..d25a54f4 100644 --- a/freqtrade/templates/freqaiprimer.py +++ b/freqtrade/templates/freqaiprimer.py @@ -1401,9 +1401,20 @@ class FreqaiPrimer(IStrategy): try: # 使用分类模型预测最优 first_length - # 检查所有可能的分类列 - classification_cols = [col for col in dataframe.columns if "optimal_first_length" in str(col)] - logger.info(f"[{pair}] 📊 检测到分类相关列: {classification_cols}") + # 检查所有可能的分类列(精确匹配实际列名格式) + classification_cols = [col for col in dataframe.columns + if col in ["&*-optimal_first_length", "optimal_first_length_pred"]] + if classification_cols: + logger.info(f"[{pair}] 📊 检测到分类相关列: {classification_cols}") + else: + logger.debug(f"[{pair}] 📊 未检测到分类相关列") + + # 调试:显示所有包含"optimal"的列名 + all_optimal_cols = [col for col in dataframe.columns if "optimal" in str(col).lower()] + if all_optimal_cols: + logger.debug(f"[{pair}] 所有包含'optimal'的列: {all_optimal_cols}") + else: + logger.debug(f"[{pair}] 未找到任何包含'optimal'的列") if "optimal_first_length_pred" in dataframe.columns: predicted_value = dataframe["optimal_first_length_pred"].iloc[-1] @@ -1429,9 +1440,12 @@ class FreqaiPrimer(IStrategy): logger.warning(f"[{pair}] ⚠️ &*-optimal_first_length 为NaN,使用默认值: {first_length}") else: first_length = 2 - logger.warning(f"[{pair}] ⚠️ 未找到任何分类模型列,使用默认值: {first_length}") - # 调试:显示所有列名 - logger.debug(f"[{pair}] 可用列: {list(dataframe.columns)[:10]}...") + # 只在首次或特定条件下显示警告 + if not hasattr(self, '_classification_warning_shown'): + logger.warning(f"[{pair}] ⚠️ 未找到分类模型列,使用默认值: {first_length}") + self._classification_warning_shown = True + else: + logger.debug(f"[{pair}] 未找到分类模型列,使用默认值: {first_length}") # 根据 first_length 动态调整其他段长 second_length = first_length * 3