Fix the defects found by the Phase 3 review (refs #33 #26 #27 #28 #29 #30 #31 #32)
ci / test (postgres) (push) Successful in 3m9s
ci / test (sqlite) (push) Successful in 2m28s
ci / test (postgres) (pull_request) Successful in 4m1s
ci / test (sqlite) (pull_request) Failing after 2m31s
ci / image (pull_request) Skipped
ci / image (push) Successful in 1m34s

- Splits multiply only the shares held before the ex-date. Old splits in
  the table no longer inflate positions bought later; the simulator's book
  follows the same split once, together with the ledger.
- Dividends pay the simulator once on the ex-date holdings, and each
  payment is marked in the same write, so a failure never pays twice.
- Positions are marked to market before every equity photograph; until
  now equity, drawdown and the Conti screen stayed at the last fill.
- A sale with no price keeps its broker stops until it can really leave;
  a purchase with no price is dropped.
- A refused sale is retried with pauses of 1, 2, 4, 8 and 15 minutes
  instead of every tick, and one failing execution no longer stops the
  stop alignment of the whole account.
- On Alpaca a purchase clears the sell stops of every strategy on the
  symbol and holds them until it ends.
- OKX order lookups treat only 51603 as unknown; any other failure is an
  error, so a lost order is never sent twice.
- The reconcile choice and key removal forms now require the antiforgery
  token; the choice re-runs the comparison and is only offered after the
  15 minutes; stale differences are dropped.
- A replaced key that cannot withdraw releases the prudent mode.
- Re-entering the same euro capital for Alpaca changes nothing; a new
  amount converts only the euro difference at today's rate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-10 21:47:36 +01:00
1 parent 60d5ebbc05
commit 1a0912e436
17 files changed
+358 -89

No files matched your search

@@ -355,6 +355,7 @@ else
("escludi", _) => ("Fatto: la differenza resta fuori dal registro e il conto è tornato normale.", true),
(_, "motore") => ("Il motore di trading non è attivo: riprova tra poco.", false),
(_, "chiave") => ("Una chiave che permette i prelievi non si allinea: va sostituita in Impostazioni.", false),
(_, "presto") => ("La scelta si fa dopo 15 minuti di modalità prudente: prima la differenza può ancora spiegarsi da sola.", false),
(_, { }) => ("Non è stato possibile completare la scelta: riprova.", false),
_ => (null, false),
};
+9 -2
View File
@@ -177,7 +177,8 @@ internal static partial class Forms
}
/// <summary>The user's choice for an account in prudent mode after the 15 minutes (SPEC 7.4): align or leave out.</summary>
private static async Task<IResult> ResolveAccountAsync(Guid id, string choice, AnubisHost host, HttpContext context, CancellationToken ct)
// The form is bound even when unused: binding it is what makes the antiforgery check run on the route.
private static async Task<IResult> ResolveAccountAsync(Guid id, string choice, IFormCollection form, AnubisHost host, IClock clock, HttpContext context, CancellationToken ct)
{
if (choice is not ("allinea" or "escludi"))
{
@@ -195,6 +196,12 @@ internal static partial class Forms
return Results.Redirect("/conti?errore=chiave");
}
if (!state.WaitsForUser(clock.UtcNow, trading.Reconciler.Grace))
{
// The choice exists only after the 15 minutes (SPEC 7.4): before, the difference may still explain itself.
return Results.Redirect("/conti?errore=presto");
}
await trading.Reconciler.ResolveAsync(manager, choice == "allinea" ? Anubis.Trading.ReconcileChoice.Align : Anubis.Trading.ReconcileChoice.Exclude,
context.User.Identity?.Name ?? "utente", ct).ConfigureAwait(false);
return Results.Redirect("/conti?ok=" + choice);
@@ -263,7 +270,7 @@ internal static partial class Forms
return Results.Redirect(back + "?ok=chiavi#conti");
}
private static async Task<IResult> RemoveKeysAsync(string broker, AnubisHost host, HttpContext context, CancellationToken ct)
private static async Task<IResult> RemoveKeysAsync(string broker, IFormCollection form, AnubisHost host, HttpContext context, CancellationToken ct)
{
const string back = "/impostazioni";
if (broker is not (Anubis.Data.Venues.Okx or Anubis.Data.Venues.Alpaca) || host.IsDemo || host.Services is not { } services)