fix: calibrate dynamic model symbols

This commit is contained in:
Курнат Андрей
2026-07-14 23:28:53 +03:00
parent 1c7701c38e
commit 51a7833896
2 changed files with 41 additions and 4 deletions
+16
View File
@@ -8,6 +8,7 @@ from tools.calibrate_torch_thresholds import (
_average_selected_predictions,
_apply_platt_calibration,
_build_torch_model,
_calibration_symbols,
_choose_recommendation,
_full_backtest,
_fit_platt_calibration,
@@ -62,6 +63,21 @@ def _record(index: int, probability: float, future: float) -> ForecastRecord:
)
def test_calibration_symbols_follow_explicit_configured_artifact_precedence() -> None:
artifact = {"symbols": {"btcusdt": {}, "ethusdt": {}}}
assert _calibration_symbols("solusdt, xrpusdt", ("ADAUSDT",), artifact) == [
"SOLUSDT",
"XRPUSDT",
]
assert _calibration_symbols("", ("ADAUSDT",), artifact) == ["ADAUSDT"]
assert _calibration_symbols("", (), artifact) == ["BTCUSDT", "ETHUSDT"]
def test_calibration_symbols_reject_malformed_artifact_symbols() -> None:
assert _calibration_symbols("", (), {"symbols": []}) == []
def test_calibration_does_not_fallback_to_too_few_trades() -> None:
selected = _choose_recommendation(
[_result(trades=1, average=2.0, total=2.0, profit_factor=999.0)],