feat: refresh recommendation calibration from settled performance
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user