Enhance null safety in MessengerService by adding null checks for TakeProfit2 and ProfitAndLoss properties

This commit is contained in:
2025-10-10 14:43:48 +07:00
parent de8160e533
commit 7b92aa5727

View File

@@ -118,12 +118,12 @@ public class MessengerService : IMessengerService
message += $"TP1 Hit: {position.TakeProfit1.Price} \n"; message += $"TP1 Hit: {position.TakeProfit1.Price} \n";
} }
if (position.TakeProfit2.Status.Equals(Enums.TradeStatus.Filled)) if (position.TakeProfit2?.Status.Equals(Enums.TradeStatus.Filled) == true)
{ {
message += $"TP2 Hit: {position.TakeProfit2.Price} \n"; message += $"TP2 Hit: {position.TakeProfit2.Price} \n";
} }
message += $"PNL : {position.ProfitAndLoss.Net} $"; message += $"PNL : {position.ProfitAndLoss?.Net ?? 0} $";
return message; return message;
} }