vv
Deploy Iddaai Backend / build-and-deploy (push) Successful in 1m7s

This commit is contained in:
2026-06-02 03:37:00 +03:00
parent 671979b07d
commit 4e563e996e
10 changed files with 708 additions and 0 deletions
@@ -86,6 +86,28 @@ POST_CAL_TRUST: Dict[str, float] = {
class MarketBoardMixin:
def _league_confidence_for(self, league_id: Optional[str]) -> Optional[Dict[str, Any]]:
"""Return the backtest-derived confidence record for a league, or None.
Shape: {"label": high|medium|low, "bet_roi": float, "bet_n": int,
"hit": float}. None → league absent or too few bets ('unknown') → FE
shows no badge. Never raises (missing artifact = graceful None)."""
if not league_id:
return None
lookup = getattr(self, "league_confidence", None) or {}
info = lookup.get(str(league_id))
if not isinstance(info, dict):
return None
label = info.get("label")
if label in (None, "unknown"):
return None
return {
"label": label,
"bet_roi": info.get("bet_roi"),
"bet_n": info.get("bet_n"),
"hit": info.get("hit"),
}
def _build_prediction_package(
self,
data: MatchData,
@@ -320,6 +342,10 @@ class MarketBoardMixin:
"home_team": data.home_team_name,
"away_team": data.away_team_name,
"league": data.league_name,
"league_id": data.league_id,
# Backtest-derived per-league confidence (ROI + sample size).
# None when the league has too little data to judge → FE shows no badge.
"league_confidence": self._league_confidence_for(data.league_id),
"match_date_ms": data.match_date_ms,
"sport": data.sport,
# Live snapshot — match_commentary uses this to detect upset-in-progress