Enhance null safety in MessengerService by adding null checks for TakeProfit2 and ProfitAndLoss properties
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user