feat(lotto): calibrate_winner + backfill (멱등·청크)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -65,6 +65,31 @@ def test_winner_calibration_upsert(monkeypatch):
|
||||
assert row["score_total"] == 2.00
|
||||
|
||||
|
||||
def _seed_draws(db, n=40):
|
||||
rows = []
|
||||
import random as _r; _r.seed(2)
|
||||
for i in range(1, n + 1):
|
||||
s = sorted(_r.sample(range(1, 46), 6))
|
||||
rows.append({"drw_no": i, "drw_date": f"2020-01-{(i%28)+1:02d}",
|
||||
"n1": s[0], "n2": s[1], "n3": s[2], "n4": s[3],
|
||||
"n5": s[4], "n6": s[5], "bonus": ((s[5] % 45) + 1)})
|
||||
db.upsert_many_draws(rows)
|
||||
|
||||
def test_backfill_calibration_idempotent(monkeypatch):
|
||||
db = _fresh_db(monkeypatch)
|
||||
_seed_draws(db, 40)
|
||||
from app import backtest as bt
|
||||
r1 = bt.backfill_calibration(batch=15, sample_m=200)
|
||||
# 첫 회차는 point-in-time 데이터가 빈약 → min_history 이후만 처리
|
||||
done1 = len(db.get_calibrated_draw_nos())
|
||||
assert done1 > 0
|
||||
r2 = bt.backfill_calibration(batch=100, sample_m=200) # 나머지
|
||||
done2 = len(db.get_calibrated_draw_nos())
|
||||
assert done2 >= done1
|
||||
r3 = bt.backfill_calibration(batch=100, sample_m=200) # 재실행 → 추가 0
|
||||
assert r3["calibrated"] == 0
|
||||
|
||||
|
||||
def test_get_calibrated_draw_nos(monkeypatch):
|
||||
"""저장된 draw_no 집합이 get_calibrated_draw_nos에 포함되어야 한다."""
|
||||
db = _fresh_db(monkeypatch)
|
||||
|
||||
Reference in New Issue
Block a user