로또 프리미엄 Phase 1 — 추천 성과 통계 + 회차 공략 리포트 API
- GET /api/lotto/stats/performance: 채점 이력 기반 성과 통계
(평균 일치 수, 등수 분포, 무작위 대비 개선율)
- GET /api/lotto/report/latest: 다음 회차 공략 리포트 자동 생성
- GET /api/lotto/report/{drw_no}: 특정 회차 공략 리포트
(과출현/냉각/오버듀 번호, 최근 패턴, 3가지 전략 추천, 신뢰도 점수)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,13 +20,15 @@ from .db import (
|
||||
get_all_subscription_items, create_subscription_item,
|
||||
update_subscription_item, delete_subscription_item,
|
||||
get_subscription_profile, upsert_subscription_profile,
|
||||
# 성과 통계
|
||||
get_recommendation_performance,
|
||||
)
|
||||
from .recommender import recommend_numbers, recommend_with_heatmap
|
||||
from .collector import sync_latest, sync_ensure_all
|
||||
from .generator import run_simulation, generate_smart_recommendations
|
||||
from .checker import check_results_for_draw
|
||||
from .utils import calc_metrics, calc_recent_overlap
|
||||
from .analyzer import get_statistical_report
|
||||
from .analyzer import get_statistical_report, generate_weekly_report
|
||||
|
||||
app = FastAPI()
|
||||
scheduler = BackgroundScheduler(timezone=os.getenv("TZ", "Asia/Seoul"))
|
||||
@@ -148,6 +150,51 @@ def api_stats():
|
||||
}
|
||||
|
||||
|
||||
# ── 추천 성과 통계 (Phase 1) ─────────────────────────────────────────────────
|
||||
@app.get("/api/lotto/stats/performance")
|
||||
def api_performance_stats():
|
||||
"""
|
||||
채점된 추천 이력 기반 성과 통계.
|
||||
- 평균 일치 개수, 분포, 등수별 현황
|
||||
- 무작위 대비 개선율 (이론 기댓값 0.8개 기준)
|
||||
"""
|
||||
return get_recommendation_performance()
|
||||
|
||||
|
||||
# ── 회차 공략 리포트 (Phase 1) ────────────────────────────────────────────────
|
||||
@app.get("/api/lotto/report/latest")
|
||||
def api_report_latest():
|
||||
"""
|
||||
다음 회차 공략 리포트 (최신 회차 기준으로 자동 계산).
|
||||
- 과출현/냉각/오버듀 번호 분석
|
||||
- 최근 3회 패턴
|
||||
- 3가지 전략별 추천 번호
|
||||
- AI 신뢰도 점수
|
||||
"""
|
||||
draws = get_all_draw_numbers()
|
||||
if not draws:
|
||||
raise HTTPException(status_code=404, detail="No data yet")
|
||||
latest = get_latest_draw()
|
||||
target = latest["drw_no"] + 1
|
||||
return generate_weekly_report(draws, target)
|
||||
|
||||
|
||||
@app.get("/api/lotto/report/{drw_no}")
|
||||
def api_report_by_draw(drw_no: int):
|
||||
"""
|
||||
특정 회차 공략 리포트 (해당 회차 이전 데이터 기준).
|
||||
drw_no: 공략 대상 회차 번호
|
||||
"""
|
||||
draws = get_all_draw_numbers()
|
||||
if not draws:
|
||||
raise HTTPException(status_code=404, detail="No data yet")
|
||||
# drw_no 이전 데이터만 사용
|
||||
base_draws = [(no, nums) for no, nums in draws if no < drw_no]
|
||||
if not base_draws:
|
||||
raise HTTPException(status_code=400, detail=f"{drw_no}회차 이전 데이터가 없습니다")
|
||||
return generate_weekly_report(base_draws, drw_no)
|
||||
|
||||
|
||||
# ── 통계 분석 리포트 ────────────────────────────────────────────────────────
|
||||
@app.get("/api/lotto/analysis")
|
||||
def api_analysis():
|
||||
|
||||
Reference in New Issue
Block a user