Harden trading, training, and monitoring

This commit is contained in:
Codex
2026-07-10 15:51:53 +03:00
parent 6fb79ee2a9
commit 069d75d2f2
55 changed files with 2658 additions and 2332049 deletions
+43 -1
View File
@@ -678,7 +678,20 @@ def _torch_forecast_entry_signal(
spread_ok = ticker.spread_percent <= settings.max_spread_percent
liquidity_ok = ticker.turnover_24h >= settings.min_24h_turnover_usdt
model_ok = _is_torch_forecast(forecast)
quality_gate_ok = forecast.get("quality_gate_passed") is not False
manual_quality_override = settings.time_series_manual_quality_override
quality_gate_ok = bool(
manual_quality_override
or (
forecast.get("quality_gate_passed") is True
if settings.time_series_require_quality_gate
else forecast.get("quality_gate_passed") is not False
)
)
model_fresh_ok = (
forecast.get("model_fresh") is True
if settings.time_series_require_fresh_model
else True
)
rebound = _torch_rebound_overlay(
settings=settings,
candles=candles or [],
@@ -697,6 +710,7 @@ def _torch_forecast_entry_signal(
rebound.get("active")
and model_ok
and quality_gate_ok
and model_fresh_ok
and bool(forecast.get("usable", False))
and not bool(forecast.get("block_entry", False))
and expected_return >= 0.0
@@ -709,6 +723,7 @@ def _torch_forecast_entry_signal(
and rebound.get("active")
and missing_torch_model
and quality_gate_ok
and model_fresh_ok
and not bool(forecast.get("block_entry", False))
and confidence >= settings.time_series_min_confidence
)
@@ -733,6 +748,7 @@ def _torch_forecast_entry_signal(
checks = {
"torch_model_ok": model_ok,
"quality_gate_ok": quality_gate_ok,
"model_fresh_ok": model_fresh_ok,
"forecast_usable": bool(forecast.get("usable", False)),
"forecast_not_blocked": not bool(forecast.get("block_entry", False)),
"expected_edge_ok": full_edge_ok or probe_edge_ok,
@@ -770,6 +786,10 @@ def _torch_forecast_entry_signal(
"skill": skill,
"quality_gate": forecast.get("quality_gate", {}),
"quality_gate_passed": forecast.get("quality_gate_passed"),
"manual_quality_override": manual_quality_override,
"model_created_at": forecast.get("model_created_at", ""),
"model_age_hours": forecast.get("model_age_hours"),
"model_fresh": forecast.get("model_fresh", False),
"spread_percent": round(ticker.spread_percent, 5),
"turnover_24h": ticker.turnover_24h,
"checks": checks,
@@ -926,6 +946,28 @@ def _torch_forecast_exit_signal(
diagnostics,
)
return Signal(position.symbol, "SELL", 0.94, "torch_forecast: ATR trailing stop hit", diagnostics)
if (
settings.time_series_require_quality_gate
and not settings.time_series_manual_quality_override
and forecast.get("quality_gate_passed") is not True
):
diagnostics["forecast_exit_blocked_by_quality_gate"] = True
return Signal(
position.symbol,
"HOLD",
0.42,
"torch_forecast: hold uses only risk exits while quality gate is unavailable",
diagnostics,
)
if settings.time_series_require_fresh_model and forecast.get("model_fresh") is not True:
diagnostics["forecast_exit_blocked_by_model_age"] = True
return Signal(
position.symbol,
"HOLD",
0.42,
"torch_forecast: hold uses only risk exits while model is stale",
diagnostics,
)
if not _is_torch_forecast(forecast):
if rebound_fallback_position:
hold_seconds = (utc_now() - position.opened_at).total_seconds()