Implement A1, A6, A2: Add TraderPosition entity, PositionPnLEngine (Average-Cost-Method), Market-level WinRate, and integrate with TraderAnalyticsWorker
This commit is contained in:
@@ -15,6 +15,7 @@ public class AppDbContext : DbContext
|
||||
public DbSet<PlatformConfig> PlatformConfigs => Set<PlatformConfig>();
|
||||
public DbSet<TraderAnalytics> TraderAnalytics => Set<TraderAnalytics>();
|
||||
public DbSet<MarketAnalytics> MarketAnalytics => Set<MarketAnalytics>();
|
||||
public DbSet<TraderPosition> TraderPositions => Set<TraderPosition>();
|
||||
|
||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
|
||||
|
||||
@@ -153,5 +154,17 @@ public class AppDbContext : DbContext
|
||||
e.Property(a => a.BotActivityScore).HasPrecision(8, 4);
|
||||
e.Property(a => a.AverageTradeSize).HasPrecision(18, 4);
|
||||
});
|
||||
|
||||
// TraderPosition
|
||||
mb.Entity<TraderPosition>(e =>
|
||||
{
|
||||
e.HasKey(tp => tp.Id);
|
||||
e.HasIndex(tp => new { tp.TraderId, tp.MarketOutcomeId }).IsUnique();
|
||||
e.Property(tp => tp.SharesHeld).HasPrecision(14, 6);
|
||||
e.Property(tp => tp.AvgCost).HasPrecision(10, 6);
|
||||
e.Property(tp => tp.RealizedPnl).HasPrecision(18, 4);
|
||||
e.HasOne(tp => tp.Trader).WithMany(t => t.Positions).HasForeignKey(tp => tp.TraderId).OnDelete(DeleteBehavior.Cascade);
|
||||
e.HasOne(tp => tp.MarketOutcome).WithMany().HasForeignKey(tp => tp.MarketOutcomeId).OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user