feat(backend): add admin evaluation history, engine, simulation, bot API controllers and global exception middleware

This commit is contained in:
2026-08-24 21:37:32 +02:00
parent 6974b2075b
commit 676496b77d
37 changed files with 88203 additions and 83075 deletions
@@ -4,7 +4,7 @@ using System.Net.Http;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using FinlyticCore.Models.Trades;
using FinlyticCore.Dtos.Trading;
using Microsoft.Extensions.Logging;
namespace FinlyticBackend.Services;
@@ -17,20 +17,12 @@ public interface IFirebaseNotificationService
/// <summary>
/// Sends a push notification about a new trade proposal.
/// </summary>
/// <param name="proposal">The trade proposal details.</param>
/// <param name="fcmTokens">The list of FCM device tokens.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>A task representing the asynchronous operation.</returns>
Task SendTradeProposalNotificationAsync(TradeProposalDto proposal, List<string> fcmTokens, CancellationToken cancellationToken = default);
/// <summary>
/// Sends a push notification about an update to an existing trade.
/// </summary>
/// <param name="update">The trade update details.</param>
/// <param name="fcmTokens">The list of FCM device tokens.</param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns>A task representing the asynchronous operation.</returns>
Task SendTradeUpdateNotificationAsync(TradeHourlyUpdateDto update, List<string> fcmTokens, CancellationToken cancellationToken = default);
Task SendTradeUpdateNotificationAsync(ActiveTradeDto update, List<string> fcmTokens, CancellationToken cancellationToken = default);
}
/// <inheritdoc />
@@ -39,11 +31,6 @@ public class FirebaseNotificationService : IFirebaseNotificationService
private readonly HttpClient _httpClient;
private readonly ILogger<FirebaseNotificationService> _logger;
/// <summary>
/// Initializes a new instance of the <see cref="FirebaseNotificationService"/> class.
/// </summary>
/// <param name="httpClient">The HTTP client for making API requests.</param>
/// <param name="logger">The logger instance.</param>
public FirebaseNotificationService(HttpClient httpClient, ILogger<FirebaseNotificationService> logger)
{
_httpClient = httpClient;
@@ -51,13 +38,12 @@ public class FirebaseNotificationService : IFirebaseNotificationService
}
/// <inheritdoc />
public async Task SendTradeProposalNotificationAsync(TradeProposalDto proposal, List<string> fcmTokens, CancellationToken cancellationToken = default)
{
if (fcmTokens == null || fcmTokens.Count == 0) return;
string title = $"🚀 Trade Signal: {proposal.SignalType} {proposal.Symbol}";
string body = $"{proposal.CompanyName} ({proposal.Isin}) - Entry: ${proposal.EntryPrice:F2}, WinRate: {proposal.WinRate:F1}%. {proposal.Reasoning}";
string title = $"🚀 Trade Signal: {proposal.Direction} {proposal.Symbol} ({proposal.StrategyKey})";
string body = $"{proposal.Symbol} ({proposal.UnderlyingIsin}) - Entry: {proposal.EntryPrice:F2}, Score: {proposal.CompositeScore:F0} Pkt. {proposal.AiValidation?.ThesisSummary}";
foreach (var token in fcmTokens)
{
@@ -66,12 +52,12 @@ public class FirebaseNotificationService : IFirebaseNotificationService
}
/// <inheritdoc />
public async Task SendTradeUpdateNotificationAsync(TradeHourlyUpdateDto update, List<string> fcmTokens, CancellationToken cancellationToken = default)
public async Task SendTradeUpdateNotificationAsync(ActiveTradeDto update, List<string> fcmTokens, CancellationToken cancellationToken = default)
{
if (fcmTokens == null || fcmTokens.Count == 0) return;
string title = $"📊 Trade Update: {update.TradeId}";
string body = $"Recommendation: {update.Recommendation} @ ${update.CurrentPrice:F2}. {update.Reasoning}";
string title = $"📊 Trade Update: {update.Symbol} (Status: {update.Status})";
string body = $"Status: {update.Status} @ {update.CurrentPrice:F2}, PnL: {update.UnrealizedPnlPercent:+0.0;-0.0}% (€{update.UnrealizedPnlEur:+0.00;-0.00}).";
foreach (var token in fcmTokens)
{