fix(CRITICAL): Add missing stop loss check for runner between TP1 and TP2

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
This commit is contained in:
mindesbunister
2025-11-15 11:28:54 +01:00
parent 5fa946acbd
commit ec5483041a

View File

@@ -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)}%`)