Implement A1, A6, A2: Add TraderPosition entity, PositionPnLEngine (Average-Cost-Method), Market-level WinRate, and integrate with TraderAnalyticsWorker

This commit is contained in:
Richard
2026-07-03 11:16:42 +02:00
parent 5fe7ab63ac
commit e994e1ce72
10 changed files with 1227 additions and 78 deletions
@@ -0,0 +1,14 @@
using System.Threading;
using System.Threading.Tasks;
namespace Predictalytics.Application.Interfaces;
public interface IPositionPnLEngine
{
/// <summary>
/// Recalculates all positions, average costs, and PnL values for a trader by re-playing their trade history.
/// Updates the TraderPosition records in the database, calculates realized/unrealized PnL,
/// and updates the Trader's TotalPnl and WinRate.
/// </summary>
Task RecalculateTraderPositionsAsync(int traderId, CancellationToken ct = default);
}