Commit Graph
3 Commits
Author SHA1 Message Date
anorandClaude Opus 4.6 12d28d6617 refactor: exchange as source of truth вместо DB-first reconcile
Бот теперь спрашивает биржу "что открыто?" перед каждым решением.
DB → журнал для trailing state, а не source of truth.

- _get_exchange_position: получает позицию с биржи (futures/spot/paper)
- _adopt_orphan: биржа имеет, DB нет → создаёт запись (только futures)
- _close_phantom: DB имеет, биржа нет → закрывает с Bybit PnL
- _sync_position_size: синхронизирует size при расхождении >2%
- _inline_reconcile: оркестрирует три предыдущие функции
- run_cycle/update_stops: exchange-first → inline reconcile → решения
- Удалён reconcile_positions (логика встроена в основной flow)
- 8 новых тестов, все 55 проходят

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 18:21:44 +10:00
anorandClaude Opus 4.6 bcf3c2a4ec fix: safety stop как SL на позиции (set_trading_stop) вместо отдельного ордера
- place_safety_stop теперь использует set_trading_stop — SL привязан
  к позиции, переживает рестарт бота, не осиротеет
- Не нужен cancel_order для futures — set_trading_stop перезаписывает
- Для spot оставлен старый подход (отдельный conditional order)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 04:48:57 +10:00
anorandClaude Opus 4.6 0b2602600e feat: futures long+short 1x 1h — FuturesExecutor, routing, time_exit в барах
- Новый FuturesExecutor (ccxt bybit linear): open_long/short, close_position,
  place_safety_stop с side, ensure_leverage (cached)
- Config: market_type, retrain_enabled, is_futures(), commission_for()
- Executor: routing spot/futures, SHORT разрешён для futures,
  time_exit в барах (не днях), commission по типу рынка
- Notify: USDT balance, skip futures в coin positions, dynamic timeframe
- Config.yaml: UNI+ATOM+SUI futures 1h, mode=paper
- 26 новых тестов (всего 97)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 03:55:17 +10:00