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
@@ -294,7 +294,7 @@ internal static partial class Forms
|
||||
}
|
||||
|
||||
/// <summary>The capital entrusted to a broker, in euro (SPEC 7.1, 8.6): only the user sets it.</summary>
|
||||
private static async Task<IResult> SetCapitalAsync(string broker, IFormCollection form, AnubisHost host, HttpContext context, CancellationToken ct)
|
||||
private static async Task<IResult> SetCapitalAsync(string broker, IFormCollection form, AnubisHost host, IClock clock, HttpContext context, CancellationToken ct)
|
||||
{
|
||||
const string back = "/impostazioni";
|
||||
if (broker is not (Anubis.Data.Venues.Okx or Anubis.Data.Venues.Alpaca))
|
||||
@@ -314,7 +314,7 @@ internal static partial class Forms
|
||||
|
||||
// More capital while a strategy of this broker has real money is more risk: it needs the procedure (SPEC 12.4).
|
||||
if ((await trading.Capital.EntrustedAsync(broker, ct).ConfigureAwait(false))?.AmountEur is { } before && amount > before &&
|
||||
await RaiseRefusalAsync(host.Services!, broker, form, ct).ConfigureAwait(false) is { } refusal)
|
||||
await RaiseRefusalAsync(host.Services!, clock, broker, form, ct).ConfigureAwait(false) is { } refusal)
|
||||
{
|
||||
return Results.Redirect(back + "?errore=" + refusal + "#conti");
|
||||
}
|
||||
@@ -392,6 +392,8 @@ internal static partial class Forms
|
||||
"phrase" => "frase",
|
||||
"password" => "password",
|
||||
"requirements" => "requisiti",
|
||||
"backtest" => "backtest",
|
||||
"observation" => "osservazione-giorni",
|
||||
"account" => "conto",
|
||||
Anubis.Risk.RiskReasons.NoConsent => "consenso",
|
||||
_ => "scelta",
|
||||
@@ -404,7 +406,7 @@ internal static partial class Forms
|
||||
/// The risk limits (SPEC 9.2, 13.5), all at once. Lowering is always allowed; raising any of them while a strategy
|
||||
/// has real money needs the phrase, the password and the second factor (SPEC 12.4).
|
||||
/// </summary>
|
||||
private static async Task<IResult> SetLimitsAsync(IFormCollection form, AnubisHost host, HttpContext context, CancellationToken ct)
|
||||
private static async Task<IResult> SetLimitsAsync(IFormCollection form, AnubisHost host, IClock clock, HttpContext context, CancellationToken ct)
|
||||
{
|
||||
const string back = "/impostazioni";
|
||||
if (host.IsDemo || host.Services is not { } services)
|
||||
@@ -440,7 +442,7 @@ internal static partial class Forms
|
||||
|
||||
if (Anubis.Risk.RiskSettings.From(k => current[k]).RaisedBy(limits))
|
||||
{
|
||||
if (await RaiseRefusalAsync(services, null, form, ct).ConfigureAwait(false) is { } refusal)
|
||||
if (await RaiseRefusalAsync(services, clock, null, form, ct).ConfigureAwait(false) is { } refusal)
|
||||
{
|
||||
return Results.Redirect(back + "?errore=" + refusal + "#rischio");
|
||||
}
|
||||
@@ -469,9 +471,10 @@ internal static partial class Forms
|
||||
}
|
||||
|
||||
/// <summary>Null when more risk may go ahead; otherwise the error code for the page.</summary>
|
||||
private static async Task<string?> RaiseRefusalAsync(AppServices services, string? broker, IFormCollection form, CancellationToken ct)
|
||||
private static async Task<string?> RaiseRefusalAsync(AppServices services, IClock clock, string? broker, IFormCollection form, CancellationToken ct)
|
||||
{
|
||||
var stages = services.Trading?.Stages ?? new Anubis.Trading.StageBook(services.Db, new SystemClock(), Anubis.Trading.TradingConsent.None, (_, _, _) => Task.FromResult(false));
|
||||
// Without the trading engine no strategy can hold real money, so the stage book only has to say so.
|
||||
var stages = services.Trading?.Stages ?? new Anubis.Trading.StageBook(services.Db, clock, Anubis.Trading.TradingConsent.None, (_, _, _) => Task.FromResult(false));
|
||||
try
|
||||
{
|
||||
var code = form["codice"].ToString();
|
||||
@@ -480,7 +483,12 @@ internal static partial class Forms
|
||||
}
|
||||
catch (Anubis.Trading.LiveConfirmationException ex)
|
||||
{
|
||||
return ex.Code == "phrase" ? "frase-rischio" : "password-rischio";
|
||||
return ex.Code switch
|
||||
{
|
||||
"phrase" => "frase-rischio",
|
||||
"demotion" => "retrocessione-rischio",
|
||||
_ => "password-rischio",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user