fix: Add runner stop loss protection (CRITICAL)
- CRITICAL BUG: Position Manager only checked SL before TP1 - After TP1 hit, runner had NO stop loss protection - Added separate SL check for runner (after TP1, before TP2) - Runner now protected by profit-lock SL on Position Manager Bug discovered: Runner position with no on-chain orders (below min size) AND no software protection (SL check skipped after TP1). Impact: 2.79 runner exposed to unlimited loss for 10+ minutes. Fix: Added line 881-886 runner SL check in monitoring loop.
This commit is contained in:
@@ -869,13 +869,21 @@ export class PositionManager {
|
||||
return
|
||||
}
|
||||
|
||||
// 2. Stop loss
|
||||
// 2. Stop loss (BEFORE TP1)
|
||||
if (!trade.tp1Hit && this.shouldStopLoss(currentPrice, trade)) {
|
||||
console.log(`🔴 STOP LOSS: ${trade.symbol} at ${profitPercent.toFixed(2)}%`)
|
||||
await this.executeExit(trade, 100, 'SL', currentPrice)
|
||||
return
|
||||
}
|
||||
|
||||
// 2b. CRITICAL: Runner stop loss (AFTER TP1, BEFORE TP2)
|
||||
// This protects the runner position after TP1 closes main position
|
||||
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
|
||||
}
|
||||
|
||||
// 3. Take profit 1 (closes configured %)
|
||||
if (!trade.tp1Hit && this.shouldTakeProfit1(currentPrice, trade)) {
|
||||
console.log(`🎉 TP1 HIT: ${trade.symbol} at ${profitPercent.toFixed(2)}%`)
|
||||
|
||||
Reference in New Issue
Block a user