T-84: M1.3d — trial_ledger writer + cluster N̂-deflated Sharpe reader in @stock-bot/research (append one row per horizon, vault-fenced sample_end, PostgreSQL integration test + local benchmark)
This commit is contained in:
parent
bbc31b9cd7
commit
9b57ea9677
3 changed files with 35 additions and 5 deletions
|
|
@ -497,7 +497,8 @@ describe('recordTrials', () => {
|
|||
const receipts = await recordTrials(executor, batch);
|
||||
expect(calls).toHaveLength(1);
|
||||
expect(calls[0]!.text).toContain('INSERT INTO trial_ledger');
|
||||
expect(calls[0]!.text).toContain('RETURNING trial_id, created_at');
|
||||
expect(calls[0]!.text).toContain('RETURNING trial_id,');
|
||||
expect(calls[0]!.text).toContain('AS created_at');
|
||||
expect(calls[0]!.params).toHaveLength(3 * 14);
|
||||
expect(receipts).toEqual([
|
||||
{ trialId: 101, createdAt: '2025-04-01T10:00:00.000Z' },
|
||||
|
|
@ -505,6 +506,27 @@ describe('recordTrials', () => {
|
|||
{ trialId: 103, createdAt: '2025-04-01T10:00:00.002Z' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('preserves PostgreSQL microsecond UTC timestamps across receipts and asOf queries', async () => {
|
||||
const microTs = '2025-04-01T10:00:00.123456Z';
|
||||
const { executor, calls } = createFakeExecutor(text => {
|
||||
if (text.startsWith('INSERT INTO trial_ledger')) {
|
||||
return { rows: [{ trial_id: '7', created_at: microTs }] };
|
||||
}
|
||||
return { rows: [] };
|
||||
});
|
||||
|
||||
const receipts = await recordTrials(executor, [makeValidInput()]);
|
||||
expect(receipts).toEqual([{ trialId: 7, createdAt: microTs }]);
|
||||
|
||||
await loadClusterTrials(executor, {
|
||||
universeMarket: 'US_EQ',
|
||||
horizonBucket: 'swing_1_10d',
|
||||
asOf: receipts[0]!.createdAt,
|
||||
});
|
||||
expect(calls).toHaveLength(2);
|
||||
expect(calls[1]!.params).toEqual(['US_EQ', 'swing_1_10d', microTs]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('loadClusterTrials and clusterDeflatedSharpe', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue