feat: refresh recommendation calibration from settled performance
All checks were successful
2026 World Cup Quant Platform - Production Deployment / Code Quality, Security Gate & Testing (push) Successful in 4m27s
2026 World Cup Quant Platform - Production Deployment / Deploy to Production VM via Gitea CD (push) Successful in 6m20s

This commit is contained in:
OG T
2026-06-19 00:14:07 +08:00
parent d9694b7dff
commit bd2fb5cc33
2 changed files with 158 additions and 4 deletions

View File

@@ -135,6 +135,27 @@ RECENT_MARKET_CALIBRATION: dict[str, dict[str, Any]] = {
},
}
_RUNTIME_MARKET_CALIBRATION: dict[str, dict[str, Any]] | None = None
def update_runtime_market_calibration(market_calibration: dict[str, dict[str, Any]] | None) -> None:
"""Update in-process market calibration from settled recommendation performance."""
global _RUNTIME_MARKET_CALIBRATION
if not market_calibration:
_RUNTIME_MARKET_CALIBRATION = None
return
cleaned: dict[str, dict[str, Any]] = {}
for market_type, calibration in market_calibration.items():
if not isinstance(calibration, dict):
continue
normalized_market = str(market_type or '').strip()
if not normalized_market:
continue
cleaned[normalized_market] = dict(calibration)
_RUNTIME_MARKET_CALIBRATION = cleaned or None
def _safe_float(value: Any, default: float = 0.0) -> float:
try:
@@ -546,10 +567,11 @@ def _recent_market_calibration(market_type: str) -> dict[str, Any] | None:
"""Return recent post-match market calibration for public recommendation safety."""
normalized_market = str(market_type or '').strip()
if normalized_market in RECENT_MARKET_CALIBRATION:
return RECENT_MARKET_CALIBRATION[normalized_market]
calibration_source = _RUNTIME_MARKET_CALIBRATION or RECENT_MARKET_CALIBRATION
if normalized_market in calibration_source:
return calibration_source[normalized_market]
if normalized_market.startswith('大小球 '):
return RECENT_MARKET_CALIBRATION.get(normalized_market)
return calibration_source.get(normalized_market)
return None