Use Torch forecast as primary strategy

This commit is contained in:
Codex
2026-06-22 05:21:05 +03:00
parent 85fecbfc36
commit 544b0f4409
9 changed files with 374 additions and 20 deletions
+15 -7
View File
@@ -6,7 +6,7 @@ from pathlib import Path
FIXED_SPOT_SYMBOLS = ("BTCUSDT", "ETHUSDT", "SOLUSDT")
STRATEGY_MODES = {"legacy", "trend_macd"}
STRATEGY_MODES = {"legacy", "trend_macd", "torch_forecast"}
def _load_dotenv(path: Path) -> None:
@@ -174,9 +174,17 @@ def load_settings(env_file: str | Path | None = None) -> Settings:
mode = os.getenv("TRADING_MODE", "paper").strip().lower()
if mode not in {"paper", "live"}:
raise ValueError("TRADING_MODE must be paper or live")
strategy_mode = os.getenv("STRATEGY_MODE", "trend_macd").strip().lower()
strategy_mode = os.getenv("STRATEGY_MODE", "torch_forecast").strip().lower()
if strategy_mode not in STRATEGY_MODES:
raise ValueError("STRATEGY_MODE must be legacy or trend_macd")
raise ValueError("STRATEGY_MODE must be legacy, trend_macd or torch_forecast")
auto_select_symbols = _bool_env("AUTO_SELECT_SYMBOLS", False)
top_symbols_count = _int_env("TOP_SYMBOLS_COUNT", len(FIXED_SPOT_SYMBOLS))
symbols = _symbols_env("SYMBOLS") or FIXED_SPOT_SYMBOLS
if strategy_mode == "torch_forecast":
auto_select_symbols = False
top_symbols_count = len(FIXED_SPOT_SYMBOLS)
symbols = FIXED_SPOT_SYMBOLS
forecast_enabled_default = strategy_mode == "torch_forecast"
settings = Settings(
trading_mode=mode,
host=os.getenv("HOST", "127.0.0.1"),
@@ -185,9 +193,9 @@ def load_settings(env_file: str | Path | None = None) -> Settings:
bybit_api_key=os.getenv("BYBIT_API_KEY", ""),
bybit_api_secret=os.getenv("BYBIT_API_SECRET", ""),
starting_balance_usdt=_float_env("STARTING_BALANCE_USDT", 100.0),
auto_select_symbols=_bool_env("AUTO_SELECT_SYMBOLS", False),
top_symbols_count=_int_env("TOP_SYMBOLS_COUNT", len(FIXED_SPOT_SYMBOLS)),
symbols=_symbols_env("SYMBOLS") or FIXED_SPOT_SYMBOLS,
auto_select_symbols=auto_select_symbols,
top_symbols_count=top_symbols_count,
symbols=symbols,
strategy_mode=strategy_mode,
base_interval=os.getenv("BASE_INTERVAL", "60"),
kline_limit=_int_env("KLINE_LIMIT", 240),
@@ -236,7 +244,7 @@ def load_settings(env_file: str | Path | None = None) -> Settings:
atr_trailing_multiplier=_float_env("ATR_TRAILING_MULTIPLIER", 2.2),
trend_rsi_min=_float_env("TREND_RSI_MIN", 45.0),
trend_rsi_max=_float_env("TREND_RSI_MAX", 65.0),
time_series_forecast_enabled=_bool_env("TIME_SERIES_FORECAST_ENABLED", False),
time_series_forecast_enabled=_bool_env("TIME_SERIES_FORECAST_ENABLED", forecast_enabled_default),
time_series_min_candles=_int_env("TIME_SERIES_MIN_CANDLES", 120),
time_series_forecast_horizon=_int_env("TIME_SERIES_FORECAST_HORIZON", 3),
time_series_min_edge_percent=_float_env("TIME_SERIES_MIN_EDGE_PERCENT", 0.04),