diff --git a/lib/trading/position-manager.ts b/lib/trading/position-manager.ts index 965e409..1debb08 100644 --- a/lib/trading/position-manager.ts +++ b/lib/trading/position-manager.ts @@ -1914,10 +1914,15 @@ export class PositionManager { return } + // CRITICAL FIX (Dec 15, 2025): Accumulate P&L for BOTH partial and full closes + // Bug was: TP1 (60% close) never updated trade.realizedPnL, only TP2 (100% close) did + // Result: Database only showed TP2 runner profit, missing TP1 profit + trade.realizedPnL += result.realizedPnL || 0 + logger.log(`💰 P&L accumulated: +$${(result.realizedPnL || 0).toFixed(2)} | Total: $${trade.realizedPnL.toFixed(2)}`) + // Update trade state if (percentToClose >= 100) { // Full close - remove from monitoring - trade.realizedPnL += result.realizedPnL || 0 // Save to database (only for valid exit reasons) if (reason !== 'error') {