Files
Anubis/tests/Anubis.Tests/Property.cs
T
Alby96andClaude Opus 5.5 8967575d2c
ci / test (postgres) (push) Successful in 7m30s
ci / test (sqlite) (push) Successful in 5m52s
ci / image (push) Successful in 2m8s
Add the tournament statistics and the surrogate series of the control
The championship judge needs statistics the single-trial protocol does not
have: one common number of trials for the whole field and the bar it sets,
a field variance taken on annualised Sharpe ratios so crypto and weekday
markets compare, the common probability of overfitting on one calendar,
the effective number of bets, a block-bootstrap interval and the control
against chance. The control replays a rule on surrogate prices where every
day all instruments change sign together, centred on the mean for
long-only rules, so sizes, tails and correlations stay while any tendency
to revert or to go on is lost. Instruments with corporate actions are
refused for now.

The seeded SplitMix64 generator of the tests moves to Anubis.Core as
SeededRandom, unchanged, so the control and the intervals draw from it;
the tests keep calling it Gen through a global alias.

refs #124

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 13:07:14 +01:00

32 lines
1.0 KiB
C#

using System.Globalization;
namespace Anubis.Tests;
/// <summary>
/// Property tests without external packages (ADR 0003, 0004): many generated cases from a fixed
/// seed, so a failure always repeats, and a message that names the seed and the failing case.
/// </summary>
internal static class Property
{
public const int DefaultSeed = 20261110;
public const int DefaultCases = 200;
public static void ForAll<T>(Func<Gen, T> generate, Action<T> property, int cases = DefaultCases, int seed = DefaultSeed)
{
var gen = new Gen(seed);
for (var i = 0; i < cases; i++)
{
var value = generate(gen);
try
{
property(value);
}
catch (Exception ex) when (ex is not AssertInconclusiveException)
{
throw new AssertFailedException(
string.Create(CultureInfo.InvariantCulture, $"Proprietà violata al caso {i} (seme {seed}): {value}"), ex);
}
}
}
}