Fix Estimator scoring and PnL engine cashflow

This commit is contained in:
Richard
2026-07-07 18:30:20 +02:00
parent 8d056653f9
commit 4eb0d99b4e
17 changed files with 2594 additions and 97 deletions
@@ -18,6 +18,7 @@ public class AppDbContext : DbContext
public DbSet<MarketAnalytics> MarketAnalytics => Set<MarketAnalytics>();
public DbSet<TraderPosition> TraderPositions => Set<TraderPosition>();
public DbSet<MarketOutcomePriceSnapshot> MarketOutcomePriceSnapshots => Set<MarketOutcomePriceSnapshot>();
public DbSet<TraderDailySnapshot> TraderDailySnapshots => Set<TraderDailySnapshot>();
public DbSet<TraderCategoryPerformance> TraderCategoryPerformances => Set<TraderCategoryPerformance>();
public DbSet<TradeContext> TradeContexts => Set<TradeContext>();
public DbSet<BackgroundJob> BackgroundJobs => Set<BackgroundJob>();
@@ -119,12 +120,13 @@ public class AppDbContext : DbContext
mb.Entity<TraderScore>(e =>
{
e.HasKey(s => s.Id);
e.Property(s => s.ActivityScore).HasPrecision(8, 4);
e.Property(s => s.QualityScore).HasPrecision(8, 4);
e.Property(s => s.CombinedScore).HasPrecision(8, 4);
e.Property(s => s.VolumeScore).HasPrecision(8, 4);
e.Property(s => s.TimingScore).HasPrecision(8, 4);
e.Property(s => s.CopytradingScore).HasPrecision(8, 4);
e.HasIndex(s => s.TraderId).IsUnique();
e.Property(s => s.ActivityScore).HasPrecision(5, 2);
e.Property(s => s.QualityScore).HasPrecision(5, 2);
e.Property(s => s.CombinedScore).HasPrecision(5, 2);
e.Property(s => s.VolumeScore).HasPrecision(5, 2);
e.Property(s => s.TimingScore).HasPrecision(5, 2);
e.HasOne(s => s.Trader).WithOne(t => t.CurrentScore).HasForeignKey<TraderScore>(s => s.TraderId).OnDelete(DeleteBehavior.Cascade);
});
// WatchlistEntry
@@ -213,6 +215,16 @@ public class AppDbContext : DbContext
e.HasOne(tp => tp.MarketOutcome).WithMany().HasForeignKey(tp => tp.MarketOutcomeId).OnDelete(DeleteBehavior.Cascade);
});
// TraderDailySnapshot
mb.Entity<TraderDailySnapshot>(e =>
{
e.HasKey(s => s.Id);
e.HasIndex(s => new { s.TraderId, s.Date }).IsUnique();
e.Property(s => s.TotalPnl).HasPrecision(18, 4);
e.Property(s => s.CurrentBalance).HasPrecision(18, 4);
e.HasOne(s => s.Trader).WithMany().HasForeignKey(s => s.TraderId).OnDelete(DeleteBehavior.Cascade);
});
// MarketOutcomePriceSnapshot
mb.Entity<MarketOutcomePriceSnapshot>(e =>
{