Compute the improvements of 8.7 in shadow on the examples

Each improvement is measured on the signals the bot already collects, in its own
savepoint after the decision, so no order depends on it: the correlation filter,
the volatility cap, the sector cap, the market filter, the entry time and the
choice of the model. The laboratory shows how many cases each one has and how far
to trust it. Sectors come from the SEC only with a contact given by the user.

refs #74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-01 20:31:15 +01:00
1 parent fb0ab223a5
commit 79bb194de0
14 files changed
+1150 -43

No files matched your search

@@ -456,6 +456,9 @@
<p class="hint">Senza chiave di Finnhub non conosco le date delle trimestrali e la mean reversion non usa il suo filtro; senza chiave di FRED il calendario usa solo Forex Factory. Le chiavi sono gratuite.</p>
@DataKey("FINNHUB_API_KEY", "Chiave di Finnhub")
@DataKey("FRED_API_KEY", "Chiave di FRED")
<h3>Settori delle società</h3>
<p class="hint">Facoltativo. La SEC, l'ente che controlla la borsa americana, chiede a chi legge i suoi archivi un contatto, di solito un indirizzo e-mail: se lo scrivi qui va solo alla SEC, dentro ogni richiesta, e serve a conoscere il settore delle azioni per una delle migliorie in osservazione. Senza, non chiedo niente.</p>
@DataKey(Anubis.Data.Edgar.ContactSecret, "Contatto per la SEC")
<h3>Riunioni di Fed e BCE</h3>
<form method="post" action="/azioni/impostazioni/@SettingsStore.CentralBankMeetings.Key" class="form">
<AntiforgeryToken />
@@ -167,10 +167,31 @@
<section class="panel" aria-labelledby="migliorie">
<h2 id="migliorie">Migliorie in osservazione</h2>
<div class="empty">
<p class="empty-title">Nessuna miglioria in osservazione.</p>
<p>Le modifiche che potrebbero migliorare il risultato o ridurre i costi si calcolano in ombra accanto alle regole in vigore e compaiono qui con l'effetto che avrebbero avuto. Arrivano con la Fase 9.</p>
<p class="hint">Modifiche che potrebbero migliorare il risultato o ridurre i costi. Nessuna è attiva: si calcolano accanto alle regole in vigore, su ogni segnale, e qui c'è l'effetto che avrebbero avuto. Per attivarne una servono il protocollo di validazione superato e una tua decisione.</p>
<div class="table-wrap">
<table class="table">
<thead><tr><th scope="col">Miglioria</th><th scope="col" class="num">Segnali esaminati</th><th scope="col" class="num">Cambiati</th><th scope="col">Effetto medio a segnale</th><th scope="col">Affidabilità</th><th scope="col">Stato</th></tr></thead>
<tbody>
@foreach (var m in _improvements)
{
<tr>
<td><strong>@m.Improvement.Name</strong><br /><span class="note">@m.Improvement.What</span>@if (m.Note is not null) {<br /><span class="note">@m.Note</span>}</td>
<td class="num">@m.Examined</td>
<td class="num">@(m.Lines.Max(l => l.Cases))</td>
<td>
@foreach (var l in m.Lines)
{
<div>@(l.Label is null ? "" : l.Label + ": ")@(l.Mean is { } mean ? Anubis.Learning.ImprovementText.Percent(mean) : "—")@if (l.Interval is { } i) {<span class="note"> tra @Anubis.Learning.ImprovementText.Percent(i.Low) e @Anubis.Learning.ImprovementText.Percent(i.High)</span>}</div>
}
</td>
<td>@(m.Lines.Max(l => l.Cases) == 0 ? "—" : m.Trust)</td>
<td class="@(m.Waiting ? "attention-text" : null)">@m.State</td>
</tr>
}
</tbody>
</table>
</div>
<p class="note">L'effetto è una quota di quanto il segnale avrebbe investito: +0,10% vuol dire un euro in più ogni mille. L'intervallo contiene il valore vero 95 volte su 100.</p>
</section>
<section class="panel" aria-labelledby="stime">
@@ -236,6 +257,7 @@
private DateOnly _to;
private IReadOnlyList<string> _research = [];
private IReadOnlyList<CostEstimate> _costs = [];
private IReadOnlyList<Anubis.Learning.ImprovementView> _improvements = [];
private bool _anyLive;
private SlippageTable _table = SlippageTable.Standard;
@@ -258,6 +280,11 @@
_costs = await costs.ListAsync(ct);
_table = await costs.TableAsync(ct);
_anyLive = await (services.Trading?.Stages ?? new StageBook(services.Db, Clock, TradingConsent.None, (_, _, _) => Task.FromResult(false))).AnyLiveAsync(null, ct);
var learning = new Anubis.Learning.LearningDesk(services.Db, Clock, services.Settings);
var champion = await learning.Models.FindAsync(Anubis.Learning.ModelStatuses.Champion, ct);
async Task<bool> HasAsync(string secret) => (await services.Secrets.StatusAsync(secret, ct)).IsSet;
_improvements = await learning.Shadow.LoadAsync(await HasAsync("ALPACA_API_KEY_DEMO") && await HasAsync("ALPACA_API_SECRET_DEMO"), await HasAsync(Edgar.ContactSecret),
learning.BaseRates.ContainsKey(StrategyNames.EquityMeanrev) && champion?.Model?.Strategies.Contains(StrategyNames.EquityMeanrev) == true, ct);
_running = _trials.Any(t => !t.IsFinished);
_family = StrategyCatalog.Find(Strategia ?? "") ?? StrategyCatalog.All[0];
var today = DateOnly.FromDateTime(Clock.UtcNow.UtcDateTime);
+1 -1
View File
@@ -53,7 +53,7 @@ internal static partial class Forms
}
/// <summary>The optional keys of SPEC 13.5 that are not a broker's: the language model, Finnhub, FRED.</summary>
internal static readonly IReadOnlyList<string> DataKeys = [Anubis.News.NewsModelSettings.KeySecret, "FINNHUB_API_KEY", "FRED_API_KEY"];
internal static readonly IReadOnlyList<string> DataKeys = [Anubis.News.NewsModelSettings.KeySecret, "FINNHUB_API_KEY", "FRED_API_KEY", Anubis.Data.Edgar.ContactSecret];
private static async Task<IResult> SetNewsSourceAsync(Guid id, IFormCollection form, AnubisHost host, HttpContext context, CancellationToken ct)
{
+1 -1
View File
@@ -244,7 +244,7 @@ internal sealed record LearningView
Anomaly = state.Aside is not null,
Checked = state.Health is not null,
GainOnReference = champion?.Report.AllStrategiesCounted == true,
Found = discoveries.Found,
Found = [.. discoveries.Found, .. discoveries.Improvements],
News = discoveries.News,
Story = [.. events.Reverse().Select(e => new LearningStory(DayText(DayOf(e.At), now), e.Text))],
};