feat(lotto): backtest API 라우터 + main 등록

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 17:20:32 +09:00
parent a425bb8809
commit 3bc4f423db
3 changed files with 55 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
from fastapi import APIRouter, BackgroundTasks, Query
from .. import backtest, db
router = APIRouter(prefix="/api/lotto/backtest", tags=["backtest"])
@router.get("/track-record")
def track_record():
return backtest.track_record()
@router.get("/calibration")
def calibration(weeks: int = Query(52, ge=1, le=520)):
return {"history": db.get_calibration_history(limit=weeks)}
@router.get("/review/{draw_no}")
def review(draw_no: int):
return backtest.build_review_payload(draw_no)
@router.post("/run-forward")
def run_forward(draw_no: int = Query(...), k: int = 5000, pool_n: int = 20000):
return backtest.run_forward_purchase(draw_no=draw_no, k=k, pool_n=pool_n)
@router.post("/backfill")
def backfill(background_tasks: BackgroundTasks, batch: int = 50, sample_m: int = 2000):
background_tasks.add_task(backtest.backfill_calibration, batch, sample_m)
return {"ok": True, "message": f"backfill 시작 (batch={batch})"}