feat(home): surface forward-test P&L on the dashboard
Adds a forward-test (paper-trading) net-P&L tile to the Home dashboard, shown only
once the worker has opened or settled any paper bet. Reuses the existing
IPaperTradingService aggregation (settled-only net + open count) so there is one
definition of the figure, and makes the H4 forward-test result visible from the
landing page instead of only its own route.
- DashboardSummary gains Paper{OpenCount,SettledCount,NetProfit,RoiPercent}
(default-valued, so existing constructions are unaffected) + HasPaperTrades;
DashboardSummaryService injects IPaperTradingService; Home tile + en/ru resx.
This commit is contained in:
@@ -18,6 +18,7 @@ public sealed class DashboardSummaryService : IDashboardSummaryService
|
||||
private readonly ISnapshotRepository _snapshots;
|
||||
private readonly IAnomalyRepository _anomalies;
|
||||
private readonly IAnomalyBrowsingService _anomalyBrowsing;
|
||||
private readonly IPaperTradingService _paperTrading;
|
||||
private readonly IOptionsMonitor<WorkerOptions> _workers;
|
||||
|
||||
public DashboardSummaryService(
|
||||
@@ -25,12 +26,14 @@ public sealed class DashboardSummaryService : IDashboardSummaryService
|
||||
ISnapshotRepository snapshots,
|
||||
IAnomalyRepository anomalies,
|
||||
IAnomalyBrowsingService anomalyBrowsing,
|
||||
IPaperTradingService paperTrading,
|
||||
IOptionsMonitor<WorkerOptions> workers)
|
||||
{
|
||||
_events = events ?? throw new ArgumentNullException(nameof(events));
|
||||
_snapshots = snapshots ?? throw new ArgumentNullException(nameof(snapshots));
|
||||
_anomalies = anomalies ?? throw new ArgumentNullException(nameof(anomalies));
|
||||
_anomalyBrowsing = anomalyBrowsing ?? throw new ArgumentNullException(nameof(anomalyBrowsing));
|
||||
_paperTrading = paperTrading ?? throw new ArgumentNullException(nameof(paperTrading));
|
||||
_workers = workers ?? throw new ArgumentNullException(nameof(workers));
|
||||
}
|
||||
|
||||
@@ -54,6 +57,9 @@ public sealed class DashboardSummaryService : IDashboardSummaryService
|
||||
|
||||
var w = _workers.CurrentValue;
|
||||
|
||||
// Reuse the forward-test aggregation (settled-only P&L) for the headline tile.
|
||||
var paper = await _paperTrading.GetAsync(ct).ConfigureAwait(false);
|
||||
|
||||
return new DashboardSummary(
|
||||
EventsTracked: eventsTracked,
|
||||
SnapshotsToday: snapshotsToday,
|
||||
@@ -64,7 +70,11 @@ public sealed class DashboardSummaryService : IDashboardSummaryService
|
||||
ScheduleStatus: StageStatus(w.UpcomingPollerEnabled, eventsTracked > 0),
|
||||
SnapshotStatus: StageStatus(w.LivePollerEnabled, snapshotsToday > 0),
|
||||
DetectorStatus: StageStatus(w.AnomalyDetectionEnabled, anomaliesTotal > 0),
|
||||
ExportStatus: eventsTracked > 0 ? "ok" : "idle");
|
||||
ExportStatus: eventsTracked > 0 ? "ok" : "idle",
|
||||
PaperOpenCount: paper.OpenCount,
|
||||
PaperSettledCount: paper.SettledCount,
|
||||
PaperNetProfit: paper.NetProfit,
|
||||
PaperRoiPercent: paper.RoiPercent);
|
||||
}
|
||||
|
||||
// Maps a worker stage to the PipelineStep token: disabled → idle, enabled but
|
||||
|
||||
Reference in New Issue
Block a user