Share backtest request contracts and isolate stored result mapping

This commit is contained in:
Boki 2026-10-21 23:57:48 -04:00
parent 007e35c747
commit 420c47704e
21 changed files with 777 additions and 244 deletions

View file

@ -2,9 +2,10 @@ import { randomUUID } from 'node:crypto';
import type { PoolClient } from 'pg';
import type { TransactionCallback } from '@stock-bot/postgres';
import type { PostgresClient } from '@stock-bot/services';
import { parseBacktestRequest } from '@stock-bot/stock-config/backtest';
import type { BacktestRunResult, HistoricalDataset } from '@stock-bot/types';
import { prepareDataset } from '../data/historical-dataset';
import { BacktestConfigSchema, type BacktestConfig } from '../types';
import type { BacktestConfig } from '../types';
import { BacktestCancelledError } from './execution-engine';
import {
BacktestConflictError,
@ -54,7 +55,7 @@ export class PostgresBacktestRunRepository implements BacktestRunRepository {
if (!run) {
throw new BacktestConflictError('Run is missing, already claimed, or terminal');
}
const snapshot = BacktestConfigSchema.parse(run.request_snapshot);
const snapshot = parseBacktestRequest(run.request_snapshot);
return {
runId: String(run.id),
backtestId: String(run.backtest_id),