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

@ -9,6 +9,7 @@ import { createHttpSecurity, httpSecurityOptions, type HttpSecurity } from '@sto
import type { IServiceContainer } from '@stock-bot/handlers';
import { createBacktestRoutes } from './backtest.routes';
import { createBacktestV2Routes } from './backtests-v2.routes';
import { createDatasetRoutes } from './datasets.routes';
import { createExchangeRoutes } from './exchange.routes';
import { createHealthRoutes } from './health.routes';
import { createMonitoringRoutes } from './monitoring.routes';
@ -47,6 +48,7 @@ export function createRoutes(
app.route('/api/pipeline', pipelineRoutes);
app.route('/', backtestRoutes); // Mounted at root since routes already have /api prefix
app.route('/', backtestV2Routes); // V2 routes also mounted at root
app.route('/', createDatasetRoutes(container));
return app;
}

View file

@ -0,0 +1,43 @@
import { Hono } from 'hono';
import { getLogger } from '@stock-bot/logger';
import { requireServices, type IServiceContainer } from '@stock-bot/services';
import { HistoricalDataRequestError } from '@stock-bot/types';
import { DatasetCatalogService } from '../services/dataset-catalog.service';
const logger = getLogger('dataset-catalog-routes');
export function createDatasetRoutes(container: IServiceContainer) {
const app = new Hono();
const catalog = new DatasetCatalogService(requireServices(container, 'postgres').postgres);
app.get('/api/v2/datasets', async c => {
try {
const limit = c.req.query('limit') ?? '50';
const offset = c.req.query('offset') ?? '0';
if (!/^\d+$/.test(limit) || !/^\d+$/.test(offset)) {
throw new HistoricalDataRequestError('Dataset limit and offset must be integers');
}
return c.json({
datasets: await catalog.list({ limit: Number(limit), offset: Number(offset) }),
});
} catch (error) {
if (error instanceof HistoricalDataRequestError) {
return c.json({ error: error.message }, 400);
}
logger.error('Failed to list datasets', error);
return c.json({ error: 'Failed to list datasets' }, 500);
}
});
app.get('/api/v2/datasets/:hash', async c => {
try {
const dataset = await catalog.get(c.req.param('hash'));
return dataset ? c.json({ dataset }) : c.json({ error: 'Dataset not found' }, 404);
} catch (error) {
if (error instanceof HistoricalDataRequestError) {
return c.json({ error: error.message }, 400);
}
logger.error('Failed to get dataset', error);
return c.json({ error: 'Failed to get dataset' }, 500);
}
});
return app;
}