Implement A1, A6, A2: Add TraderPosition entity, PositionPnLEngine (Average-Cost-Method), Market-level WinRate, and integrate with TraderAnalyticsWorker
This commit is contained in:
@@ -66,4 +66,5 @@ public class Trader
|
||||
public TraderScore? CurrentScore { get; set; }
|
||||
public virtual TraderAnalytics? Analytics { get; set; }
|
||||
public ICollection<WatchlistEntry> WatchlistEntries { get; set; } = new List<WatchlistEntry>();
|
||||
public ICollection<TraderPosition> Positions { get; set; } = new List<TraderPosition>();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
|
||||
namespace Predictalytics.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a trader's position in a specific market outcome.
|
||||
/// Tracks shares held, average purchase price, and realized profit/loss.
|
||||
/// </summary>
|
||||
public class TraderPosition
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>Foreign key to the trader.</summary>
|
||||
public int TraderId { get; set; }
|
||||
|
||||
/// <summary>Foreign key to the resolved market outcome.</summary>
|
||||
public int MarketOutcomeId { get; set; }
|
||||
|
||||
/// <summary>Number of shares currently held.</summary>
|
||||
public decimal SharesHeld { get; set; }
|
||||
|
||||
/// <summary>Average purchase cost per share.</summary>
|
||||
public decimal AvgCost { get; set; }
|
||||
|
||||
/// <summary>Realized profit/loss from closed portions of this position.</summary>
|
||||
public decimal RealizedPnl { get; set; }
|
||||
|
||||
/// <summary>When this position was last updated.</summary>
|
||||
public DateTime LastUpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation properties
|
||||
public Trader Trader { get; set; } = null!;
|
||||
public MarketOutcome MarketOutcome { get; set; } = null!;
|
||||
}
|
||||
Reference in New Issue
Block a user