feat(research): cut over canonical runtime and enforce agent budgets
This commit is contained in:
parent
ab08db82fd
commit
bbf0dd4453
103 changed files with 6138 additions and 3112 deletions
|
|
@ -266,7 +266,7 @@ describe('deterministic ingestion → storage → native backtest', () => {
|
|||
validateDataset(first, { ...datasetConfig(), datasetHash: 'f'.repeat(64) })
|
||||
).toThrow('does not match');
|
||||
});
|
||||
test('replays stored provider fixtures and produces identical trades and metrics', async () => {
|
||||
test('stored provider fixtures normalize into identical frozen inputs before admission', async () => {
|
||||
const { documents, mongodb } = memoryStore();
|
||||
await persistEodPrices(mongodb, identity, fixture);
|
||||
await persistEodPrices(mongodb, identity, fixture);
|
||||
|
|
@ -287,16 +287,11 @@ describe('deterministic ingestion → storage → native backtest', () => {
|
|||
slippage: 0,
|
||||
config: { fastPeriod: 3, slowPeriod: 7 },
|
||||
});
|
||||
const engine = new RustBacktestAdapter({ logger, storage });
|
||||
const first = await engine.runBacktest(config);
|
||||
const second = await engine.runBacktest(config);
|
||||
expect(first.status).toBe('completed');
|
||||
expect(first.trades.length).toBeGreaterThan(0);
|
||||
expect(first.trades).toEqual(second.trades);
|
||||
expect(first.metrics).toEqual(second.metrics);
|
||||
expect(first.equity).toEqual(second.equity);
|
||||
expect(first.metrics.totalReturn).toBeFinite();
|
||||
expect(engine.getStatus().isRunning).toBe(false);
|
||||
const first = await loadDataset(storage, config);
|
||||
const second = await loadDataset(storage, config);
|
||||
expect(first).toEqual(second);
|
||||
expect(first.bars).toHaveLength(fixture.length);
|
||||
expect(first.manifest.hash).toBe(second.manifest.hash);
|
||||
});
|
||||
|
||||
test('all listings retain their first same-timestamp bar and deterministic tie ordering', async () => {
|
||||
|
|
@ -310,16 +305,14 @@ describe('deterministic ingestion → storage → native backtest', () => {
|
|||
config: { fastPeriod: 3, slowPeriod: 7 },
|
||||
};
|
||||
const storage = new StorageService({ logger }, mongodb, null, null);
|
||||
const engine = new RustBacktestAdapter({ logger, storage });
|
||||
const first = await engine.runBacktest(config);
|
||||
const second = await engine.runBacktest(config);
|
||||
const first = await loadDataset(storage, config);
|
||||
const second = await loadDataset(storage, config);
|
||||
for (const id of config.symbols) {
|
||||
expect(first.ohlcData[id]).toHaveLength(fixture.length);
|
||||
expect(first.ohlcData[id]?.[0]?.timestamp).toBe(start.getTime());
|
||||
const bars = first.bars.filter(bar => bar.symbol === id);
|
||||
expect(bars).toHaveLength(fixture.length);
|
||||
expect(bars[0]?.timestamp).toBe(start.getTime());
|
||||
}
|
||||
expect(first.trades).toEqual(second.trades);
|
||||
expect(first.metrics).toEqual(second.metrics);
|
||||
expect(first.equity).toEqual(second.equity);
|
||||
expect(first).toEqual(second);
|
||||
});
|
||||
|
||||
test('rejects malformed provider records before writing anything', async () => {
|
||||
|
|
@ -347,7 +340,7 @@ describe('deterministic ingestion → storage → native backtest', () => {
|
|||
);
|
||||
});
|
||||
|
||||
test('empty storage and unknown strategies fail without leaving the engine running', async () => {
|
||||
test('retired provider-at-execution entry refuses before storage or native strategy resolution', async () => {
|
||||
const { mongodb } = memoryStore();
|
||||
const storage = new StorageService({ logger }, mongodb, null, null);
|
||||
const engine = new RustBacktestAdapter({ logger, storage });
|
||||
|
|
@ -360,9 +353,11 @@ describe('deterministic ingestion → storage → native backtest', () => {
|
|||
initialCapital: 100000,
|
||||
dataFrequency: '1d',
|
||||
});
|
||||
await expect(engine.runBacktest(config)).rejects.toThrow('No historical data');
|
||||
await expect(engine.runBacktest(config)).rejects.toThrow(
|
||||
'Legacy backtest execution is retired'
|
||||
);
|
||||
await expect(engine.runBacktest({ ...config, strategy: 'does-not-exist' })).rejects.toThrow(
|
||||
'Unknown native strategy'
|
||||
'Legacy backtest execution is retired'
|
||||
);
|
||||
expect(engine.getStatus().isRunning).toBe(false);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue