From dc4fa4411ad0a891d409b75ad4f07e313f899ed4 Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Tue, 24 Feb 2026 01:04:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=85=B3=E9=94=AE=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=9A=E7=A7=BB=E9=99=A4=E5=A4=9A=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E5=A4=84=E7=90=86=E4=B8=AD=E7=9A=84bfill()?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E6=95=B0=E6=8D=AE=E5=89=8D=E7=9E=BB?= =?UTF-8?q?=E5=81=8F=E5=B7=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freqtrade/templates/freqaiprimer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/freqtrade/templates/freqaiprimer.py b/freqtrade/templates/freqaiprimer.py index 2acfe7e3..ae738150 100644 --- a/freqtrade/templates/freqaiprimer.py +++ b/freqtrade/templates/freqaiprimer.py @@ -741,7 +741,8 @@ class FreqaiPrimer(IStrategy): # 确保 StochRSI 指标已正确计算 # 将 1h 数据重新索引到主时间框架 (3m),并填充缺失值 - df_1h = df_1h.set_index('date').reindex(dataframe['date']).ffill().bfill().reset_index() + # 注意:只使用 ffill()(向前填充),不要用 bfill()(避免数据前瞻偏差) + df_1h = df_1h.set_index('date').reindex(dataframe['date']).ffill().reset_index() df_1h = df_1h.rename(columns={'index': 'date'}) # Include macd_1h, macd_signal_1h, ema_5_1h, ema_20_1h, ema5_cross_above_ema20 in the column selection df_1h = df_1h[['date', 'rsi_1h', 'trend_1h', 'ema_50_1h', 'ema_200_1h', 'bb_lower_1h', 'bb_upper_1h', 'stochrsi_k_1h', 'stochrsi_d_1h', 'macd_1h', 'macd_signal_1h', 'macd_hist_1h', 'ema_5_1h', 'ema_20_1h', 'ema20_slope_normalized', 'ema5_cross_above_ema20']].ffill()