Add the Laboratorio screen: new test, report, comparison (refs #36)
The laboratory starts with the host (off in demo mode) and runs its queue next to market data and trading. The page lists every trial with status, verdict and headline figures, refreshing itself while one is queued or running, and offers the form for a new test: strategy, data origin and market, instruments, period, initial capital and the grid, with the thresholds stated before the run. The form posts with the antiforgery token; errors come back as a short code. The report page shows the protocol checks, the chosen variant against buy and hold (table and chart), results per year, cost sensitivity, the Deflated Sharpe Ratio, PBO, walk-forward windows, purged CV paths, the look-ahead result, every variant with its zone score, what the backtest does not model, the data used and the trades. A comparison page puts two finished tests side by side and says whether they read the same data. The improvements of 8.7 and the cost estimates of 11.6 have their sections, empty until Phases 9 and 8. The equity chart takes amounts in their own currency and its labels as parameters. The profit factor has no value without a losing trade. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5efb149fd6
commit
953ffe5e9b
11 files changed
+1083
-26
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using Anubis.Access;
|
||||
using Anubis.Backtest;
|
||||
using Anubis.Core;
|
||||
using Anubis.Data;
|
||||
using Anubis.Db;
|
||||
@@ -37,7 +38,7 @@ internal sealed record HostChanged(HostMode Mode);
|
||||
|
||||
/// <summary>Everything that needs the database, built once it is reachable and the installation checks out.</summary>
|
||||
internal sealed record AppServices(Database Db, SettingsStore Settings, SecretStore Secrets, AccessStore Access, Backups Backups, Scheduler Scheduler,
|
||||
MarketDataService? MarketData = null, TradingService? Trading = null);
|
||||
MarketDataService? MarketData = null, TradingService? Trading = null, Laboratory? Lab = null);
|
||||
|
||||
/// <summary>
|
||||
/// The startup state machine of the server (SPEC 15.1, 15.6): reads the startup configuration, opens the configured
|
||||
@@ -65,6 +66,7 @@ internal sealed partial class AnubisHost(
|
||||
private CancellationTokenSource? _schedulerStop;
|
||||
private MarketDataService? _market;
|
||||
private TradingService? _trading;
|
||||
private Laboratory? _lab;
|
||||
private volatile HostStatus _status = new(HostMode.Starting, null, null, clock.UtcNow, 0);
|
||||
private volatile AppServices? _services;
|
||||
|
||||
@@ -292,7 +294,9 @@ internal sealed partial class AnubisHost(
|
||||
? new TradingService(_db, clock, bus, secrets, _market, new FxStore(_db, clock), TradingConsent.From(Config), file.InstallationId,
|
||||
overrides?.MarketHttp, overrides?.MarketSockets, logger)
|
||||
: null;
|
||||
_services = new AppServices(_db, settings, secrets, access, backups, scheduler, _market, _trading);
|
||||
// The laboratory computes on its own thread and reads only local data; the demo shows appendix F and runs none.
|
||||
_lab = options.Demo ? null : new Laboratory(_db, clock, Config.Data.Research, logger);
|
||||
_services = new AppServices(_db, settings, secrets, access, backups, scheduler, _market, _trading, _lab);
|
||||
StartScheduler(scheduler, backups);
|
||||
SetStatus(HostMode.Ready, null);
|
||||
}
|
||||
@@ -426,12 +430,14 @@ internal sealed partial class AnubisHost(
|
||||
var token = _schedulerStop.Token;
|
||||
var market = _market;
|
||||
var trading = _trading;
|
||||
var lab = _lab;
|
||||
_schedulerLoop = Task.Run(async () =>
|
||||
{
|
||||
using var runs = bus.Subscribe<JobRun>();
|
||||
var recorder = RecordJobsAsync(runs, token);
|
||||
var collecting = market is null ? Task.CompletedTask : RunMarketDataAsync(market, token);
|
||||
var dealing = trading is null ? Task.CompletedTask : RunTradingAsync(trading, token);
|
||||
var testing = lab is null ? Task.CompletedTask : RunLabAsync(lab, token);
|
||||
try
|
||||
{
|
||||
await scheduler.RunAsync(token).ConfigureAwait(false);
|
||||
@@ -442,6 +448,7 @@ internal sealed partial class AnubisHost(
|
||||
|
||||
await collecting.ConfigureAwait(false);
|
||||
await dealing.ConfigureAwait(false);
|
||||
await testing.ConfigureAwait(false);
|
||||
await recorder.ConfigureAwait(false);
|
||||
}, CancellationToken.None);
|
||||
}
|
||||
@@ -461,6 +468,21 @@ internal sealed partial class AnubisHost(
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RunLabAsync(Laboratory lab, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
await lab.RunAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogLabFailed(logger, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RunTradingAsync(TradingService trading, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
@@ -532,6 +554,8 @@ internal sealed partial class AnubisHost(
|
||||
_market = null;
|
||||
_trading?.Dispose();
|
||||
_trading = null;
|
||||
_lab?.Dispose();
|
||||
_lab = null;
|
||||
}
|
||||
|
||||
// Values of the startup configuration that also exist as settings are read-only in the interface (SPEC 13.5).
|
||||
@@ -571,6 +595,9 @@ internal sealed partial class AnubisHost(
|
||||
[LoggerMessage(Level = LogLevel.Error, Message = "Market data stopped")]
|
||||
private static partial void LogMarketDataFailed(ILogger logger, Exception exception);
|
||||
|
||||
[LoggerMessage(Level = LogLevel.Error, Message = "Laboratory stopped")]
|
||||
private static partial void LogLabFailed(ILogger logger, Exception exception);
|
||||
|
||||
[LoggerMessage(Level = LogLevel.Error, Message = "Trading stopped")]
|
||||
private static partial void LogTradingFailed(ILogger logger, Exception exception);
|
||||
|
||||
|
||||
Reference in new issue
Block a user