From ea707fe104071f961bd89b01bf8aa0d5556d88f0 Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Mon, 28 Apr 2025 14:06:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=9F=E7=89=B9=E5=BE=81=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E6=B2=A1=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config_examples/config_freqai.okx.json | 2 +- freqtrade/templates/FreqaiExampleStrategy.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config_examples/config_freqai.okx.json b/config_examples/config_freqai.okx.json index c8ffea75..9f7f17a6 100644 --- a/config_examples/config_freqai.okx.json +++ b/config_examples/config_freqai.okx.json @@ -78,7 +78,7 @@ "include_corr_pairlist": ["BTC/USDT"], "label_period_candles": 10, "include_shifted_candles": 1, - "DI_threshold": 0.3, + "DI_threshold": 1.5, "weight_factor": 0.9, "principal_component_analysis": false, "use_SVM_to_remove_outliers": false, diff --git a/freqtrade/templates/FreqaiExampleStrategy.py b/freqtrade/templates/FreqaiExampleStrategy.py index 7a5ca70c..956ecb9f 100644 --- a/freqtrade/templates/FreqaiExampleStrategy.py +++ b/freqtrade/templates/FreqaiExampleStrategy.py @@ -179,9 +179,10 @@ class FreqaiExampleStrategy(IStrategy): label_period = self.freqai_info["feature_parameters"]["label_period_candles"] # 生成更复杂的目标变量 up_or_down - dataframe["up_or_down"] = np.where( - dataframe["close"].shift(-label_period) > dataframe["close"], 1, 0 - ) + # Ensure the target variable is reshaped correctly + dataframe["up_or_down"] = np.where( + dataframe["close"].shift(-label_period) > dataframe["close"], 1, 0 + ).reshape(-1, 1) # Reshape to 2D array # 生成 %-volatility 特征 dataframe["%-volatility"] = dataframe["close"].pct_change().rolling(20).std() @@ -202,6 +203,8 @@ class FreqaiExampleStrategy(IStrategy): logger.error(f"创建 FreqAI 目标失败:{str(e)}") raise + # Log the shape of the target variable for debugging + logger.info(f"目标列形状:{dataframe['up_or_down'].shape}") logger.info(f"目标列预览:\n{dataframe[['up_or_down', '&-buy_rsi']].head().to_string()}") return dataframe