From e9479e0a48b6f39c52baaf2c8684b8073db07394 Mon Sep 17 00:00:00 2001 From: cryptooda Date: Wed, 15 Oct 2025 22:01:32 +0700 Subject: [PATCH] Add logs when running signal --- .../Shared/WebhookService.cs | 24 +++---------------- src/Managing.Common/Formatings.cs | 23 ++++++++++++++++++ .../Shared/Helpers/TradingBox.cs | 2 ++ 3 files changed, 28 insertions(+), 21 deletions(-) create mode 100644 src/Managing.Common/Formatings.cs diff --git a/src/Managing.Application/Shared/WebhookService.cs b/src/Managing.Application/Shared/WebhookService.cs index 8538744a..dd6a454c 100644 --- a/src/Managing.Application/Shared/WebhookService.cs +++ b/src/Managing.Application/Shared/WebhookService.cs @@ -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; - } } \ No newline at end of file diff --git a/src/Managing.Common/Formatings.cs b/src/Managing.Common/Formatings.cs new file mode 100644 index 00000000..9d95ba14 --- /dev/null +++ b/src/Managing.Common/Formatings.cs @@ -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; + } +} \ No newline at end of file diff --git a/src/Managing.Domain/Shared/Helpers/TradingBox.cs b/src/Managing.Domain/Shared/Helpers/TradingBox.cs index 7c2624fe..e064d62f 100644 --- a/src/Managing.Domain/Shared/Helpers/TradingBox.cs +++ b/src/Managing.Domain/Shared/Helpers/TradingBox.cs @@ -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) {