T-121: tests

This commit is contained in:
Studio 2026-11-29 15:26:38 -05:00
parent ee69c216af
commit aecafdebe1
2 changed files with 574 additions and 6 deletions

View file

@ -148,9 +148,14 @@ function buildCeoShortsFixture(poisonPostCutoff: boolean): CeoShortsFixture {
const barRows: TableRow[] = [];
const shortsRows: TableRow[] = [];
// Semi-monthly ceoShorts reports (every 10 trading sessions), published at 17:00 ET (22:00 UTC).
// Semi-monthly ceoShorts reports (every 10 trading sessions). Publication follows the CIRO
// working assumption: 17:00 ET (22:00 UTC) four business days after `report_date`. A report
// only drives prices from the session AFTER its publication close, so no close ever reflects
// a report before its `known_at` (QA fix for the reviewer's look-ahead note).
// Plant a negative relationship: higher net_change predicts lower subsequent 5-session return.
const PUBLICATION_LAG_SESSIONS = 4;
const activeNetChange = new Float64Array(listingCount);
const pendingByPublishIdx = new Map<number, (number | null)[]>();
const prices = new Float64Array(listingCount);
for (let l = 0; l < listingCount; l += 1) {
prices[l] = 10 + l * 1.5;
@ -160,14 +165,25 @@ function buildCeoShortsFixture(poisonPostCutoff: boolean): CeoShortsFixture {
const date = allDates[t]!;
const closeTs = makeUtcMs(date, 21); // 16:00 ET close
if (t % 10 === 0) {
const reportKnownAt = makeUtcMs(date, 22); // 17:00 ET (after close -> effective next session)
// Reports published after the previous close become tradeable information today.
const released = pendingByPublishIdx.get(t - 1);
if (released !== undefined) {
for (let l = 0; l < listingCount; l += 1) {
const v = released[l];
if (v !== null && v !== undefined) {
activeNetChange[l] = v / 20_000; // normalized in [-1, 1]
}
}
}
const publishIdx = t + PUBLICATION_LAG_SESSIONS;
if (t % 10 === 0 && publishIdx < allDates.length) {
const reportKnownAt = makeUtcMs(allDates[publishIdx]!, 22); // 17:00 ET on T+4
const pending: (number | null)[] = [];
for (let l = 0; l < listingCount; l += 1) {
const isNullCell = t > 0 && (t + l) % 19 === 0;
const netChange = isNullCell ? null : Math.round((rand() * 2 - 1) * 20_000);
if (netChange !== null) {
activeNetChange[l] = netChange / 20_000; // normalized in [-1, 1]
}
pending.push(netChange);
shortsRows.push({
listing_id: listingIds[l]!,
report_date: date,
@ -178,6 +194,7 @@ function buildCeoShortsFixture(poisonPostCutoff: boolean): CeoShortsFixture {
source: 'ceoShorts',
});
}
pendingByPublishIdx.set(publishIdx, pending);
}
for (let l = 0; l < listingCount; l += 1) {
@ -323,6 +340,17 @@ describe('ceoShorts end-to-end signal study (headless, no database)', () => {
return { fixture, duck, ledger, built, studyResult };
}
it('fixture publishes each ceoShorts report after the close four sessions past report_date', () => {
const fixture = buildCeoShortsFixture(false);
expect(fixture.shortsRows.length).toBeGreaterThan(0);
for (const row of fixture.shortsRows) {
const reportIdx = fixture.allDates.indexOf(row.report_date as string);
const publishDate = fixture.allDates[reportIdx + 4]!;
expect(row.known_at).toBe(makeUtcMs(publishDate, 22));
expect(row.known_at as number).toBeGreaterThan(makeUtcMs(publishDate, 21));
}
});
it('flows DuckDbMarketDataStore -> buildForwardReturnPanel -> analyzeSignal -> trial_ledger + DSR', async () => {
const clean = await runCeoShortsStudy(false);