diff --git a/src/Managing.Application/Shared/MessengerService.cs b/src/Managing.Application/Shared/MessengerService.cs index b5ea66d6..401cfa8c 100644 --- a/src/Managing.Application/Shared/MessengerService.cs +++ b/src/Managing.Application/Shared/MessengerService.cs @@ -106,19 +106,24 @@ public class MessengerService : IMessengerService var message = $"🔒 Closing : {position.OriginDirection} {position.Open.Ticker} \n" + $"📈 Open Price : {position.Open.Price} \n"; + // Determine closing price from whichever trade was filled + decimal? closingPrice = null; if (position.StopLoss.Status.Equals(Enums.TradeStatus.Filled)) { - message += $"🛑 SL Hit: {position.StopLoss.Price} \n"; + closingPrice = position.StopLoss.Price; + } + else if (position.TakeProfit1.Status.Equals(Enums.TradeStatus.Filled)) + { + closingPrice = position.TakeProfit1.Price; + } + else if (position.TakeProfit2?.Status.Equals(Enums.TradeStatus.Filled) == true) + { + closingPrice = position.TakeProfit2.Price; } - if (position.TakeProfit1.Status.Equals(Enums.TradeStatus.Filled)) + if (closingPrice.HasValue) { - message += $"🎯 TP1 Hit: {position.TakeProfit1.Price} \n"; - } - - if (position.TakeProfit2?.Status.Equals(Enums.TradeStatus.Filled) == true) - { - message += $"🎯 TP2 Hit: {position.TakeProfit2.Price} \n"; + message += $"💰 Closing Price : {closingPrice.Value} \n"; } var pnl = position.ProfitAndLoss?.Net ?? 0;