From 972bbbe7066a2064657f09458eb53801bd304a14 Mon Sep 17 00:00:00 2001 From: aszerW Date: Wed, 3 Jun 2026 01:25:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(rotation):=20signal=5Fdate=E6=94=B9?= =?UTF-8?q?=E7=94=A8=E6=97=A5=E5=8E=86=E6=97=A5=E5=89=8D=E4=B8=80=E5=A4=A9?= =?UTF-8?q?=E4=BB=A5=E6=8D=95=E8=8E=B7=E5=A4=96=E7=9B=98=E5=81=87=E6=9C=9F?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 signal_date = trading_calendar[i-1] 改为 date - timedelta(days=1) - 解决A股长假期间美股继续交易但动量计算丢失外盘数据的问题 - 同步修复 export_results 中的 signal_date 映射逻辑 --- rotation/simple_rotation.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/rotation/simple_rotation.py b/rotation/simple_rotation.py index 9dde1c3..6e70df3 100644 --- a/rotation/simple_rotation.py +++ b/rotation/simple_rotation.py @@ -505,12 +505,10 @@ class SimpleRotationStrategy: # Signal timing: 9:00 AM on day T # At this moment, T's market has NOT opened yet. # Only T-1 close data is available for all markets. - # So momentum must be computed from T-1 close (prev_date). + # Use calendar day -1 (not A-share prev trading day) so that + # foreign markets (US/HK) that traded during A-share holidays are captured. # Execution happens at 9:30 AM using T's ETF prices. - if i > 0: - signal_date = self.trading_calendar[i - 1] # T-1 close - else: - signal_date = date # First day: no prior trading day available + signal_date = date - timedelta(days=1) new_holdings, factors, bond_momentum = self._generate_signals(signal_date) @@ -826,11 +824,9 @@ class SimpleRotationStrategy: tracked_entry: Dict[str, dict] = {} prev_holdings = [] - # Build date index map for signal_date lookup (T-1) + # Build date index map for signal_date lookup (calendar T-1, not A-share prev trading day) date_list = [pd.Timestamp(rec['date']) for rec in self.daily_records] - date_to_signal_date = {} - for i, d in enumerate(date_list): - date_to_signal_date[d] = date_list[i - 1] if i > 0 else d + date_to_signal_date = {d: d - timedelta(days=1) for d in date_list} for rec in self.daily_records: date = pd.Timestamp(rec['date'])