Fix what the independent review of Phase 7 found and close the phase (refs #61)
ci / test (postgres) (push) Successful in 4m14s
ci / test (sqlite) (push) Successful in 4m41s
ci / test (postgres) (pull_request) Successful in 4m22s
ci / test (sqlite) (pull_request) Successful in 4m33s
ci / image (push) Successful in 2m51s
ci / image (pull_request) Successful in 50s
ci / test (postgres) (push) Successful in 4m14s
ci / test (sqlite) (push) Successful in 4m41s
ci / test (postgres) (pull_request) Successful in 4m22s
ci / test (sqlite) (pull_request) Successful in 4m33s
ci / image (push) Successful in 2m51s
ci / image (pull_request) Successful in 50s
Linking missed Italian elisions, "The" names and common aliases; keywords missed words after an apostrophe; stories about two companies merged and confirmed each other; a story that became serious late was measured from its first article. The news round delayed the engine and the risk check, and the classifier ran inside the database writer. The earnings row started and ended on the wrong sessions, the one-step comparison ignored it, and a purchase was said to be put off when it was not, or sent at the open. ADR 0017 records the choices; what depends on the user is in #107 and #55. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
61878c2023
commit
a3ff8ea6b7
22 files changed
+862
-123
No files matched your search
@@ -306,6 +306,81 @@ public sealed class NewsRulesTests
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The decision of the day before, made again for the one-step comparison (SPEC 12.3), reads the same earnings: a
|
||||
/// purchase left out for a report is not a difference.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[TestCategory(Category.Integration)]
|
||||
public async Task TheOneStepComparisonReadsTheSameEarnings()
|
||||
{
|
||||
var day = new DateOnly(2026, 9, 1);
|
||||
await using var stocks = await StockRig.CreateAsync(day, day.AddDays(41)).ConfigureAwait(false);
|
||||
await new CalendarEventStore(stocks.Rig.Db, stocks.Rig.Clock).UpsertAsync(
|
||||
[new CalendarEvent(CalendarEventKinds.Earnings, "Trimestrale BBB", new DateTimeOffset(2026, 9, 3, 11, 0, 0, TimeSpan.Zero), false, "test", "earnings:BBB")
|
||||
{ Symbol = "BBB", TimeHint = "bmo" }], _none).ConfigureAwait(false);
|
||||
var desk = new NewsDesk(stocks.Rig.Db, stocks.Rig.Clock);
|
||||
stocks.UseEarnings(async (d, ct) => new EarningsView(await desk.EarningsAsync(d, ct).ConfigureAwait(false), true));
|
||||
await stocks.SessionAsync(day).ConfigureAwait(false);
|
||||
await stocks.SessionAsync(day.AddDays(1)).ConfigureAwait(false);
|
||||
|
||||
var checks = await stocks.Rig.QueryAsync("SELECT outcome, data FROM decisions WHERE stage = @st", r => (Outcome: r.Text("outcome"), Data: r.TextOrNull("data")),
|
||||
("st", DecisionStages.OneStep)).ConfigureAwait(false);
|
||||
Assert.AreNotEqual(0, checks.Count);
|
||||
Assert.IsTrue(checks.All(c => c.Outcome == DecisionOutcomes.Same), string.Join(" | ", checks));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A restriction that ends before the purchase is due changes nothing and the diary is silent; one that ends while the
|
||||
/// market is closed or opening sends it five minutes after the open, as every other purchase (5.5).
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
[TestCategory(Category.Integration)]
|
||||
public async Task OnlyAPurchaseReallyPutOffIsSaidToBe()
|
||||
{
|
||||
var day = new DateOnly(2026, 9, 1);
|
||||
var due = new DateTimeOffset(2026, 9, 2, 13, 35, 0, TimeSpan.Zero);
|
||||
foreach (var (until, expected) in new[] { (due.AddHours(-12), due), (due.AddMinutes(-2), due), (due.AddMinutes(10), due.AddMinutes(10)) })
|
||||
{
|
||||
await using var stocks = await StockRig.CreateAsync(day, day.AddDays(41)).ConfigureAwait(false);
|
||||
stocks.UseGate(new FixedGate(new EntryHold(CorrectiveReasons.CalendarEvent, until, "Inflazione USA")));
|
||||
await stocks.SessionAsync(day).ConfigureAwait(false);
|
||||
var planned = await stocks.Rig.QueryAsync("SELECT due_at, first_due_at FROM planned_orders WHERE side = 'buy'", r => (Due: r.Moment("due_at"), First: r.MomentOrNull("first_due_at")))
|
||||
.ConfigureAwait(false);
|
||||
Assert.AreEqual(1, planned.Count);
|
||||
Assert.AreEqual(expected, planned[0].Due);
|
||||
Assert.AreEqual(expected > due ? due : null, planned[0].First);
|
||||
var diary = await DiaryAsync(stocks.Rig.Db).ConfigureAwait(false);
|
||||
Assert.AreEqual(expected > due, diary.Any(d => d.StartsWith("Ho rimandato", StringComparison.Ordinal)), string.Join(" | ", diary));
|
||||
if (expected > due)
|
||||
{
|
||||
Assert.IsTrue(diary.Any(d => d.StartsWith("Ho rimandato l'acquisto di BBB a mercoledì 2 settembre alle 15:45.", StringComparison.Ordinal)), string.Join(" | ", diary));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A restriction that ends at night sends a weekly purchase five minutes after the next open, not at the open.</summary>
|
||||
[TestMethod]
|
||||
[TestCategory(Category.Integration)]
|
||||
public async Task APurchaseHeldWithTheMarketClosedGoesFiveMinutesAfterTheOpen()
|
||||
{
|
||||
var friday = new DateOnly(2026, 9, 4);
|
||||
await using var stocks = await StockRig.CreateAsync(friday, friday.AddDays(20), StrategyNames.EquityMomentum).ConfigureAwait(false);
|
||||
stocks.UseGate(new FixedGate(new EntryHold(CorrectiveReasons.CalendarEvent, new DateTimeOffset(2026, 9, 7, 23, 0, 0, TimeSpan.Zero), "Inflazione USA")));
|
||||
await stocks.SessionAsync(friday).ConfigureAwait(false);
|
||||
var planned = await stocks.Rig.QueryAsync("SELECT due_at FROM planned_orders WHERE side = 'buy'", r => r.Moment("due_at")).ConfigureAwait(false);
|
||||
Assert.AreNotEqual(0, planned.Count);
|
||||
Assert.IsTrue(planned.All(d => d == new DateTimeOffset(2026, 9, 8, 13, 35, 0, TimeSpan.Zero)), string.Join(", ", planned));
|
||||
Assert.IsTrue((await DiaryAsync(stocks.Rig.Db).ConfigureAwait(false)).Any(d => d.Contains("a martedì 8 settembre alle 15:35.", StringComparison.Ordinal)));
|
||||
}
|
||||
|
||||
private sealed class FixedGate(EntryHold hold) : IEntryGate
|
||||
{
|
||||
public Task<EntryHold?> HoldAsync(InstrumentSpec spec, DateTimeOffset at, CancellationToken cancellationToken) => Task.FromResult(at < hold.Until ? hold : null);
|
||||
|
||||
public Task<EntryHold?> KeepStopAsync(InstrumentSpec spec, DateTimeOffset at, CancellationToken cancellationToken) => Task.FromResult<EntryHold?>(null);
|
||||
}
|
||||
|
||||
/// <summary>A story linked to one instrument, with one article from the named publisher.</summary>
|
||||
internal static async Task<Guid> StoryAsync(Database db, IClock clock, InstrumentSpec spec, string title, DateTimeOffset published, int importance, double? score,
|
||||
string publisher, bool trusted, int sources = 1, DateTimeOffset? seen = null)
|
||||
|
||||
Reference in new issue
Block a user