feat: implement Part D and E from FIXPLAN

- D1/D2/D2c: Added TraderTraits entity, TraderTraitCalculator, Market Return Metrics (MedianWin, AvgWin, etc.), and trait filters
- D3: Implemented HF-Trader Tiering via IngestMode (Full, Aggregated, SnapshotOnly) and updated TradeHistoryWorker to respect tiers
- E1-E5: Added MasterStatus to Trader, TraderWindowMetrics for rolling analytics, Fingerprint metrics (PriceBandProfile, P50/P90), Copyability aggregates (Volume, Drift, Edge)
- E6: Implemented GET /api/traders/{id}/profile and GET /api/traders/correlation
- Replaced FIXPLAN-2026-07-09.md with FIXPLAN-TODO.md and FIXPLAN-DONE.md
- Cleaned up API docs and plan to use generic terms (removed hardcoded PolyTrader references)
- Added respective EF Core Migrations
This commit is contained in:
Richard
2026-07-14 09:04:31 +02:00
parent a1fcb4ace5
commit 16431f38a5
39 changed files with 9028 additions and 167 deletions
@@ -69,7 +69,7 @@ public class TradeRetentionWorker : BackgroundService
return;
}
var retentionDays = _config.GetValue("RetentionSettings:RetentionDays", 90);
var retentionDays = _config.GetValue("RetentionSettings:RetentionDays", 180);
var compactionDays = _config.GetValue("RetentionSettings:CompactionDays", 14);
_logger.LogInformation("🧹 TradeRetentionWorker: Starting optimization. RetentionDays={Retention}, CompactionDays={Compaction}",
@@ -83,13 +83,13 @@ public class TradeRetentionWorker : BackgroundService
_logger.LogInformation("Pruning trades older than {Cutoff}...", retentionCutoff);
var deletedTrades = await db.Trades
.Where(t => t.ExecutedAt < retentionCutoff && !t.Trader.WatchlistEntries.Any())
.Where(t => t.ExecutedAt < retentionCutoff && !t.Trader.WatchlistEntries.Any() && t.Trader.IngestMode == IngestMode.Full)
.Select(t => new { t.TraderId, t.MarketOutcomeId })
.Distinct()
.ToListAsync(ct);
var deletedCount = await db.Trades
.Where(t => t.ExecutedAt < retentionCutoff && !t.Trader.WatchlistEntries.Any())
.Where(t => t.ExecutedAt < retentionCutoff && !t.Trader.WatchlistEntries.Any() && t.Trader.IngestMode == IngestMode.Full)
.ExecuteDeleteAsync(ct);
if (deletedCount > 0 && deletedTrades.Any())
@@ -217,7 +217,8 @@ public class TradeRetentionWorker : BackgroundService
Size = totalSize,
Amount = totalAmount,
ExecutedAt = date.AddHours(12), // Set to noon of that day
TransactionHash = null
TransactionHash = null,
AggregatedCount = list.Sum(t => t.AggregatedCount ?? 1)
};
// Remove the individual trades