fix: 导出脚本因子前向填充对齐到展示日历
- 先定义 common_dates = equity_curve.index - 再执行 factor_df.reindex(common_dates, method='ffill') - 修复境外市场放假时动量显示为 None 的问题
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user