import { authenticatedServiceFetch } from '@stock-bot/di'; import { requireServices, type IServiceContainer } from '@stock-bot/services'; import type { BacktestTransport } from './backtests/contracts'; import { BacktestReproduction } from './backtests/reproduction'; import { BacktestResults } from './backtests/results'; import { BacktestRuns } from './backtests/runs'; import { BacktestTemplates } from './backtests/templates'; export { BacktestRetentionError, CatalogExecutionUnavailableError, RunSubmissionConflictError, } from './backtests/contracts'; export type { BacktestTransport, BacktestResultQuery, BacktestRequest, Backtest, Run, RunRequest, RunSubmission, } from './backtests/contracts'; export { datasetSelectionForRun } from './backtests/mapping'; /** Compatible application facade; no financial simulation or accounting lives here. */ export class BacktestServiceV2 { private readonly templates: BacktestTemplates; private readonly runs: BacktestRuns; private readonly results: BacktestResults; private readonly reproduction: BacktestReproduction; constructor( container: IServiceContainer, request: BacktestTransport = authenticatedServiceFetch ) { const services = requireServices(container, 'postgres'); this.runs = new BacktestRuns(services, request); this.templates = new BacktestTemplates(services); this.results = new BacktestResults(services); this.reproduction = new BacktestReproduction(services, this.results); } createBacktest(...args: Parameters) { return this.templates.createBacktest(...args); } getBacktest(...args: Parameters) { return this.templates.getBacktest(...args); } updateBacktest(...args: Parameters) { return this.templates.updateBacktest(...args); } listBacktests(...args: Parameters) { return this.templates.listBacktests(...args); } deleteBacktest(...args: Parameters) { return this.templates.deleteBacktest(...args); } archiveBacktest(...args: Parameters) { return this.templates.archiveBacktest(...args); } createRun(...args: Parameters) { return this.runs.createRun(...args); } getRun(...args: Parameters) { return this.runs.getRun(...args); } listRuns(...args: Parameters) { return this.runs.listRuns(...args); } updateRunProgress(...args: Parameters) { return this.runs.updateRunProgress(...args); } pauseRun(...args: Parameters) { return this.runs.pauseRun(...args); } resumeRun(...args: Parameters) { return this.runs.resumeRun(...args); } cancelRun(...args: Parameters) { return this.runs.cancelRun(...args); } updateRunSpeed(...args: Parameters) { return this.runs.updateRunSpeed(...args); } canonicalCapability(...args: Parameters) { return this.runs.canonicalCapability(...args); } getRunResults(...args: Parameters) { return this.results.getRunResults(...args); } getReproductionPreview(...args: Parameters) { return this.reproduction.getReproductionPreview(...args); } reproduceRun(...args: Parameters) { return this.reproduction.reproduceRun(...args); } getReproductionComparison( ...args: Parameters ) { return this.reproduction.getReproductionComparison(...args); } }