Keep bot operational when forecast model is unavailable
This commit is contained in:
@@ -334,6 +334,29 @@ def test_time_series_forecaster_uses_symbol_calibration(make_settings, tmp_path)
|
||||
assert forecast.calibrated_min_confidence == 0.45
|
||||
|
||||
|
||||
def test_time_series_forecaster_blocks_symbol_outside_train_only_allowlist(make_settings, tmp_path) -> None:
|
||||
artifact_path = tmp_path / "lstm_forecaster.json"
|
||||
_write_torch_gru_artifact(artifact_path, head_bias=0.2)
|
||||
(tmp_path / "torch_threshold_calibration.json").write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"validation": {"status": "pass", "passed": True},
|
||||
"eligible_symbols": ["ETHUSDT"],
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
settings = make_settings(tmp_path, time_series_lstm_model_path=artifact_path)
|
||||
|
||||
forecast = TimeSeriesForecaster(settings).forecast(
|
||||
_candles_from_returns([0.0001] * 140), symbol="BTCUSDT"
|
||||
)
|
||||
|
||||
assert forecast.usable is True
|
||||
assert forecast.block_entry is True
|
||||
assert forecast.reason == "symbol excluded by train-only calibration"
|
||||
|
||||
|
||||
def test_time_series_forecaster_averages_ensemble_members(make_settings, tmp_path) -> None:
|
||||
artifact_path = tmp_path / "lstm_forecaster.json"
|
||||
_write_torch_gru_artifact(artifact_path, head_bias=0.9)
|
||||
@@ -343,6 +366,9 @@ def test_time_series_forecaster_averages_ensemble_members(make_settings, tmp_pat
|
||||
{"state_dict": entry["state_dict"], "head_weight": [0.0, 0.0], "head_bias": bias}
|
||||
for bias in (0.1, 0.3)
|
||||
]
|
||||
entry.pop("state_dict")
|
||||
entry.pop("head_weight")
|
||||
entry.pop("head_bias")
|
||||
artifact_path.write_text(json.dumps(artifact), encoding="utf-8")
|
||||
settings = make_settings(
|
||||
tmp_path,
|
||||
|
||||
Reference in New Issue
Block a user