Fix status and filtered positions for metrics

This commit is contained in:
2025-10-08 18:37:38 +07:00
parent 86dd6849ea
commit 76b087a6e4
8 changed files with 57 additions and 89 deletions

View File

@@ -91,10 +91,10 @@ public class MessengerService : IMessengerService
private string BuildClosePositionMessage(Position position)
{
return $"Closing : {position.OriginDirection} {position.Open.Ticker} \n" +
$"Open Price : {position.Open.Price} \n" +
$"Closing Price : {position.Open.Price} \n" +
$"Quantity :{position.Open.Quantity} \n" +
$"PNL : {position.ProfitAndLoss.Realized} $";
$"Open Price : {position.Open.Price} \n" +
$"Closing Price : {position.Open.Price} \n" +
$"Quantity :{position.Open.Quantity} \n" +
$"PNL : {position.ProfitAndLoss.Realized} $";
}
public async Task SendMessage(string message, string telegramChannel)
@@ -114,21 +114,23 @@ public class MessengerService : IMessengerService
if (position.Open != null)
{
message += $"\nOpen Trade: {position.Open.Quantity:F5} @ {position.Open.Price:F5}";
message += $"\nOpen Trade: {position.Open.Price:F5}";
}
if (position.StopLoss != null){
message += $"\nStop Loss: {position.StopLoss.Quantity:F5} @ {position.StopLoss.Price:F5}";
if (position.StopLoss != null)
{
message += $"\nStop Loss: {position.StopLoss.Price:F5}";
}
if (position.TakeProfit1 != null){
message += $"\nTake Profit 1: {position.TakeProfit1.Quantity:F5} @ {position.TakeProfit1.Price:F5}";
if (position.TakeProfit1 != null)
{
message += $"\nTake Profit 1: {position.TakeProfit1.Price:F5}";
}
if (position.ProfitAndLoss != null)
{
var pnlEmoji = position.ProfitAndLoss.Realized >= 0 ? "✅" : "❌";
message += $"\nPnL: {pnlEmoji} ${position.ProfitAndLoss.Realized:F5}";
var pnlEmoji = position.ProfitAndLoss.Net >= 0 ? "✅" : "❌";
message += $"\nPnL: {pnlEmoji} ${position.ProfitAndLoss.Net:F5}";
}
return message;