Bound backtest dataset preparation and preserve replay identity

This commit is contained in:
Boki 2026-10-21 23:18:23 -04:00
parent cca5d71e6e
commit 6bd671d92a
20 changed files with 1420 additions and 155 deletions

View file

@ -1,5 +1,6 @@
import { expect, test } from 'bun:test';
import { createExampleRuntime } from '../../apps/stock/orchestrator/examples/example-runtime';
import { backtestDatasetLimitsSchema } from '../../apps/stock/config/src/schemas/stock-app.schema';
test('offline examples use the shared DI graph without starting a real-time feed', async () => {
const runtime = await createExampleRuntime();
@ -10,3 +11,12 @@ test('offline examples use the shared DI graph without starting a real-time feed
expect(runtime.modeManager.getConfig()).toBeNull();
expect(() => runtime.modeManager.getTradingEngine()).toThrow('Trading engine not initialized');
});
test('dataset configuration accepts partial budgets and rejects invalid or misspelled ceilings', () => {
expect(backtestDatasetLimitsSchema.parse({ maxBars: 1000 })).toEqual({ maxBars: 1000 });
expect(backtestDatasetLimitsSchema.parse({})).toEqual({});
for (const maxBars of [0, -1, 1.5, Infinity, Number.MAX_SAFE_INTEGER]) {
expect(backtestDatasetLimitsSchema.safeParse({ maxBars }).success).toBe(false);
}
expect(backtestDatasetLimitsSchema.safeParse({ maxBar: 1000 }).success).toBe(false);
});