fix(factor): 因子管线真数据跑通(注册因子 + close 时区 + 多 symbol + smoke 真断言)
端到端修复因子分析在真实 A 股数据上的多层问题: - __init__ 引入 library 触发 _register_all(ma5 等内置因子注册) - read_db_daily 用裸 symbol(600000 非 600000.SSE),匹配 DB 存储 - analyzer 单独读 close 价格 + tz_localize Asia/Shanghai 对齐 factor_df aware 日期 - smoke 用 >=2 symbol(alphalens IC 是横截面分析,单 symbol 分位为空 -> concat 报错) - smoke 真断言 IC 非空(杀掉之前的假阳性 PASS) - 修 status 引用未定义的 use_cumsum_fallback 验证:容器 smoke 6/6 PASS,real tears 出真 IC (ma5: 1D mean=-0.122/icir=-0.22, 5D mean=-0.276, 10D mean=-0.265, count=49) 容器 68 tests passed。
This commit is contained in:
@@ -251,11 +251,11 @@ async def test_real_factor_tears_pipeline():
|
||||
print(" === SKIP: database config not found ===")
|
||||
return
|
||||
|
||||
# Run on a SMALL real slice to avoid overwhelming the 2-core NAS
|
||||
symbols = ["600000.SSE"] # Just one symbol
|
||||
# ≥2 symbols: alphalens IC is cross-sectional (1 symbol → empty bins → fails)
|
||||
symbols = ["600000", "000001", "300750"] # BARE symbols (no .EXCHANGE suffix) for DB lookup
|
||||
factor_names = ["ma5"] # Simple factor
|
||||
start = "2024-01-01"
|
||||
end = "2024-01-31" # Just one month to reduce load
|
||||
end = "2024-06-30" # Use longer range for reliable IC (Phase 1 confirmed 541 bars)
|
||||
|
||||
print(f" Running factor analysis: {symbols}, {factor_names}, {start} to {end}")
|
||||
print(" This will test the multiprocessing pipeline...")
|
||||
@@ -278,6 +278,12 @@ async def test_real_factor_tears_pipeline():
|
||||
assert result is not None, "Result is None"
|
||||
assert len(result.factor_names) > 0, "No factors processed"
|
||||
|
||||
# CRITICAL: Verify IC is non-empty (Root cause C fix)
|
||||
assert result.ic_summary, "ic_summary empty - no IC computed"
|
||||
assert "ma5" in result.ic_summary, "ma5 not in ic_summary"
|
||||
assert result.ic_summary["ma5"].get("ic"), "no IC data for ma5"
|
||||
print(f" ✓ IC computed: {result.ic_summary['ma5']['ic']}")
|
||||
|
||||
# Check if any reports were generated
|
||||
if result.report_paths:
|
||||
print(f" Tears report generated: {result.report_paths}")
|
||||
|
||||
Reference in New Issue
Block a user