Update closing message
This commit is contained in:
@@ -84,17 +84,48 @@ public class MessengerService : IMessengerService
|
|||||||
public async Task SendClosedPosition(Position position, User user)
|
public async Task SendClosedPosition(Position position, User user)
|
||||||
{
|
{
|
||||||
var message = BuildClosePositionMessage(position);
|
var message = BuildClosePositionMessage(position);
|
||||||
|
try
|
||||||
|
{
|
||||||
await _discordService.SendMessage(message);
|
await _discordService.SendMessage(message);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
SentrySdk.CaptureException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
await _webhookService.SendMessage(message, user.TelegramChannel);
|
await _webhookService.SendMessage(message, user.TelegramChannel);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
SentrySdk.CaptureException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private string BuildClosePositionMessage(Position position)
|
private string BuildClosePositionMessage(Position position)
|
||||||
{
|
{
|
||||||
return $"Closing : {position.OriginDirection} {position.Open.Ticker} \n" +
|
var message = $"Closing : {position.OriginDirection} {position.Open.Ticker} \n" +
|
||||||
$"Open Price : {position.Open.Price} \n" +
|
$"Open Price : {position.Open.Price} \n";
|
||||||
$"Closing Price : {position.Open.Price} \n" +
|
|
||||||
$"Quantity :{position.Open.Quantity} \n" +
|
if (position.StopLoss.Status.Equals(Enums.TradeStatus.Filled))
|
||||||
$"PNL : {position.ProfitAndLoss.Realized} $";
|
{
|
||||||
|
message += $"SL Hit: {position.StopLoss.Price} \n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position.TakeProfit1.Status.Equals(Enums.TradeStatus.Filled))
|
||||||
|
{
|
||||||
|
message += $"TP1 Hit: {position.TakeProfit1.Price} \n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position.TakeProfit2.Status.Equals(Enums.TradeStatus.Filled))
|
||||||
|
{
|
||||||
|
message += $"TP2 Hit: {position.TakeProfit2.Price} \n";
|
||||||
|
}
|
||||||
|
|
||||||
|
message += $"PNL : {position.ProfitAndLoss.Net} $";
|
||||||
|
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SendMessage(string message, string telegramChannel)
|
public async Task SendMessage(string message, string telegramChannel)
|
||||||
|
|||||||
Reference in New Issue
Block a user