Add logs when running signal

This commit is contained in:
2025-10-15 22:01:32 +07:00
parent da9c8db474
commit e9479e0a48
3 changed files with 28 additions and 21 deletions

View File

@@ -1,5 +1,6 @@
using System.Net.Http.Json;
using Managing.Application.Abstractions.Services;
using Managing.Common;
using Managing.Domain.Users;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
@@ -38,7 +39,7 @@ public class WebhookService : IWebhookService
isBadBehavior = isBadBehavior,
timestamp = DateTime.UtcNow,
type = "trade_notification",
telegramChannel = FormatTelegramChannel(user.TelegramChannel)
telegramChannel = Formatings.FormatTelegramChannel(user.TelegramChannel)
};
// Send the webhook notification
@@ -77,7 +78,7 @@ public class WebhookService : IWebhookService
message = message,
timestamp = DateTime.UtcNow,
type = "general_message",
telegramChannel = FormatTelegramChannel(telegramChannel)
telegramChannel = Formatings.FormatTelegramChannel(telegramChannel)
};
// Send the webhook notification
@@ -97,23 +98,4 @@ public class WebhookService : IWebhookService
_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;
}
}

View 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;
}
}

View File

@@ -65,7 +65,9 @@ public static class TradingBox
foreach (var indicator in lightScenario.Indicators)
{
IIndicator indicatorInstance = indicator.ToInterface();
Console.WriteLine($"[{indicator.Type}] Running indicator: {indicator.Name}");
var signals = indicatorInstance.Run(newCandles);
Console.WriteLine($"[{indicator.Type}] Signals founds: {string.Join(", ", signals)}");
if (signals == null || signals.Count() == 0)
{