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:
1 parent
e58a26e8fa
commit
76b64ef147
31 files changed
+957
-130
No files matched your search
@@ -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;
|
||||
|
||||
|
||||
@@ -310,6 +310,9 @@ legend { display: flex; align-items: center; gap: 10px; font-size: 17px; font-we
|
||||
.chart-axis { position: relative; }
|
||||
.chart-axis span { position: absolute; left: 0; transform: translateY(-50%); color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; }
|
||||
.chart-plot { position: relative; }
|
||||
.chart-days { position: relative; height: 18px; margin: 8px 84px 0 64px; }
|
||||
.chart-days span { position: absolute; transform: translateX(-50%); color: var(--text-3); font-size: 13px; white-space: nowrap; }
|
||||
.chart-days span:first-child { transform: none; }
|
||||
.chart-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
|
||||
.chart .grid { stroke: var(--rule-inner); stroke-width: 1; }
|
||||
.chart .area { fill: var(--text); opacity: .05; }
|
||||
@@ -796,7 +799,7 @@ legend { display: flex; align-items: center; gap: 10px; font-size: 17px; font-we
|
||||
.head-block { grid-template-columns: 1fr; gap: 14px; padding: 0; background: none; border: 0; }
|
||||
.half { padding: 18px; background: var(--surface); border: 1px solid var(--rule); border-radius: 14px; }
|
||||
.half + .half { border-left: 1px solid var(--rule); }
|
||||
.segmented, .cell-change, .cell-extra, .long, .chart-axis { display: none; }
|
||||
.segmented, .cell-change, .cell-extra, .long, .chart-axis, .chart-days { display: none; }
|
||||
.lead { margin-top: 12px; }
|
||||
.big-result { gap: 12px; }
|
||||
.big-number { font-size: 46px; line-height: 48px; }
|
||||
|
||||
@@ -48,6 +48,12 @@
|
||||
<span class="end-label" style="top:@Pct(Y(last) / 10)">@Text(Points[^1].Equity, 0)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chart-days" aria-hidden="true">
|
||||
@foreach (var i in Days())
|
||||
{
|
||||
<span style="left:@Pct(X(i) / 10)">@Format.AxisDay(Points[i].Day, Points[^1].Day.DayNumber - Points[0].Day.DayNumber)</span>
|
||||
}
|
||||
</div>
|
||||
<figcaption class="legend">
|
||||
<span class="key key-equity">@EquityLabel</span>
|
||||
@if (benchLine.Length > 0)
|
||||
@@ -102,6 +108,9 @@
|
||||
|
||||
private string Text(decimal amount, int decimals = 2) => Native ? Format.Money(amount, Currency, decimals: decimals) : Shell.Money(amount, Currency, decimals: decimals);
|
||||
|
||||
// Five dates at even distances, first and last included; fewer when there are not enough days.
|
||||
private IEnumerable<int> Days() => Enumerable.Range(0, 5).Select(i => i * (Points.Count - 1) / 4).Distinct();
|
||||
|
||||
private static string Fmt(double v) => v.ToString("0.##", CultureInfo.InvariantCulture);
|
||||
|
||||
private static string Pct(double v) => v.ToString("0.###", CultureInfo.InvariantCulture) + "%";
|
||||
|
||||
Reference in new issue
Block a user