Rebuild the state from the brokers after a restore and refuse an older copy
A restore, an import or an adopted database restarts protected: the engine stays stopped, reads from the broker what the archive does not know (orders, stops, executions, also from the OKX history up to 89 days), cancels orders left working, protects what it finds and waits for the user. Strategies with real money stay exit only until confirmed again. The database of before the restore, put back by mistake, is refused by its fingerprint. A failed migration leaves the engine off with one backup and a way to try again; an archive is checked whole before the database is touched; a changed secret key no longer crashes anything, and "anubis access reset" gives the access back to whoever holds the computer. The image runs the db and access commands without the guard. refs #69 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3da9b00f44
commit
4897594b87
40 files changed
+1871
-90
No files matched your search
@@ -18,6 +18,9 @@
|
||||
case IdentityVerdict.DifferentInstallation:
|
||||
<p>Il database appartiene a un'altra installazione di Anubis. Il motore resta spento: due registri sugli stessi conti produrrebbero ordini doppi.</p>
|
||||
break;
|
||||
case IdentityVerdict.MissingFile:
|
||||
<p>Il database appartiene a un'installazione, ma la cartella dei dati non ha il suo file d'identità: non posso sapere se questo database è quello giusto o una copia vecchia. Il motore resta spento finché non lo dici tu.</p>
|
||||
break;
|
||||
case IdentityVerdict.StaleDatabase:
|
||||
<p>È il database di questa installazione, ma una copia più vecchia: dopo l'ultimo ripristino o spostamento ne è nata una più recente. Il motore resta spento per non lavorare su dati superati.</p>
|
||||
break;
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
{
|
||||
"password" => "Password sbagliata. Riprova: dopo 5 tentativi sbagliati l'accesso si blocca per 15 minuti.",
|
||||
"codice" => "Il codice non è giusto o è scaduto. Usa quello che l'app mostra adesso.",
|
||||
"chiave" => "La password è giusta, ma la chiave dei segreti (ANUBIS_SECRET_KEY) non è più quella di prima e il codice non si può controllare. Rimetti la vecchia chiave, oppure azzera l'accesso dal computer che ospita Anubis: il manuale dice come.",
|
||||
"attesa" => $"Troppi tentativi sbagliati. Riprova tra {Minuti ?? "15"} minuti.",
|
||||
_ => null,
|
||||
};
|
||||
|
||||
@@ -812,6 +812,7 @@
|
||||
private string KeyState(SecretStatus status) => status switch
|
||||
{
|
||||
{ FromEnvironment: true } => "Dalle variabili d'ambiente",
|
||||
{ Unreadable: true } => "Non si legge più: la chiave dei segreti è cambiata, inseriscila di nuovo",
|
||||
{ IsSet: true, UpdatedAt: { } at } => "Impostata " + Inline(Format.ShortDate(at, Shell.Now, Shell.Zone)),
|
||||
{ IsSet: true } => "Impostata",
|
||||
_ => "Non impostata",
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
var phoneMoves = moves.Select((m, i) => (m, i)).Where(x => !x.m.Calendar).Take(2).Select(x => x.i).ToHashSet();
|
||||
var v = p.Accounts;
|
||||
}
|
||||
@if (p.ProtectedRestart)
|
||||
{
|
||||
<div class="notice notice-attention" role="status"><Icon Name="alert" Size="16" /><span><strong>Ripartenza protetta.</strong> Dopo un ripristino o un'importazione sono fermo: non apro posizioni finché non hai controllato e non confermi dalla pagina <a href="/rischio">Rischio</a>.</span></div>
|
||||
}
|
||||
@if (_absence is { } away)
|
||||
{
|
||||
<div class="notice notice-attention absence" role="status">
|
||||
|
||||
@@ -22,6 +22,34 @@
|
||||
<h2 id="interruttore">Interruttore d'emergenza</h2>
|
||||
<span class="link-state @(v.BotState == "active" ? null : "down")"><span class="dot"></span>@BotText(v.BotState)</span>
|
||||
</div>
|
||||
@if (v.ProtectedRestart is { } restart)
|
||||
{
|
||||
<div class="notice notice-attention" role="status"><Icon Name="alert" Size="16" /><div>
|
||||
<p><strong>Ripartenza protetta.</strong> Il database è cambiato il @Moment(restart.Since) (ripristino, importazione o copia più vecchia del conto): prima di ripartire guarda cosa ho ricostruito.</p>
|
||||
<ul>
|
||||
@foreach (var line in restart.Rebuilt)
|
||||
{
|
||||
<li>@line</li>
|
||||
}
|
||||
@if (restart.Working)
|
||||
{
|
||||
<li>Sto ancora leggendo i conti.</li>
|
||||
}
|
||||
else if (restart.Waiting.Count > 0)
|
||||
{
|
||||
<li>Non ho ancora letto: @string.Join(", ", restart.Waiting). Riprovo ogni minuto; se una chiave è scaduta, cambiala nelle Impostazioni.</li>
|
||||
}
|
||||
else if (restart.Rebuilt.Count == 0)
|
||||
{
|
||||
<li>Sui conti non c'era niente che il database non conoscesse già.</li>
|
||||
}
|
||||
@if (restart.ToReconfirm.Count > 0)
|
||||
{
|
||||
<li>Da riconfermare nella pagina Strategie, altrimenti restano in sola uscita: @string.Join(", ", restart.ToReconfirm).</li>
|
||||
}
|
||||
</ul>
|
||||
</div></div>
|
||||
}
|
||||
@if (v.WaitsForRestart)
|
||||
{
|
||||
<p class="notice notice-attention" role="status"><Icon Name="alert" Size="16" /><span>
|
||||
@@ -51,7 +79,7 @@
|
||||
<form method="post" action="/azioni/bot/riattiva" class="form-inline">
|
||||
<AntiforgeryToken />
|
||||
<input type="hidden" name="ritorno" value="/rischio" />
|
||||
<button class="btn" type="submit" disabled="@v.StopFile" data-confirm="@RestartText(v)">Riparti</button>
|
||||
<button class="btn" type="submit" disabled="@(v.StopFile || v.ProtectedRestart is { CanRestart: false })" data-confirm="@RestartText(v)">Riparti</button>
|
||||
</form>
|
||||
}
|
||||
}
|
||||
@@ -293,7 +321,9 @@
|
||||
|
||||
private static string Where(string world) => world == Worlds.Real ? "sui conti veri" : "nel mondo simulato";
|
||||
|
||||
private static string RestartText(RiskView v) => v.Tripped.Count > 0
|
||||
private static string RestartText(RiskView v) => v.ProtectedRestart is not null
|
||||
? "Riparti dopo il ripristino: hai controllato posizioni e operazioni ricostruite? Il bot torna a operare; le strategie con soldi veri restano in sola uscita finché non le riconfermi. Confermi?"
|
||||
: v.Tripped.Count > 0
|
||||
? "Riparti: il massimo di riferimento riparte dal patrimonio di adesso e il bot torna a operare. Confermi?"
|
||||
: "Riparti: il bot torna a operare. Confermi?";
|
||||
|
||||
|
||||
@@ -65,6 +65,25 @@
|
||||
|
||||
case HostMode.SchemaProblem:
|
||||
<p>@_status.Detail</p>
|
||||
@if (Host.MigrationFailed is not null)
|
||||
{
|
||||
var copies = new Backups(Host.Config.Data, Clock).List();
|
||||
<p>Il motore resta spento.
|
||||
@if (copies.Count > 0)
|
||||
{
|
||||
<text>L'ultimo salvataggio è <code>@copies[0].Name</code>, in <code>@Host.Config.Data.Backups</code>: per tornarci, indica nella configurazione un database nuovo e vuoto e sceglilo in questa pagina.</text>
|
||||
}
|
||||
Se il problema è passeggero (spazio sul disco, permessi), risolvilo e riprova.</p>
|
||||
@if (Host.Config.Platform == PlatformKind.Docker || _local)
|
||||
{
|
||||
<form method="post" action="/azioni/servizio/riprova" class="form">
|
||||
<AntiforgeryToken />
|
||||
<AdminPassword Docker="Host.Config.Platform == PlatformKind.Docker" />
|
||||
<button class="btn btn-primary" type="submit">Riprova l'aggiornamento</button>
|
||||
</form>
|
||||
}
|
||||
break;
|
||||
}
|
||||
<p>Per non rovinare i dati il motore resta spento. Aggiorna Anubis alla versione che ha creato questo database, oppure ripristina un salvataggio in un database vuoto.</p>
|
||||
break;
|
||||
|
||||
@@ -82,7 +101,7 @@
|
||||
<p class="notice notice-loss" role="alert"><Icon Name="alert" Size="16" />@(errore switch
|
||||
{
|
||||
"password" => "Password della configurazione d'avvio sbagliata, oppure scelta fatta da un altro computer.",
|
||||
"importazione" => "Il ripristino non è riuscito e non ho cambiato nulla. Controlla l'archivio e riprova.",
|
||||
"importazione" => "Non ci sono riuscito e nessun dato a metà è in uso. Controlla l'archivio o guarda i log, poi riprova.",
|
||||
"attesa" => "Troppi tentativi sbagliati. Riprova tra 15 minuti.",
|
||||
_ => "Questa scelta non è disponibile adesso.",
|
||||
})</p>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
var up = s.ResultEur >= 0;
|
||||
<section class="panel strategy" aria-label="@s.Name">
|
||||
<div class="strategy-about">
|
||||
<h2><span class="swatch round" style="background: @s.Color"></span>@s.Name <span class="tag">@(s.Stage.ExitOnly ? "Sola uscita" : "In " + StrategyStages.Label(s.Stage.Stage).ToLower(CultureInfo.GetCultureInfo("it-IT")))</span></h2>
|
||||
<h2><span class="swatch round" style="background: @s.Color"></span>@s.Name <span class="tag">@(s.Stage.WaitsForReconfirmation ? "Da riconfermare" : s.Stage.ExitOnly ? "Sola uscita" : "In " + StrategyStages.Label(s.Stage.Stage).ToLower(CultureInfo.GetCultureInfo("it-IT")))</span></h2>
|
||||
<p>@s.Description</p>
|
||||
<ul>
|
||||
@foreach (var rule in s.Rules)
|
||||
@@ -92,7 +92,30 @@
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
@if (s.Stage.ExitOnly)
|
||||
@if (s.Stage.WaitsForReconfirmation)
|
||||
{
|
||||
<p class="notice notice-attention"><Icon Name="alert" Size="16" />Dopo un ripristino non compra con soldi veri finché non la riconfermi: vende e tiene gli stop. I giorni e i conteggi restano quelli di prima.</p>
|
||||
@if (!Shell.IsDemo)
|
||||
{
|
||||
<details class="confirm-live">
|
||||
<summary class="btn">Riconferma</summary>
|
||||
<form method="post" action="/azioni/strategie/@s.Stage.Strategy/riconferma" class="form-grid">
|
||||
<AntiforgeryToken />
|
||||
<p>Ecco con che cosa riprende <strong>@s.Name</strong>:</p>
|
||||
<ul class="confirm-summary">
|
||||
@foreach (var line in s.Summary)
|
||||
{
|
||||
<li>@line</li>
|
||||
}
|
||||
</ul>
|
||||
<label>Password<input name="password" type="password" required autocomplete="current-password" /></label>
|
||||
<label>Codice a sei cifre (se attivo)<input name="codice" inputmode="numeric" autocomplete="one-time-code" /></label>
|
||||
<button class="btn btn-danger" type="submit">Riconferma soldi veri</button>
|
||||
</form>
|
||||
</details>
|
||||
}
|
||||
}
|
||||
else if (s.Stage.ExitOnly)
|
||||
{
|
||||
<p class="notice notice-attention"><Icon Name="alert" Size="16" />Tornata indietro con posizioni vere ancora aperte: le gestisce fino a zero, con i loro stop, senza nuovi acquisti.</p>
|
||||
}
|
||||
@@ -220,6 +243,7 @@
|
||||
("simulazione", _) => ("Fatto: la strategia è in simulazione, con ordini finti su prezzi veri.", true),
|
||||
("osservazione", _) => ("Fatto: la strategia è in osservazione.", true),
|
||||
("reale", _) => ("Fatto: la strategia usa soldi veri da adesso. Se peggiora torna indietro da sola.", true),
|
||||
("riconferma", _) => ("Fatto: la strategia è riconfermata e torna a operare con soldi veri.", true),
|
||||
(_, "backtest") => ("Solo una strategia che ha superato il backtest può andare in simulazione.", false),
|
||||
(_, "osservazione-giorni") => ($"Prima della simulazione servono almeno {StageBook.ObservationDays} giorni di segnali raccolti dal vivo in osservazione.", false),
|
||||
(_, "frase") => ("La frase non corrisponde: scrivila esattamente come è mostrata.", false),
|
||||
|
||||
Reference in new issue
Block a user