510f77e6ea
- BacktestResult 加 id;save_result 设 result.id=lastrowid(修 get_result bug) - runner._on_done 用 result.id(getattr 兜底 FactorReport) - cta_engine 构建 equity_curve/trades DataFrame;save 传 file_dir - result_store parquet→JSON(去 pyarrow 依赖,本机/容器都稳) - 16 tests passed
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
"""Diagnostic: confirm multi-symbol factor analysis produces real IC on real data.
|
|
Guarded entry for spawn-friendly multiprocessing. Throwaway."""
|
|
import sys
|
|
import os
|
|
import traceback
|
|
|
|
_VNPY_SRC = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "vnpy_v4.4.0"))
|
|
_REPO = os.path.dirname(_VNPY_SRC)
|
|
for _p in (_REPO, _VNPY_SRC):
|
|
if _p not in sys.path:
|
|
sys.path.insert(0, _p)
|
|
|
|
|
|
def main():
|
|
import sanguo_factor # registers built-in factors
|
|
from sanguo_factor.registry import get_factor
|
|
from sanguo_factor.analyzer import run_factor_analysis
|
|
from sanguo_data.config import load_config
|
|
|
|
print("ma5 registered:", get_factor("ma5") is not None)
|
|
cfg = load_config("/app/config/data_platform.yaml")
|
|
symbols = ["600000", "000001", "300750"] # multi-symbol for cross-section
|
|
print(f"symbols={symbols} range=2024-01-01..2024-06-30")
|
|
try:
|
|
report = run_factor_analysis(
|
|
symbols, ["ma5"], "2024-01-01", "2024-06-30", cfg,
|
|
output_dir="/tmp/diag_factor",
|
|
)
|
|
print("=== ic_summary ===")
|
|
print(report.ic_summary)
|
|
print("=== report_paths ===")
|
|
print(report.report_paths)
|
|
except Exception:
|
|
traceback.print_exc()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|