From 0ef062353825445845c7194765e584fd895ecc78 Mon Sep 17 00:00:00 2001 From: aszerW Date: Mon, 25 May 2026 02:30:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=BC=E5=87=BA=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E5=9B=A0=E5=AD=90=E5=89=8D=E5=90=91=E5=A1=AB=E5=85=85=E5=AF=B9?= =?UTF-8?q?=E9=BD=90=E5=88=B0=E5=B1=95=E7=A4=BA=E6=97=A5=E5=8E=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 先定义 common_dates = equity_curve.index - 再执行 factor_df.reindex(common_dates, method='ffill') - 修复境外市场放假时动量显示为 None 的问题 --- framework_v2/scripts/export_backtest_detail.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/framework_v2/scripts/export_backtest_detail.py b/framework_v2/scripts/export_backtest_detail.py index 75ef2e0..f1e2102 100644 --- a/framework_v2/scripts/export_backtest_detail.py +++ b/framework_v2/scripts/export_backtest_detail.py @@ -137,19 +137,21 @@ def main(): # 9. 构建逐日明细 print("[9] 构建逐日明细...") + # 获取展示日历 + common_dates = equity_curve.index + # 因子数据(DataFrame 格式) factor_df = pd.DataFrame(factors) - # 将因子对齐到 A 股交易日历(前向填充) + # 将因子对齐到实际展示日历(前向填充) # 因子已经在原始数据上计算完成,这里只是将结果对齐到展示日历 - factor_df_aligned = factor_df.reindex(trading_calendar, method='ffill') + factor_df_aligned = factor_df.reindex(common_dates, method='ffill') # 持仓状态跟踪 holdings_state = {} # {code: {'entry_date': str, 'entry_price': float}} prev_holdings = set() days_list = [] - common_dates = equity_curve.index # 获取配置信息 bond_code = strategy.bond_code if strategy.use_dynamic_threshold else None