Fix the defects of the Phase 5 review (refs #41 #42 #43 #44 #45 #46)
ci / test (postgres) (push) Successful in 3m52s
ci / test (sqlite) (push) Failing after 2m41s
ci / image (push) Skipped

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:
Alby96andClaude Opus 5.5 committed 2026-11-11 16:48:41 +01:00
1 parent 17d6b8db38
commit 9ac159a7db
27 files changed
+1015 -532

No files matched your search

+12
View File
@@ -133,6 +133,13 @@ internal static partial class Endpoints
return Error(StatusCodes.Status400BadRequest, "usa_i_comandi", "Lo stato del bot si cambia con pausa, ripresa e Ferma tutto.");
}
// Risk limits go only through the settings page, which checks their order and asks for the confirmation of
// SPEC 12.4 when a limit goes up while a strategy uses real money: the check holds on the API too.
if (Anubis.Risk.RiskSettings.All.Any(d => d.Key == key))
{
return Error(StatusCodes.Status400BadRequest, "usa_le_impostazioni", "I limiti di rischio si cambiano da Impostazioni, con la conferma quando servono soldi veri.");
}
return await SetSettingAsync(host, key, body.Value, context, ct).ConfigureAwait(false);
});
@@ -252,6 +259,10 @@ internal static partial class Endpoints
{
var settings = host.Services!.Settings;
var current = (await settings.GetAsync(SettingsStore.BotState.Key, ct).ConfigureAwait(false)).Value;
// A switch tripped by the fall from the high stops only its world and leaves the bot "active": the restart is
// the user's confirmation for that world too (SPEC 9.2, 9.3).
var tripped = host.Services.Trading?.Risk is { } engine && await engine.AnyTrippedAsync(ct).ConfigureAwait(false);
var target = command switch
{
"pause" or "pausa" when current == "active" => "paused",
@@ -259,6 +270,7 @@ internal static partial class Endpoints
"stop" or "ferma" => "stopped",
"close" or "chiudi" => "stopped",
"restart" or "riattiva" when current == "stopped" => "active",
"restart" or "riattiva" when tripped => current,
_ => null,
};
if (target is null)