Add logs when running signal
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
using Managing.Application.Abstractions.Services;
|
using Managing.Application.Abstractions.Services;
|
||||||
|
using Managing.Common;
|
||||||
using Managing.Domain.Users;
|
using Managing.Domain.Users;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@@ -38,7 +39,7 @@ public class WebhookService : IWebhookService
|
|||||||
isBadBehavior = isBadBehavior,
|
isBadBehavior = isBadBehavior,
|
||||||
timestamp = DateTime.UtcNow,
|
timestamp = DateTime.UtcNow,
|
||||||
type = "trade_notification",
|
type = "trade_notification",
|
||||||
telegramChannel = FormatTelegramChannel(user.TelegramChannel)
|
telegramChannel = Formatings.FormatTelegramChannel(user.TelegramChannel)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Send the webhook notification
|
// Send the webhook notification
|
||||||
@@ -77,7 +78,7 @@ public class WebhookService : IWebhookService
|
|||||||
message = message,
|
message = message,
|
||||||
timestamp = DateTime.UtcNow,
|
timestamp = DateTime.UtcNow,
|
||||||
type = "general_message",
|
type = "general_message",
|
||||||
telegramChannel = FormatTelegramChannel(telegramChannel)
|
telegramChannel = Formatings.FormatTelegramChannel(telegramChannel)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Send the webhook notification
|
// Send the webhook notification
|
||||||
@@ -97,23 +98,4 @@ public class WebhookService : IWebhookService
|
|||||||
_logger.LogError(ex, "Error sending webhook message");
|
_logger.LogError(ex, "Error sending webhook message");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string FormatTelegramChannel(string? telegramChannel)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(telegramChannel))
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (telegramChannel.StartsWith("100"))
|
|
||||||
{
|
|
||||||
return telegramChannel.Substring(3);
|
|
||||||
}
|
|
||||||
else if (telegramChannel.StartsWith("-100"))
|
|
||||||
{
|
|
||||||
return telegramChannel.Substring(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
return telegramChannel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
23
src/Managing.Common/Formatings.cs
Normal file
23
src/Managing.Common/Formatings.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
namespace Managing.Common;
|
||||||
|
|
||||||
|
public static class Formatings
|
||||||
|
{
|
||||||
|
public static string FormatTelegramChannel(string? telegramChannel)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(telegramChannel))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (telegramChannel.StartsWith("100"))
|
||||||
|
{
|
||||||
|
return telegramChannel.Substring(3);
|
||||||
|
}
|
||||||
|
else if (telegramChannel.StartsWith("-100"))
|
||||||
|
{
|
||||||
|
return telegramChannel.Substring(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return telegramChannel;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -65,7 +65,9 @@ public static class TradingBox
|
|||||||
foreach (var indicator in lightScenario.Indicators)
|
foreach (var indicator in lightScenario.Indicators)
|
||||||
{
|
{
|
||||||
IIndicator indicatorInstance = indicator.ToInterface();
|
IIndicator indicatorInstance = indicator.ToInterface();
|
||||||
|
Console.WriteLine($"[{indicator.Type}] Running indicator: {indicator.Name}");
|
||||||
var signals = indicatorInstance.Run(newCandles);
|
var signals = indicatorInstance.Run(newCandles);
|
||||||
|
Console.WriteLine($"[{indicator.Type}] Signals founds: {string.Join(", ", signals)}");
|
||||||
|
|
||||||
if (signals == null || signals.Count() == 0)
|
if (signals == null || signals.Count() == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user