diff --git a/lib/trading/position-manager.ts b/lib/trading/position-manager.ts index 0115694..b6a2e3a 100644 --- a/lib/trading/position-manager.ts +++ b/lib/trading/position-manager.ts @@ -1581,10 +1581,22 @@ export class PositionManager { // Persist updated trade state so analytics reflect partial profits immediately await this.saveTradeState(trade) + + // Send Telegram notification for TP1 partial close + await sendPositionClosedNotification({ + symbol: trade.symbol, + direction: trade.direction, + entryPrice: trade.entryPrice, + exitPrice: result.closePrice || currentPrice, + positionSize: closedUSD, // Show only the closed portion + realizedPnL: result.realizedPnL || 0, + exitReason: `${reason} (${percentToClose}% closed, ${(100 - percentToClose).toFixed(0)}% runner remaining)`, + holdTimeSeconds: Math.floor((Date.now() - trade.entryTime) / 1000), + maxDrawdown: Math.abs(Math.min(0, trade.maxAdverseExcursion)), + maxGain: Math.max(0, trade.maxFavorableExcursion), + }) } - // TODO: Send notification - } catch (error) { console.error(`❌ Error executing exit for ${trade.symbol}:`, error) }