learning_ai_invt_trdg/backend/src/backtest/index.ts

25 lines
842 B
TypeScript

import { assertBacktestFeatureEnabled, assertBacktestMode } from './guards.js';
import { loadHistoricalData } from './data/loadHistoricalData.js';
import { runBacktestReplay } from './engine/BacktestRunner.js';
import type { BacktestRequest, BacktestResult } from './types.js';
export interface RunBacktestOptions {
profileSettings?: any;
}
export const runBacktest = async (
request: BacktestRequest,
options: RunBacktestOptions = {}
): Promise<BacktestResult> => {
assertBacktestFeatureEnabled();
assertBacktestMode(request.mode);
const historical = await loadHistoricalData(request);
return runBacktestReplay({
request,
dataset: historical.dataset,
replayWindow: historical.window,
dataSourceType: historical.source,
profileSettings: options.profileSettings
});
};