diff --git a/core/engine.py b/core/engine.py index 5e3ef82..9498c64 100644 --- a/core/engine.py +++ b/core/engine.py @@ -964,7 +964,9 @@ class TradingEngine: if bal <= 0: return ps = self.trader.snapshot() - open_pnl = float(ps.get("pnl") or 0.0) + # ⚠ BEIDE Slots — s. Begruendung im Snapshot-Block. + ps_brk = self.trader_brk.snapshot() or {} + open_pnl = float(ps.get("pnl") or 0.0) + float(ps_brk.get("pnl") or 0.0) day_total = self._day_realized_cached() + open_pnl limit_eur = self._cb_limit_pct / 100.0 * bal if day_total > -limit_eur: @@ -978,6 +980,15 @@ class TradingEngine: tg_on = (tg.get("enabled", "false").lower() == "true" and tg.get("bot_token")) if ps.get("ticket"): err = self.trader.close(reason="circuit_breaker") + # ⚠ Der zweite Slot MUSS mit — eine Notbremse, die nur die Haelfte + # schliesst, ist keine. + if ps_brk.get("ticket"): + try: + e2 = self.trader_brk.close(reason="circuit_breaker") + if e2: + log.warning(f"Circuit-Breaker: BRK-Slot nicht geschlossen — {e2}") + except Exception as ce: + log.warning(f"Circuit-Breaker BRK-Close: {ce}") if err: log.error(f"Circuit-Breaker-Close fehlgeschlagen: {err}") if tg_on: @@ -4381,7 +4392,16 @@ class TradingEngine: .get("total_pnl") or 0.0) except Exception as e: log.warning(f"day stats: {e}"); day_realized = 0.0 + # ⚠⚠ BEIDE Slots summieren (Zwei-Slot-Umbau 2026-08-19). Wuerde hier + # nur der erste stehen, saehe der Tages-P&L eine offene BRK-Position + # nicht — und der Circuit-Breaker griffe zu spaet, also genau dann + # nicht, wenn zwei Positionen gleichzeitig laufen und das Risiko + # doppelt ist. open_pnl = float(position.get("pnl") or 0.0) + try: + open_pnl += float((self.trader_brk.snapshot() or {}).get("pnl") or 0.0) + except Exception: + pass day_pl = {"realized": round(day_realized, 2), "open": round(open_pnl, 2), "total": round(day_realized + open_pnl, 2)} # Circuit Breaker — Status für die UI (Tagesverlust-Stopp)