fix:批量修复了一些问题

This commit is contained in:
shangfangjian
2026-09-19 22:51:35 +08:00
parent 835d7217d0
commit 8e6ad5394e
44 changed files with 4921 additions and 395 deletions
+9 -5
View File
@@ -28,13 +28,16 @@ async def backtest(req: BacktestRequest):
"""对历史比赛运行回测。
该接口会对每场已完赛比赛各发起一次 LLM 预测,成本高 —— 因此需要
`X-API-Key` 鉴权(见审查报告 P2-7)。
管理员鉴权(require_admin)。
对每场已完赛比赛:
1. 用比赛之前的数据构建上下文 (防未来信息泄漏)
2. 调 LLM 预测
3. 用实际比分回填
1. 用比赛之前的数据构建上下文 (防未来信息泄漏,cutoff=match_date-1天)
2. 调 LLM 预测(强制 use_cache=False,避免缓存命中导致反复 settle 同一行)
3. 用实际比分回填(settle)
4. 统计准确率 / RMSE / 校准度
限流:单请求上限 200 场(默认 20),避免一次打爆 LLM 额度。
回测写入 run_type='backtest',与实盘(live)互不覆盖(唯一键含 run_type)。
"""
try:
summary = await run_backtest(
@@ -53,10 +56,11 @@ async def backtest(req: BacktestRequest):
"summary": {
"total": summary.total,
"scored": summary.scored,
"success": summary.success,
"degraded": summary.degraded,
"accuracy_1x2": summary.accuracy_1x2,
"avg_score_rmse": summary.avg_score_rmse,
"avg_subjective_confidence": summary.avg_subjective_confidence,
"calibration": summary.calibration,
},
"results": [
{