Fix what the review of Phase 9 found in accounts, access, capital, health and publication
A position left out together with its stop kept the account prudent for good: the stop was still asked for shares that no longer exist. The cover required now stops at what the account holds, the stops are compared again after the choice, and where one is still missing Align takes the excluded position up again. After the choice the account waits for the stop with its own reason, so it returns to normal by itself also past the 15 minutes; a new difference still gets its own 15 minutes. A right password alone no longer clears the wrong second-factor codes: it takes back only its own attempt. Capital and shares are planned and written in one transaction, so overlapping changes cannot apply twice and an interruption leaves nothing halfway; sending the same figures again completes what an old one left. The cash that purchases under way still hold is no longer given away, counted as the risk engine counts it. /health said healthy when the trading engine had failed to start. It now says so at once, or after ten minutes of a stalled start, and the host tries the start again every minute; the guard still sees a start that does not move. The image of the manual publication says its version and its commit, marked when the tree is dirty, and publish.sh refuses before any login an image that does not come from the commit of the tag. refs #75 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
24e20584d4
commit
81d6c5f667
20 files changed
+814
-174
No files matched your search
@@ -62,7 +62,8 @@ internal static partial class Endpoints
|
||||
|
||||
checks["scheduler"] = host.SchedulerRunning ? "ok" : "fermo";
|
||||
healthy &= host.SchedulerRunning;
|
||||
var (loop, loopOk) = HealthRules.Loop(host.Clock.UtcNow, services.Trading is { IsStarted: true }, services.Trading?.LastTurnAt);
|
||||
var (loop, loopOk) = HealthRules.Loop(host.Clock.UtcNow, services.Trading is null ? null : status.Since, services.Trading is { IsStarted: true },
|
||||
services.Trading is { StartFailed: true }, services.Trading?.LastTurnAt);
|
||||
var (feed, feedOk) = HealthRules.Feed(host.Clock.UtcNow, services.MarketData?.LiveFeed.Since, services.MarketData?.LiveFeed.LastDataAt);
|
||||
checks["motore"] = loop;
|
||||
checks["dati"] = feed;
|
||||
@@ -540,14 +541,19 @@ internal static class HealthRules
|
||||
/// <summary>The same silence after which the guard steps in (SPEC 9.3).</summary>
|
||||
public static readonly TimeSpan LoopLimit = TimeSpan.FromMinutes(2);
|
||||
|
||||
/// <summary>A start of the engine this long is stalled, as for the guard (SPEC 9.3).</summary>
|
||||
public static readonly TimeSpan StartLimit = TimeSpan.FromMinutes(10);
|
||||
|
||||
/// <summary>Longer than the silence that blocks new entries (SPEC 6.5): a line that drops for a moment is not an ill container.</summary>
|
||||
public static readonly TimeSpan FeedLimit = TimeSpan.FromMinutes(5);
|
||||
|
||||
public static (string Text, bool Ok) Loop(DateTimeOffset now, bool started, DateTimeOffset? lastTurn) => (started, lastTurn) switch
|
||||
/// <summary>The engine's loop; <paramref name="since"/> is when the services became ready, null where there is no engine to start.</summary>
|
||||
public static (string Text, bool Ok) Loop(DateTimeOffset now, DateTimeOffset? since, bool started, bool failed, DateTimeOffset? lastTurn) => (since, started, lastTurn) switch
|
||||
{
|
||||
(false, _) => ("non avviato", true),
|
||||
(_, null) => ("in avvio", true),
|
||||
(_, { } at) when now - at > LoopLimit => ("fermo", false),
|
||||
(null, _, _) => ("non avviato", true),
|
||||
({ } from, false, _) when failed || now - from > StartLimit => ("non avviato", false),
|
||||
(_, false, _) or (_, _, null) => ("in avvio", true),
|
||||
(_, _, { } at) when now - at > LoopLimit => ("fermo", false),
|
||||
_ => ("ok", true),
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user