Use Torch as the only forecast model

This commit is contained in:
Codex
2026-06-21 08:37:09 +03:00
parent 25651d7fa7
commit f19856ca6e
7 changed files with 129 additions and 278 deletions
+10 -16
View File
@@ -215,9 +215,7 @@ def _safe_config(settings: Settings) -> dict[str, Any]:
"kelly_max_fraction": settings.kelly_max_fraction,
"time_series_forecast_enabled": settings.time_series_forecast_enabled,
"time_series_min_candles": settings.time_series_min_candles,
"time_series_validation_window": settings.time_series_validation_window,
"time_series_forecast_horizon": settings.time_series_forecast_horizon,
"time_series_ewma_lambda": settings.time_series_ewma_lambda,
"time_series_min_edge_percent": settings.time_series_min_edge_percent,
"time_series_max_adjustment": settings.time_series_max_adjustment,
"time_series_lstm_enabled": settings.time_series_lstm_enabled,
@@ -257,16 +255,19 @@ def _time_series_model_artifact(settings: Settings) -> dict[str, Any]:
"symbol_count": 0,
"models": [],
}
artifact_type = str(data.get("type", "")).strip()
symbols = data.get("symbols")
rows = list(symbols.values()) if isinstance(symbols, dict) else []
models = sorted(
{
_forecast_model_label(str(row.get("model", row.get("architecture", "lstm"))))
_forecast_model_label(
str(row.get("model", row.get("architecture", "lstm"))),
torch_artifact=artifact_type == "pytorch_recurrent_forecaster",
)
for row in rows
if isinstance(row, dict)
}
)
artifact_type = str(data.get("type", "")).strip()
if artifact_type != "pytorch_recurrent_forecaster":
return {
"available": False,
@@ -286,16 +287,16 @@ def _time_series_model_artifact(settings: Settings) -> dict[str, Any]:
}
def _forecast_model_label(model: str) -> str:
def _forecast_model_label(model: str, *, torch_artifact: bool = False) -> str:
normalized = model.strip().lower()
if normalized == "torch_lstm":
if normalized in {"torch_lstm", "lstm"} and torch_artifact:
return "PyTorch LSTM"
if normalized == "torch_gru":
if normalized in {"torch_gru", "gru"} and torch_artifact:
return "PyTorch GRU"
if normalized == "lstm":
return "устаревший LSTM"
return "устаревший артефакт"
if normalized == "gru":
return "GRU"
return "устаревший артефакт"
return model
@@ -746,12 +747,6 @@ HTML = r"""
const names = {
torch_lstm: 'PyTorch LSTM',
torch_gru: 'PyTorch GRU',
lstm: 'Устаревший LSTM',
naive: 'Baseline',
drift: 'Drift',
ewma: 'EWMA',
ar1: 'AR(1)',
ar3: 'AR(3)',
none: '-'
};
return names[key] || String(model || '-');
@@ -937,7 +932,6 @@ HTML = r"""
['Kelly размер', `${yesNo(config.kelly_sizing_enabled)} · ${num(config.kelly_fraction, 2)}x · max ${num((config.kelly_max_fraction || 0) * 100, 1)}%`],
['Прогноз временных рядов', yesNo(config.time_series_forecast_enabled)],
['Модельный горизонт', `${config.time_series_forecast_horizon} свечи`],
['Walk-forward окно', `${config.time_series_validation_window} свечей`],
['Мин. edge прогноза', `${num(config.time_series_min_edge_percent, 3)}%`],
['Нейропрогноз', modelArtifactSummary(config)],
['Файл модели', config.time_series_lstm_model_path || '-'],