Replay the past of a rebuilt account in its order

What an account did while the bot was off is now written before the splits and
the dividends of those days, once and without acting on it; an attempt cut
halfway is taken up from the same point. Until then the account is not valued
at today's price, the guard keeps the last figures it knew with their time,
and a stop order only cancels what is open. Protective sales of the archive
are not continued, and the rest of a stop that fired in part is sold.

Also the decisions of the phase (ADR 0020), the manuals and the dates under
the equity chart.

refs #69 #72 #75

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-01 22:58:08 +01:00
1 parent e58a26e8fa
commit 76b64ef147
31 files changed
+957 -130

No files matched your search

+32 -1
View File
@@ -152,7 +152,8 @@ internal sealed partial class AnubisHost(
/// <summary>
/// A choice that failed or was cut halfway leaves nothing open that could create the missing file, and what it had
/// begun to write steps aside: moved and not deleted, because in the meantime the true file may have come back.
/// begun to write steps aside, moved and not deleted. In the meantime the true file may have come back: that one is
/// not touched, and the loop finds it.
/// </summary>
internal async Task AbandonChoiceAsync()
{
@@ -165,6 +166,11 @@ internal sealed partial class AnubisHost(
_db = null;
_createdByChoice = false;
var path = Config.Db!.SqlitePath!;
if (!File.Exists(path) || !await IsLeftoverAsync().ConfigureAwait(false))
{
return;
}
var aside = path + ".incompleto-" + clock.UtcNow.ToString("yyyyMMdd-HHmmss", System.Globalization.CultureInfo.InvariantCulture);
foreach (var part in new[] { "", "-wal", "-shm" })
{
@@ -182,6 +188,31 @@ internal sealed partial class AnubisHost(
}
}
/// <summary>
/// A file a choice left halfway: without an installation, or with the sealed one of an import not renewed yet. One
/// that cannot be read is not certainly that.
/// </summary>
private async Task<bool> IsLeftoverAsync()
{
try
{
await using var db = Database.Open(Config.Db!, allowCreate: false);
if ((await Migrations.StatusAsync(db, CancellationToken.None).ConfigureAwait(false)).IsEmpty)
{
return true;
}
var row = await Installation.ReadRowAsync(db, CancellationToken.None).ConfigureAwait(false);
return row is null ? !await Installation.HasDataAsync(db, CancellationToken.None).ConfigureAwait(false)
: row.ProtectedRestart && row.Fingerprint != Installation.ReadFile(Config.Data)?.Fingerprint;
}
catch (Exception ex) when (ex is System.Data.Common.DbException or IOException or UnauthorizedAccessException or InvalidOperationException or InvalidDataException)
{
LogStepFailed(logger, ex);
return false;
}
}
/// <summary>The choice is done: the database it opened is the one in use.</summary>
internal void KeepChoice() => _createdByChoice = false;