Fix the review findings of the basket engine, command and report
The independent review of Phase 14 found rules the engine applied differently from the decisions, numbers the report labelled wrongly and a command that left a trial "running" when interrupted. Engine: - The pause after the 9% account stop is read at the decision moment (the bar's close), like every other gate: on daily bars it no longer blocks one day past the server date change. - In a one-pair basket, a level closed by the venue's mandatory stop closes the other levels at the next execution with their own reason, closed_with_stop (counted and labelled in the report); the basket's exit stays mandatory_stop, and a two-leg basket keeps orphan_leg. - The cap of two entries per currency applies to new baskets only, never to the averagings of an open basket, and every leg is valued at the current mid: a Prudente long basket "come dal vivo" now makes its three averagings and Fedele writes no note on them. - The surrogate of the control chains on the mid when the source has an ask, so each mid change keeps its size and the spread stays around the mid instead of moving the mid by a spread at each change of sign. - The financing already charged on positions still open at the end is part of the run's fees (BacktestRun.AccruedFees, zero for the daily engine, kept in stored unit outcomes). Report: the fee row says what it holds (commission and financing, the spread is in the prices) and the cost-stress text matches what the multiplier scales; baskets still open at the end are labelled as such and left out of the share closed at the target; refusal labels say what the engine checks; the ECB-price and cost limitations are no longer printed twice; every count has the Italian thousands separator. Command: Ctrl+C or SIGTERM cancels the run; the trial is recorded as failed with "Prova interrotta prima della fine: rilancia «anubis backtest baskets»." and the command exits 1; a trial that cannot start is failed instead of thrown, and an unexpected error ends with an Italian line, never a stack trace. The laboratory fails a leftover basket trial with an accurate message instead of "Strategia non più disponibile". The Table 6.5 test comment no longer claims each price is the only one that fits the row. The real report is regenerated on the same data and database as the first run, which now counts as a prior trial. refs #127 #129 #131 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3bee136c74
commit
a8defde572
15 files changed
+488
-143
No files matched your search
@@ -189,6 +189,42 @@ public sealed class BasketTrialEngineTests
|
||||
Assert.AreEqual(engine.Sessions, surrogate.Run(StrategyParameters.Of(BasketReversionFamily.Instance, "generation=2;signal=2;units=2;target=2.5;distance=4;exit=2")).Equity.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory(Category.Unit)]
|
||||
public void WithBidAndAskTheSurrogateKeepsTheSizeOfEveryMidChange()
|
||||
{
|
||||
// 15-minute EURUSD quotes two pips wide around a walking mid, from Tuesday 13 January 2026 20:00 UTC over four server
|
||||
// days whose signs alternate. The engine reads the mid: in the surrogate every change of the mid keeps its size and
|
||||
// the spread stays around it. Chained on the bid, the mid would jump by a whole spread at each change of sign.
|
||||
var first = new DateTimeOffset(2026, 1, 13, 20, 0, 0, TimeSpan.Zero);
|
||||
var walk = BasketSynthetic.Walk(200, 7, 0, 0.0004);
|
||||
var data = BasketSynthetic.Quarters(first, new Dictionary<string, (QuoteSide, QuoteSide)[]>
|
||||
{
|
||||
["EURUSD"] = [.. walk.Select(x => BasketSynthetic.Mid(Math.Round(1.1m * (decimal)Math.Exp(x), 5), 0.0002m))],
|
||||
});
|
||||
var market = BasketMarket.Of(data);
|
||||
var days = market.Day(market.Count - 1).DayNumber - market.Day(0).DayNumber + 1;
|
||||
Assert.IsTrue(days >= 3, $"{days} server days");
|
||||
var signs = new DaySigns(market.Day(0), [.. Enumerable.Range(0, days).Select(i => i % 2 == 0 ? 1 : -1)]);
|
||||
|
||||
var surrogate = market.Surrogate(signs, centred: false);
|
||||
|
||||
var before = market.Reference("EURUSD");
|
||||
var after = surrogate.Reference("EURUSD");
|
||||
var (bid, ask) = (surrogate.Bid("EURUSD").Close, surrogate.Ask("EURUSD")!.Close);
|
||||
var (bid0, ask0) = (market.Bid("EURUSD").Close, market.Ask("EURUSD")!.Close);
|
||||
var turned = 0;
|
||||
for (var t = 1; t < before.Count; t++)
|
||||
{
|
||||
Assert.AreEqual(Math.Abs(Math.Log(before[t] / before[t - 1])), Math.Abs(Math.Log(after[t] / after[t - 1])), 1e-7, $"bar {t}");
|
||||
Assert.IsTrue(bid[t] < ask[t], $"bar {t}");
|
||||
Assert.AreEqual((ask0[t] - bid0[t]) / before[t], (ask[t] - bid[t]) / after[t], 1e-6, $"bar {t}: the spread stays around the mid");
|
||||
turned += market.Day(t) != market.Day(t - 1) ? 1 : 0;
|
||||
}
|
||||
|
||||
Assert.IsTrue(turned >= 2, $"{turned} changes of sign");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory(Category.Unit)]
|
||||
public void TheFamilyHasOneIdForEverySubVariant()
|
||||
|
||||
Reference in new issue
Block a user