From ec5483041ab5f1f245fe1b92a075c904c57c679c Mon Sep 17 00:00:00 2001 From: mindesbunister Date: Sat, 15 Nov 2025 11:28:54 +0100 Subject: [PATCH] fix(CRITICAL): Add missing stop loss check for runner between TP1 and TP2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CRITICAL BUG: Runner had NO stop loss protection between TP1 and TP2! Impact: Runner position completely unprotected for entire TP1→TP2 window Risk: Unlimited loss exposure on 25-30% remaining position Example: SHORT at $141.31, TP1 closed 70% at $140.94, runner has SL at $140.89 - Price rises to $141.98 (way above SL) → NO STOP LOSS CHECK → Losses accumulate - Should have closed at $140.89 with 0.3% profit locked Fix: Added explicit stop loss check for runner state (TP1 hit but TP2 not hit) Log: "🔴 RUNNER STOP LOSS" to distinguish from pre-TP1 stops Files: lib/trading/position-manager.ts --- lib/trading/position-manager.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/trading/position-manager.ts b/lib/trading/position-manager.ts index 132401a..9edebe8 100644 --- a/lib/trading/position-manager.ts +++ b/lib/trading/position-manager.ts @@ -792,6 +792,13 @@ export class PositionManager { await this.saveTradeState(trade) } + // CRITICAL: Check stop loss for runner (after TP1, before TP2) + if (trade.tp1Hit && !trade.tp2Hit && this.shouldStopLoss(currentPrice, trade)) { + console.log(`🔴 RUNNER STOP LOSS: ${trade.symbol} at ${profitPercent.toFixed(2)}% (profit lock triggered)`) + await this.executeExit(trade, 100, 'SL', currentPrice) + return + } + // 5. Take profit 2 (remaining position) if (trade.tp1Hit && !trade.tp2Hit && this.shouldTakeProfit2(currentPrice, trade)) { console.log(`🎊 TP2 HIT: ${trade.symbol} at ${profitPercent.toFixed(2)}%`)