Review the base strategies every three months

Every quarter the base strategies are tried again on the longer history with
the slippage in force, compared with how they did live, and the report is
published in the laboratory with the base rates measured again and the balance
of the restrictions of 10.5. In observation the outcome replaces the old one and
a strategy that passed goes to simulation after its 90 days; with capital
nothing moves but the demotion condition of 12.3. A restart halfway goes on and
the review concludes once; the outcome of a review survives a restart with an
older build.

refs #74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-01 20:59:20 +01:00
1 parent 79bb194de0
commit 2257c3e16c
34 files changed
+2308 -87

No files matched your search

@@ -2,9 +2,12 @@ using System.IO.Compression;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using Anubis.Backtest;
using Anubis.Brokers;
using Anubis.Core;
using Anubis.Data;
using Anubis.Db;
using Anubis.Platform;
namespace Anubis.Tests;
@@ -283,6 +286,54 @@ public sealed class ReferenceSourcesTests
}
}
// Answers with a pause, and counts the requests open at once.
private sealed class SlowHttp(Func<Uri, byte[]?> answer) : HttpMessageHandler
{
private int _open;
public int MostOpen { get; private set; }
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
MostOpen = Math.Max(MostOpen, Interlocked.Increment(ref _open));
await Task.Delay(1, cancellationToken).ConfigureAwait(false);
Interlocked.Decrement(ref _open);
return answer(request.RequestUri!) is { } body ? new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(body) } : new HttpResponseMessage(HttpStatusCode.NotFound);
}
}
/// <summary>The history of the quarterly review (SPEC 12.2): archives one at a time, in euro, and what is missing in words.</summary>
[TestMethod]
[TestCategory(Category.Integration)]
public async Task TheHistoryOfTheReviewIsPreparedOnceAtATime()
{
var folder = TempFolder.Create("review-archives");
try
{
await using var test = await DatabaseTests.MigratedAsync().ConfigureAwait(false);
var clock = new FastClock(new DateTimeOffset(2017, 10, 15, 0, 0, 0, TimeSpan.Zero));
var august = Zip("BTCUSDT-1d-2017-08.csv", Fixture.Text("free/binance-BTCUSDT-1d-2017-08.csv"));
var http = new SlowHttp(u => !u.ToString().Contains("2017-08", StringComparison.Ordinal) || !CryptoTrendProtocol.Narrow.Any(s => u.ToString().Contains(s[..3] + "USDT", StringComparison.Ordinal)) ? null
: u.ToString().EndsWith("CHECKSUM", StringComparison.Ordinal) ? Encoding.UTF8.GetBytes(Convert.ToHexStringLower(SHA256.HashData(august)) + " x.zip") : august);
var bus = new EventBus();
using var market = new MarketDataService(test.Db, clock, bus, new SettingsStore(test.Db, clock, bus), new SecretStore(test.Db, clock, new byte[32]), new DataDirectory(folder), http);
var to = new DateOnly(2017, 8, 21);
Assert.AreEqual("mancano i cambi della BCE", await market.PrepareReviewHistoryAsync(to, CancellationToken.None).ConfigureAwait(false));
await new FxStore(test.Db, clock).UpsertAsync([new FxRate("EUR", "USD", new DateOnly(2017, 8, 16), 1.17m, "ecb"), new FxRate("EUR", "USD", new DateOnly(2017, 8, 18), 1.17m, "ecb")], CancellationToken.None)
.ConfigureAwait(false);
var both = await Task.WhenAll(market.PrepareReviewHistoryAsync(to, CancellationToken.None), market.PrepareReviewHistoryAsync(to, CancellationToken.None)).ConfigureAwait(false);
CollectionAssert.AreEqual(new string?[] { null, null }, both);
Assert.AreEqual(1, http.MostOpen, "one import at a time");
Assert.AreEqual("l'archivio di Binance di settembre 2017 non è ancora completo", await market.PrepareReviewHistoryAsync(new DateOnly(2017, 9, 30), CancellationToken.None).ConfigureAwait(false));
using var offline = new MarketDataService(test.Db, clock, bus, new SettingsStore(test.Db, clock, bus), new SecretStore(test.Db, clock, new byte[32]), new DataDirectory(folder), http, offline: true);
Assert.AreEqual("la raccolta dei dati è spenta", await offline.PrepareReviewHistoryAsync(to, CancellationToken.None).ConfigureAwait(false));
}
finally
{
TempFolder.Delete(folder);
}
}
[TestMethod]
[TestCategory(Category.Integration)]
public async Task CsvImporterFollowsTheMappingAndReportsWhatItCouldNotRead()