namespace QuantEngine.Core.Interfaces; /// /// Data collection storage abstraction layer. /// Maps Python data_collection_store_v1.py contracts to .NET. /// Supports PostgreSQL backend for production. /// public interface IDataCollectionStore { /// /// Initialize storage tables and schema (idempotent). /// Task InitializeAsync(); /// /// Insert or update collection run record. /// Task UpsertRunAsync(CollectionRunRecord run); /// /// Insert collection snapshot record. /// Task UpsertSnapshotAsync(CollectionSnapshotRecord snapshot); /// /// Append error record from collection attempt. /// Task AppendErrorAsync(CollectionErrorRecord error); /// /// Fetch recent collection runs for dashboard. /// /// Max number of runs to return Task> FetchRecentRunsAsync(int limit = 20); /// /// Fetch latest snapshots for a ticker/dataset combination. /// Task> FetchLatestSnapshotsAsync(string ticker, string? datasetName = null, int limit = 10); /// /// Get collection pipeline dashboard state. /// Task GetDashboardStateAsync(); } public interface ICollectionWriteRepository { Task SaveRunAsync(CollectionRunRecord run); Task UpdateRunStatusAsync(string runId, string status, string? finishedAt = null, int? totalSnapshots = null, int? totalErrors = null); Task SaveSnapshotAsync(CollectionSnapshotRecord snapshot); Task SaveErrorAsync(CollectionErrorRecord error); Task SavePriceHistoryDailyAsync(PriceHistoryDailyRecord record); } public interface ICollectionReadRepository { Task> GetRecentRunsAsync(int limit = 20); Task> GetRunSnapshotsAsync(string runId); Task> GetRunErrorsAsync(string runId, int limit = 50); Task GetDashboardStateAsync(); Task> GetLatestSnapshotsForTickerAsync(string ticker, int limit = 10); Task> GetPriceHistorySummaryAsync(); } /// /// Collection run record (maps Python CollectionRun). /// public record CollectionRunRecord( string RunId, string Status, string StartedAt, string? FinishedAt = null, int? TotalSnapshots = null, int? TotalErrors = null, string UpdatedAt = "" ); /// /// Collection snapshot record (maps Python CollectionSnapshot). /// public record CollectionSnapshotRecord( string RunId, string DatasetName, string Ticker, string SourceName, string PayloadJson, string CapturedAt, string CreatedAt = "" ); /// /// Collection error record (maps Python CollectionSourceError). /// public record CollectionErrorRecord( string RunId, string SourceName, string ErrorKind, string ErrorMessage, string Ticker = "", string CreatedAt = "" ); /// /// Dashboard state summary. /// public record CollectionDashboardStateRecord( string? LastRunId, string? LastRunStatus, string? LastFinishedAt, int TotalSnapshots, int TotalErrors, List RecentErrors ); /// /// Daily price history record (OHLCV bar). /// public record PriceHistoryDailyRecord( string Ticker, DateOnly TradeDate, decimal Open, decimal High, decimal Low, decimal Close, long Volume, string Source, string? ProvenanceJson = null ); /// /// Price history summary (per-ticker aggregation). /// public record PriceHistorySummaryRecord( string Ticker, int RowCount, DateOnly FirstDate, DateOnly LastDate );