Bound backtest dataset preparation and preserve replay identity

This commit is contained in:
Boki 2026-10-21 23:18:23 -04:00
parent cca5d71e6e
commit 6bd671d92a
20 changed files with 1420 additions and 155 deletions

View file

@ -7,6 +7,7 @@ import { PostgresBacktestRunRepository } from './backtest/PostgresBacktestRunRep
import { UnavailableBacktestRunRepository } from './backtest/run-repository';
import { RustBacktestAdapter } from './backtest/RustBacktestAdapter';
import { ModeManager } from './core/ModeManager';
import { datasetLimits, type DatasetLimits } from './data/dataset-limits';
import { BacktestHandler } from './handlers/backtest/backtest.handler';
import { PaperTradingManager } from './paper/PaperTradingManager';
import { AnalyticsService } from './services/AnalyticsService';
@ -29,8 +30,10 @@ export async function registerOrchestratorServices(
syntheticSeed?: number;
nativeExecutionTimeoutMs?: number;
strategyRegistry?: StrategyRegistry;
datasetLimits?: Partial<DatasetLimits>;
} = {}
): Promise<void> {
const limits = datasetLimits(options.datasetLimits);
// Create a service adapter that provides the expected interface
const services = container.resolve('serviceContainer') as IServiceContainer;
const custom = services.custom ?? {};
@ -54,8 +57,11 @@ export async function registerOrchestratorServices(
const strategyManager = new StrategyManager(services, options.strategyRegistry);
Object.assign(custom, { StorageService: storageService });
const backtestEngine = options.useRustEngine
? new RustBacktestAdapter(services, { timeoutMs: options.nativeExecutionTimeoutMs })
: new BacktestEngine(services, storageService, strategyManager);
? new RustBacktestAdapter(services, {
timeoutMs: options.nativeExecutionTimeoutMs,
datasetLimits: limits,
})
: new BacktestEngine(services, storageService, strategyManager, { datasetLimits: limits });
const paperTradingManager = new PaperTradingManager(
services,
storageService,
@ -73,9 +79,10 @@ export async function registerOrchestratorServices(
engine: backtestEngine,
engineName: options.useRustEngine ? 'native' : 'typescript',
repository: services.postgres
? new PostgresBacktestRunRepository(services.postgres)
? new PostgresBacktestRunRepository(services.postgres, undefined, limits)
: new UnavailableBacktestRunRepository(),
logger: services.logger,
datasetLimits: limits,
prepare: options.useRustEngine ? undefined : config => modeManager.initializeMode(config),
});