From d3226ebe711927c16abcc5331daf02291f15ac6b Mon Sep 17 00:00:00 2001 From: claude_dev Date: Tue, 25 Aug 2026 00:25:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(factor):=20=E6=89=B9=E9=87=8F=E8=AF=84?= =?UTF-8?q?=E4=BC=B0=E7=A9=BA=E5=9B=A0=E5=AD=90=E7=9F=A9=E9=98=B5=E5=AE=88?= =?UTF-8?q?=E5=8D=AB=E2=80=94=E2=80=94join=E9=9D=99=E9=BB=98=E7=A9=BA?= =?UTF-8?q?=E9=9B=86=E8=AE=B0error=E8=A1=8C=E4=B8=8D=E5=86=8D=E4=BA=A7?= =?UTF-8?q?=E5=85=A8None=E6=B7=98=E6=B1=B0=E5=81=87=E6=95=B0=E6=8D=AE=20[v?= =?UTF-8?q?ps]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sanguo_factor/batch_eval.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sanguo_factor/batch_eval.py b/sanguo_factor/batch_eval.py index 0fb3790..8a7a110 100644 --- a/sanguo_factor/batch_eval.py +++ b/sanguo_factor/batch_eval.py @@ -72,7 +72,7 @@ def run_batch_eval( run_id = eval_store.create_run( eval_db, label=label, universe=universe_label, symbols_count=bars["vt_symbol"].n_unique(), factors_total=len(factor_names), - start=start, end=end, params={"limit": limit, "symbols": symbols[:20] if symbols else None}, + start=start, end=end, params={"limit": limit, "symbols": symbols[:20] if symbols else None}, # 截断防 4400 只全量塞 JSON ) errors: list[str] = [] @@ -115,6 +115,10 @@ def _eval_one(name: str, alpha_df: pl.DataFrame, eval_rows: pl.DataFrame, .sort("datetime").to_pandas().set_index("datetime") ) F.index = pd.to_datetime(F.index) + if F.empty or len(F.index) == 0: + return {"factor": name, "category": factor["category"], + "expression": factor["expression"], + "metrics": {"error": "因子矩阵为空(join 后无评估窗行,检查 datetime dtype/窗口)"}} metrics = summarize_factor(F, rets[1], rets[5], rets[10]) return {"factor": name, "category": factor["category"], "expression": factor["expression"], "metrics": metrics}