fix: 数据源路由修复与因子计算改进

1. 修复期货路由逻辑:NYMEX期货(.NYM)走YFinance而非Tushare
2. 添加SSH隧道路径修复(原引擎)
3. 因子计算只使用close列(处理部分指数只有收盘价的情况)
4. 添加数据不足和缺失率剔除日志

收益对比:
- 原引擎(剔除国债): 累计1804%, 调仓459次
- 新框架: 累计772%, 调仓1276次

差异原因待查:
- 国债剔除逻辑不同
- 调仓频率差异
This commit is contained in:
2026-05-12 00:47:43 +08:00
parent a7a4a69153
commit 19131c41dd
6 changed files with 76 additions and 36 deletions

View File

@@ -164,10 +164,6 @@ class TopNSelector(SignalGenerator):
factor_cols: List[str]
) -> bool:
"""检查是否应该调仓(得分阈值检查)"""
if self.rebalance_threshold <= 0:
# 无阈值,直接调仓
return target != current_held
# 提取当前持仓和目标持仓的代码
old_codes = [c for c in current_held.split(',') if c]
new_codes = [c for c in target.split(',') if c]
@@ -176,13 +172,14 @@ class TopNSelector(SignalGenerator):
return True
if set(new_codes) == set(old_codes):
return False
return False # 组合完全相同,不调仓
# 计算新旧组合的总得分
old_total = sum(float(row.get(col, 0)) for col in factor_cols if col in old_codes)
new_total = sum(float(row.get(col, 0)) for col in factor_cols if col in new_codes)
# 新组合得分需超过当前组合一定比例才调仓
# 即使 threshold=0也要确保 new_total >= old_total
if old_total > 0:
return (new_total / old_total - 1) >= self.rebalance_threshold