diff --git a/strategies/rotation/strategy.py b/strategies/rotation/strategy.py index 1e9ae13..f60b56f 100644 --- a/strategies/rotation/strategy.py +++ b/strategies/rotation/strategy.py @@ -420,10 +420,11 @@ class RotationStrategy(StrategyBase): # 提取原始收盘价序列 if 'close' in df.columns: close_series = df['close'].dropna() - # 先在原始交易日历计算收益率 - returns_series = close_series.pct_change(fill_method=None) - # 然后对齐到A股交易日历(用ffill填充非共同交易日) - returns_aligned = returns_series.reindex(a_share_dates, method='ffill') + # 修复:先ffill价格对齐到A股日历,再计算收益率 + # 原因:若先pct_change再ffill,休市日会复制前一天的非零收益率 + # 正确做法:休市日价格不变 → 收益率应为0% + close_aligned = close_series.reindex(a_share_dates, method='ffill') + returns_aligned = close_aligned.pct_change(fill_method=None) returns_data[f'日收益率_{code}'] = returns_aligned returns_df = pd.DataFrame(returns_data)