Phase 11: decisions from the numbers only, outside rules measured in the shadow
ci / test (postgres) (push) Successful in 5m56s
ci / test (sqlite) (push) Successful in 5m5s
ci / test (postgres) (pull_request) Successful in 5m36s
ci / test (sqlite) (pull_request) Successful in 4m52s
ci / image (push) Successful in 2m6s
ci / image (pull_request) Successful in 52s
ci / test (postgres) (push) Successful in 5m56s
ci / test (sqlite) (push) Successful in 5m5s
ci / test (postgres) (pull_request) Successful in 5m36s
ci / test (sqlite) (pull_request) Successful in 4m52s
ci / image (push) Successful in 2m6s
ci / image (pull_request) Successful in 52s
News, the economic calendar and earnings dates no longer change any decision by default (ADR 0023). A new switch, decisions.external_rules, chooses between "misurate" (default) and "attive" (the Phase 7 behaviour); ADR 0027 records every choice. - Engine: with "misurate" nothing is held, postponed or kept, no diary or note is written and equity_meanrev gets no earnings dates. The gate is still asked, per rule and with all rows on, to write one shadow case per rule, strategy, instrument and day. The switch is read once per decision; the one-step check and the release of a planned order read it as it was when the decision ran. - Shadow: five rules measured with the existing improvement machinery, 99% interval, "too early" under six months, the ADR 0023 criterion; the earnings exit is measured by relabelling with the report date. Shown in the Laboratorio and in the quarterly review beside the historical restriction balance. - Model: the seven outside clues stay out of training; a champion that uses one is set aside at once, without an alarm, and Sunday trains one without them. - Settings: the switch changes only from the settings form, with the protections of the five rows; the API refuses it; each change writes one diary line. The first start of this version records "attive" until then on an installation that had already decided. - Screens, demo and manual follow "misurate". Two independent review rounds; their confirmed findings are fixed and tested. SQLite, PostgreSQL and the image with the guard drill are green. refs #116, refs #117 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ed22d1c8b5
commit
501c9be70e
47 files changed
+1743
-169
No files matched your search
@@ -40,6 +40,9 @@ internal sealed record NewsView(
|
||||
|
||||
public const int CalendarRows = 6;
|
||||
|
||||
/// <summary>News, calendar and earnings only measured (ADR 0023): the page is an archive of what each rule would have done.</summary>
|
||||
public bool Measured => Board.Measured;
|
||||
|
||||
private static readonly CultureInfo _it = CultureInfo.InvariantCulture;
|
||||
|
||||
public static async Task<NewsView> LoadAsync(AnubisHost host, ShellData shell, CancellationToken cancellationToken)
|
||||
@@ -52,7 +55,7 @@ internal sealed record NewsView(
|
||||
var board = await new NewsBoard(services.Db, clock, services.Settings).LoadAsync(cancellationToken).ConfigureAwait(false);
|
||||
var switches = await NewsRuleSettings.LoadAsync(services.Settings, cancellationToken).ConfigureAwait(false);
|
||||
var mood = await MoodAsync(new MoodStore(services.Db, clock), now, cancellationToken).ConfigureAwait(false);
|
||||
var calendar = await CalendarAsync(services, clock, shell.Zone, switches, cancellationToken).ConfigureAwait(false);
|
||||
var calendar = await CalendarAsync(services, clock, shell.Zone, switches, board.Measured, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
using var aggregates = shell.Aggregates();
|
||||
if (aggregates?.RootElement.GetProperty("notizie") is { } demo)
|
||||
@@ -120,7 +123,7 @@ internal sealed record NewsView(
|
||||
|
||||
// The events that change something or that the user expects to see: this week's US and euro data of medium or high
|
||||
// impact, the central banks of the next month, the earnings of the stocks held or watched.
|
||||
private static async Task<IReadOnlyList<CalendarRow>> CalendarAsync(AppServices services, IClock clock, TimeZoneInfo zone, NewsRuleSwitches switches,
|
||||
private static async Task<IReadOnlyList<CalendarRow>> CalendarAsync(AppServices services, IClock clock, TimeZoneInfo zone, NewsRuleSwitches switches, bool measured,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var now = clock.UtcNow;
|
||||
@@ -133,20 +136,26 @@ internal sealed record NewsView(
|
||||
return (h, n);
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
var stocks = held.ToHashSet(StringComparer.Ordinal);
|
||||
// Measured: no note is written, so the candidates come from the list the filter of the earnings reads, within the
|
||||
// reach the notes would have had (ADR 0027).
|
||||
var candidates = measured ? await NewsWatcher.WatchedStocksAsync(services.Db, cancellationToken).ConfigureAwait(false) : new HashSet<string>();
|
||||
var reach = NewsDesk.EarningsReach(now);
|
||||
|
||||
var withNote = noted.ToHashSet(StringComparer.Ordinal);
|
||||
|
||||
var shown = events.Where(e => e.Kind switch
|
||||
{
|
||||
CalendarEventKinds.Economic => e.OccursAt - now <= EconomicAhead && e.Currency is "USD" or "EUR" && e.Impact is "High" or "Medium",
|
||||
CalendarEventKinds.CentralBank => true,
|
||||
CalendarEventKinds.Earnings => e.OccursAt - now <= EarningsAhead && e.Symbol is { } s && (stocks.Contains(s) || withNote.Contains("event:" + e.SourceKey)),
|
||||
CalendarEventKinds.Earnings => e.OccursAt - now <= EarningsAhead && e.Symbol is { } s && (stocks.Contains(s) || withNote.Contains("event:" + e.SourceKey)
|
||||
|| (candidates.Contains(s) && Zones.DayIn(e.OccursAt, Zones.NewYork) <= reach)),
|
||||
_ => false,
|
||||
}).OrderBy(e => e.OccursAt).Take(CalendarRows);
|
||||
|
||||
return [.. shown.Select(e => Row(e, now, zone, switches))];
|
||||
return [.. shown.Select(e => Row(e, now, zone, switches, measured))];
|
||||
}
|
||||
|
||||
private static CalendarRow Row(CalendarEvent e, DateTimeOffset now, TimeZoneInfo zone, NewsRuleSwitches switches)
|
||||
private static CalendarRow Row(CalendarEvent e, DateTimeOffset now, TimeZoneInfo zone, NewsRuleSwitches switches, bool measured)
|
||||
{
|
||||
var local = TimeZoneInfo.ConvertTime(e.OccursAt, zone);
|
||||
var day = DateOnly.FromDateTime(local.DateTime);
|
||||
@@ -163,7 +172,9 @@ internal sealed record NewsView(
|
||||
"amc" => (", dopo la chiusura", "fino alla seduta dopo i conti"),
|
||||
_ => ("", "fino alla seduta dopo i conti"),
|
||||
};
|
||||
return switches.Earnings
|
||||
return measured
|
||||
? new CalendarRow(dayText + when, e.Title, $"Riguarda {e.Symbol}: con le regole attive niente mean reversion {until}. Solo registrato.", false)
|
||||
: switches.Earnings
|
||||
? new CalendarRow(dayText + when, e.Title, $"Riguarda {e.Symbol}: niente mean reversion {until}", true)
|
||||
: new CalendarRow(dayText + when, e.Title, $"Riguarda {e.Symbol}: la regola è spenta, nessun effetto", false);
|
||||
}
|
||||
@@ -177,6 +188,13 @@ internal sealed record NewsView(
|
||||
};
|
||||
if (CalendarBlocks.Window(e) is { } window)
|
||||
{
|
||||
if (measured)
|
||||
{
|
||||
var start = TimeZoneInfo.ConvertTime(window.From, zone);
|
||||
var end = TimeZoneInfo.ConvertTime(window.To, zone);
|
||||
return new CalendarRow(whenText, e.Title, string.Create(_it, $"{impact}: con le regole attive nessun nuovo ingresso dalle {start:HH:mm} alle {end:HH:mm}. Solo registrato."), false);
|
||||
}
|
||||
|
||||
if (!switches.Macro)
|
||||
{
|
||||
return new CalendarRow(whenText, e.Title, impact + ": la regola è spenta, nessun blocco", false);
|
||||
|
||||
Reference in new issue
Block a user