feat: Add Telegram notification for TP1 partial closes
**ENHANCEMENT:** TP1 partial closes now send Telegram notifications - Previously only full position closes (runner exit) sent notifications - TP1 hit → 60% close → User not notified until runner closed later - User couldn't see TP1 profit immediately **FIX:** Added notification in executeExit() partial close branch - Shows TP1 realized P&L (e.g., +$22.78) - Shows closed portion size - Includes "60% closed, 40% runner remaining" in exit reason - Same format as full closes: entry/exit prices, hold time, MAE/MFE **IMPACT:** User now gets immediate feedback when TP1 hits - Removed TODO comment at line 1589 - Both TP1 and runner closures now send notifications **FILES:** lib/trading/position-manager.ts line ~1575-1592 **DEPLOYED:** Nov 20, 2025 17:42 CET
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user