From 8477bf07c7712cd3af451ccd6e431aa329fcfd4d Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Mon, 28 Apr 2025 13:23:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=89=B9=E5=BE=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config_examples/config_freqai.okx.json | 4 ++-- freqtrade/templates/FreqaiExampleStrategy.py | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/config_examples/config_freqai.okx.json b/config_examples/config_freqai.okx.json index 18169835..626b4197 100644 --- a/config_examples/config_freqai.okx.json +++ b/config_examples/config_freqai.okx.json @@ -68,8 +68,8 @@ "purge_old_models": 2, "train_period_days": 15, "identifier": "test62", - "train_period_days": 30, - "backtest_period_days": 10, + "train_period_days": 90, + "backtest_period_days": 30, "live_retrain_hours": 0, "feature_selection": { "method": "recursive_elimination" diff --git a/freqtrade/templates/FreqaiExampleStrategy.py b/freqtrade/templates/FreqaiExampleStrategy.py index 688e6446..fb631b3c 100644 --- a/freqtrade/templates/FreqaiExampleStrategy.py +++ b/freqtrade/templates/FreqaiExampleStrategy.py @@ -30,12 +30,12 @@ class FreqaiExampleStrategy(IStrategy): # FreqAI 配置 freqai_info = { - "model": "XGBoostRegressor", # 改用XGBoost + "model": "CatboostClassifier", # 与config保持一致 "feature_parameters": { - "include_timeframes": ["5m", "15m", "1h"], - "include_corr_pairlist": [], - "label_period_candles": 12, - "include_shifted_candles": 3, + "include_timeframes": ["3m", "15m", "1h"], # 与config一致 + "include_corr_pairlist": ["BTC/USDT", "SOL/USDT"], # 添加相关交易对 + "label_period_candles": 20, # 与config一致 + "include_shifted_candles": 2, # 与config一致 }, "data_split_parameters": { "test_size": 0.2, @@ -308,8 +308,9 @@ class FreqaiExampleStrategy(IStrategy): # 改进买入信号条件 enter_long_conditions = [ (df["rsi"] < df["buy_rsi_pred"]), # RSI 低于买入阈值 - (df["volume"] > df["volume"].rolling(window=10).mean()), # 成交量高于近期均值 - (df["close"] > df["bb_middleband"]) # 价格高于布林带中轨 + (df["volume"] > df["volume"].rolling(window=10).mean() * 1.2), # 成交量高于近期均值20% + (df["close"] > df["bb_middleband"]), # 价格高于布林带中轨 + (df["do_predict"] == 1) # 确保模型预测为买入 ] if enter_long_conditions: df.loc[