refactor(api): validate shared product response contracts (CL25)

This commit is contained in:
Boki 2026-10-28 13:57:37 -04:00
parent e2292e4883
commit 366a6054bf
22 changed files with 989 additions and 451 deletions

View file

@ -83,7 +83,7 @@ export class BacktestService {
runId: run?.id,
status: run?.status ?? 'pending',
updatedAt: run?.updatedAt ?? backtest.updatedAt,
error: run?.error,
error: run?.error ?? undefined,
};
}
}

View file

@ -1,6 +1,7 @@
import type { QueryResultRow } from 'pg';
import type { IServiceContainer } from '@stock-bot/services';
import type { BacktestDefinitionInput } from '@stock-bot/stock-config/backtest';
import type { BacktestResponse, RunResponse } from '@stock-bot/stock-config/product-responses';
import type {
BacktestRunDatasetSelection,
ResearchActor,
@ -28,38 +29,30 @@ export interface BacktestRequest {
strategyParameters?: Record<string, StrategyParameterValue> | null;
}
export interface Backtest {
id: string;
archivedAt: string | null;
/** The HTTP serializer converts these database Dates to the shared JSON wire shape. */
export interface Backtest
extends Omit<BacktestResponse, 'startDate' | 'endDate' | 'createdAt' | 'updatedAt'> {
strategyVersionId: string | null;
strategyParameters: Record<string, StrategyParameterValue> | null;
name: string;
strategy: string;
symbols: string[];
startDate: Date;
endDate: Date;
initialCapital: number;
config: Record<string, unknown>;
createdAt: Date;
updatedAt: Date;
}
export interface Run {
export interface Run
extends Omit<
RunResponse,
'startedAt' | 'completedAt' | 'pausedAt' | 'currentDate' | 'createdAt' | 'updatedAt'
> {
originalRunId: string | null;
dataset: BacktestRunDatasetSelection;
id: string;
backtestId: string;
runNumber: number;
status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'paused';
speedMultiplier: number | null;
error?: string;
startedAt?: Date;
completedAt?: Date;
pausedAt?: Date;
progress: number;
startedAt?: Date | null;
completedAt?: Date | null;
pausedAt?: Date | null;
cancelRequested: boolean;
attemptNumber: number;
currentDate?: Date;
currentDate?: Date | null;
createdAt: Date;
updatedAt: Date;
}