feat: production paper trading platform

This commit is contained in:
Курнат Андрей
2026-07-14 22:52:47 +03:00
parent 7186acb9a1
commit 5c4aecfe5f
29 changed files with 396 additions and 564 deletions
+14 -3
View File
@@ -169,17 +169,23 @@ class Settings:
hold_signal_sample_seconds: int = 60
storage_retention_days: int = 30
storage_prune_interval_seconds: int = 3600
bybit_rest_base_url_override: str = ""
bybit_websocket_url_override: str = ""
@property
def rest_base_url(self) -> str:
return "https://api-testnet.bybit.com" if self.bybit_testnet else "https://api.bybit.com"
if self.bybit_rest_base_url_override:
return self.bybit_rest_base_url_override.rstrip("/")
return "https://api-testnet.bybit.com" if self.bybit_testnet else "https://api.bybit.kz"
@property
def websocket_url(self) -> str:
if self.bybit_websocket_url_override:
return self.bybit_websocket_url_override
return (
"wss://stream-testnet.bybit.com/v5/public/spot"
if self.bybit_testnet
else "wss://stream.bybit.com/v5/public/spot"
else "wss://stream.bybit.kz/v5/public/spot"
)
@property
@@ -220,7 +226,7 @@ def load_settings(env_file: str | Path | None = None) -> Settings:
strategy_mode = os.getenv("STRATEGY_MODE", "torch_forecast").strip().lower()
if strategy_mode not in STRATEGY_MODES:
raise ValueError("STRATEGY_MODE must be legacy, trend_macd or torch_forecast")
auto_select_symbols = _bool_env("AUTO_SELECT_SYMBOLS", False)
auto_select_symbols = _bool_env("AUTO_SELECT_SYMBOLS", True)
top_symbols_count = _int_env("TOP_SYMBOLS_COUNT", len(FIXED_SPOT_SYMBOLS))
requested_symbols = _symbols_env("SYMBOLS")
symbols = requested_symbols if requested_symbols else (() if auto_select_symbols else FIXED_SPOT_SYMBOLS)
@@ -343,6 +349,11 @@ def load_settings(env_file: str | Path | None = None) -> Settings:
hold_signal_sample_seconds=_int_env("HOLD_SIGNAL_SAMPLE_SECONDS", 60),
storage_retention_days=_int_env("STORAGE_RETENTION_DAYS", 30),
storage_prune_interval_seconds=_int_env("STORAGE_PRUNE_INTERVAL_SECONDS", 3600),
bybit_rest_base_url_override=os.getenv(
"BYBIT_REST_BASE_URL",
"" if _bool_env("BYBIT_TESTNET", False) else "https://api.bybit.kz",
).strip(),
bybit_websocket_url_override=os.getenv("BYBIT_WEBSOCKET_URL", "").strip(),
)
_validate_settings(settings)
if settings.trading_mode == "live" and not settings.live_ready: