100 lines
3.8 KiB
TypeScript
100 lines
3.8 KiB
TypeScript
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, input => this.runs.createRun(input));
|
|
this.results = new BacktestResults(services);
|
|
this.reproduction = new BacktestReproduction(services, this.results);
|
|
}
|
|
createBacktest(...args: Parameters<BacktestTemplates['createBacktest']>) {
|
|
return this.templates.createBacktest(...args);
|
|
}
|
|
getBacktest(...args: Parameters<BacktestTemplates['getBacktest']>) {
|
|
return this.templates.getBacktest(...args);
|
|
}
|
|
updateBacktest(...args: Parameters<BacktestTemplates['updateBacktest']>) {
|
|
return this.templates.updateBacktest(...args);
|
|
}
|
|
listBacktests(...args: Parameters<BacktestTemplates['listBacktests']>) {
|
|
return this.templates.listBacktests(...args);
|
|
}
|
|
deleteBacktest(...args: Parameters<BacktestTemplates['deleteBacktest']>) {
|
|
return this.templates.deleteBacktest(...args);
|
|
}
|
|
archiveBacktest(...args: Parameters<BacktestTemplates['archiveBacktest']>) {
|
|
return this.templates.archiveBacktest(...args);
|
|
}
|
|
createRun(...args: Parameters<BacktestRuns['createRun']>) {
|
|
return this.runs.createRun(...args);
|
|
}
|
|
getRun(...args: Parameters<BacktestRuns['getRun']>) {
|
|
return this.runs.getRun(...args);
|
|
}
|
|
listRuns(...args: Parameters<BacktestRuns['listRuns']>) {
|
|
return this.runs.listRuns(...args);
|
|
}
|
|
updateRunProgress(...args: Parameters<BacktestRuns['updateRunProgress']>) {
|
|
return this.runs.updateRunProgress(...args);
|
|
}
|
|
pauseRun(...args: Parameters<BacktestRuns['pauseRun']>) {
|
|
return this.runs.pauseRun(...args);
|
|
}
|
|
resumeRun(...args: Parameters<BacktestRuns['resumeRun']>) {
|
|
return this.runs.resumeRun(...args);
|
|
}
|
|
cancelRun(...args: Parameters<BacktestRuns['cancelRun']>) {
|
|
return this.runs.cancelRun(...args);
|
|
}
|
|
updateRunSpeed(...args: Parameters<BacktestRuns['updateRunSpeed']>) {
|
|
return this.runs.updateRunSpeed(...args);
|
|
}
|
|
canonicalCapability(...args: Parameters<BacktestRuns['canonicalCapability']>) {
|
|
return this.runs.canonicalCapability(...args);
|
|
}
|
|
getRunResults(...args: Parameters<BacktestResults['getRunResults']>) {
|
|
return this.results.getRunResults(...args);
|
|
}
|
|
getReproductionPreview(...args: Parameters<BacktestReproduction['getReproductionPreview']>) {
|
|
return this.reproduction.getReproductionPreview(...args);
|
|
}
|
|
reproduceRun(...args: Parameters<BacktestReproduction['reproduceRun']>) {
|
|
return this.reproduction.reproduceRun(...args);
|
|
}
|
|
getReproductionComparison(
|
|
...args: Parameters<BacktestReproduction['getReproductionComparison']>
|
|
) {
|
|
return this.reproduction.getReproductionComparison(...args);
|
|
}
|
|
}
|