fix: retry с backoff на сетевые ошибки Bybit + top-level crash guard

- exchange: timeout 10s→30s, retry 3x с backoff [2,4,8]s на NetworkError
  для fetch_candles, load_markets, get_balance, get_price, get_position
- executor: run_cycle обёрнут в try/except — цикл никогда не крашит APScheduler
- Только сетевые ошибки ретраятся (ccxt.NetworkError, RequestTimeout,
  ExchangeNotAvailable), auth/perm ошибки пробрасываются сразу

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
anor
2026-03-13 23:53:25 +10:00
co-authored by Claude Opus 4.6
parent 4b9f3e0365
commit 0e06427648
2 changed files with 114 additions and 37 deletions
+9
View File
@@ -90,6 +90,15 @@ def _risk_pct(t: Trade) -> float:
def run_cycle(conn: sqlite3.Connection, cfg: Config) -> list[str]:
"""Run one trading cycle for all symbols. Returns list of log messages."""
try:
return _run_cycle_inner(conn, cfg)
except Exception as e:
log.error("Cycle crashed: %s", e, exc_info=True)
return [f"CYCLE ERROR: {e}"]
def _run_cycle_inner(conn: sqlite3.Connection, cfg: Config) -> list[str]:
"""Inner cycle logic — wrapped by run_cycle for safety."""
global _sessions, _session_date
logs: list[str] = []
now_utc = datetime.now(timezone.utc)