feat(research): select and reuse frozen datasets in workbench

This commit is contained in:
Boki 2026-10-23 18:13:37 -04:00
parent 6a67ae8683
commit b106c1ca85
29 changed files with 2295 additions and 426 deletions

View file

@ -103,6 +103,26 @@ const storage: Pick<StorageService, 'getHistoricalBars'> = {
},
};
/** Retain a real hash-validated v1 fixture through the same preparation function as a run. */
export async function retainDataset(pool: Pool, overrides: Partial<BacktestConfig> = {}) {
const dataset = await loadDataset(storage, {
mode: 'backtest',
strategy: 'moving-average',
symbols: ['AAPL.US'],
startDate: '2024-01-01T00:00:00.000Z',
endDate: '2024-03-15T00:00:00.000Z',
dataFrequency: '1d',
initialCapital: 100000,
speed: 'max',
...overrides,
});
await pool.query('INSERT INTO backtest_datasets(hash,payload) VALUES ($1,$2)', [
dataset.manifest.hash,
JSON.stringify(dataset),
]);
return dataset;
}
/** Fixed UI lifecycle data, NOT a financial simulator or correctness oracle. */
class FixtureEngine extends EventEmitter {
completion = gate();
@ -377,6 +397,7 @@ export async function fixture(native = false) {
if (
(!pathname.startsWith('/api/v2/backtests') &&
!pathname.startsWith('/api/v2/runs') &&
!pathname.startsWith('/api/v2/datasets') &&
pathname !== '/api/auth/session') ||
/\/(pause|resume|speed)$/.test(pathname)
) {