An independent review found these, now fixed and tested: - Risk limits could be raised through PUT /api/settings without the phrase and the password. The API now refuses risk keys. - The reference equity counted results twice after reduced to real and after a demotion. Each ledger now keeps a baseline, and carried results stay in the ledger's currency until the reference is computed. - An instrument could be bought by a second strategy in the same account (SPEC 8.6), and purchases under way did not hold their cash, so several purchases sent together could exceed it. Both are refused or shrunk now. - After an automatic trip of the switch there was no way to restart from the interface. Rischio now shows the trip of both worlds and the restart. - The fresh password of SPEC 12.4 could be tried without limit. Five wrong attempts in 15 minutes now lock it. - Observation to simulation skipped the 90 days of live signals. - A new build changed the qualification of a strategy with real money, "Ferma tutto" counted as a critical incident, raising risk ignored demotion conditions in progress, and weekends counted as stock sessions. - The 12.4 confirmation now summarises capital, first purchases and limits, and live strategies show the gap with their simulated twin. The backtest converts each bar with the rate fixed before it opens, the day before, and the report now counts how often correctives and risk changed a decision. crypto_trend is still not passed: the broad universe now falls 32.8%. The outcome file also keeps the qualified parameters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
17d6b8db38
commit
9ac159a7db
27 files changed
+1015
-532
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using Anubis.Core;
|
||||
using Anubis.Db;
|
||||
using Anubis.Risk;
|
||||
@@ -95,6 +96,17 @@ public sealed class StrategyScreensTests
|
||||
var services = server.Host.Services!;
|
||||
var daily = RiskSettings.DailyLoss.Key;
|
||||
|
||||
// Not through the API: there the order of the limits and the procedure of SPEC 12.4 would be skipped.
|
||||
var csrf = await server.Http.GetFromJsonAsync<Dictionary<string, string>>(new Uri("/api/antiforgery", UriKind.Relative));
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Put, new Uri("/api/settings/" + RiskSettings.DrawdownStop.Key, UriKind.Relative)) { Content = JsonContent.Create(new { value = "40" }) })
|
||||
{
|
||||
request.Headers.Add(csrf!["header"], csrf["token"]);
|
||||
using var put = await server.Http.SendAsync(request);
|
||||
Assert.AreEqual(HttpStatusCode.BadRequest, put.StatusCode);
|
||||
}
|
||||
|
||||
Assert.AreEqual("15", (await services.Settings.GetAsync(RiskSettings.DrawdownStop.Key, CancellationToken.None)).Value);
|
||||
|
||||
// Out of range, or the halving after the switch: nothing changes.
|
||||
using (var wrong = await server.PostFormAsync("/impostazioni", "/azioni/rischio/limiti", (daily, "50")))
|
||||
{
|
||||
@@ -175,5 +187,19 @@ public sealed class StrategyScreensTests
|
||||
}
|
||||
|
||||
Assert.AreEqual("active", await StateAsync());
|
||||
|
||||
// The switch tripped by itself in the simulation: the bot stays "active" elsewhere, and the page offers the restart.
|
||||
await services.Db.WriteAsync(s => s.ExecuteAsync("INSERT INTO risk_state (id, world, state, created_at, updated_at) VALUES (@id, 'simulated', @j, @t, @t)",
|
||||
CancellationToken.None, ("id", Guid.NewGuid()), ("j", new DbJson("{\"tripped\":true}")), ("t", DateTimeOffset.UtcNow)), CancellationToken.None);
|
||||
var page = await server.TextAsync("/rischio");
|
||||
StringAssert.Contains(page, "Interruttore scattato nel mondo simulato");
|
||||
StringAssert.Contains(page, "Riparti");
|
||||
using (var again = await server.PostFormAsync("/rischio", "/azioni/bot/riattiva", ("ritorno", "/rischio")))
|
||||
{
|
||||
Assert.IsFalse(ServerHarness.Location(again).Contains("errore", StringComparison.Ordinal), ServerHarness.Location(again));
|
||||
}
|
||||
|
||||
Assert.IsFalse(await services.Trading.Risk.AnyTrippedAsync(CancellationToken.None));
|
||||
Assert.AreEqual("active", await StateAsync());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user