fix: max_trades=99, leverage per symbol, crash recovery, test_live.py

- max_trades=99 в config/backtest — стратегия находит ВСЕ входы,
  лимит позиций контролирует executor (Phase 2)
- leverage setup per symbol (set[str] вместо bool)
- crash recovery: get_today_trade_keys() восстанавливает last_trade_ids
- flash trade exit по new_positions[-1] (slippage-safe)
- last_trade_ids.add() только в Phase 2 для исполненных трейдов
- test_live.py: cfg.strategy → per-symbol strat_cfg
- backtest_wf: risk 5%, max_trades=[99]
- cli daemon: per-symbol params display

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
anor
2026-03-13 18:46:28 +10:00
co-authored by Claude Opus 4.6
parent e2d2dcbc4b
commit 650ab61168
7 changed files with 56 additions and 36 deletions
+11
View File
@@ -179,6 +179,17 @@ def get_today_trade_count(conn: sqlite3.Connection, dt: date) -> int:
return row["cnt"] if row else 0
def get_today_trade_keys(conn: sqlite3.Connection, dt: date,
symbol: str) -> set[str]:
"""Get trade keys for today's positions (for crash recovery)."""
rows = conn.execute(
"SELECT direction, entry_price, stop_price FROM positions "
"WHERE date=? AND symbol=?", (str(dt), symbol)
).fetchall()
return {f"{r['direction']}_{r['entry_price']:.2f}_{r['stop_price']:.2f}"
for r in rows}
def get_trade_history(conn: sqlite3.Connection, limit: int = 50) -> list[dict]:
rows = conn.execute(
"SELECT * FROM positions WHERE status='closed' ORDER BY id DESC LIMIT ?",