feat(research): run durable backtests in a bounded worker pool

This commit is contained in:
Boki 2026-10-24 17:41:00 -04:00
parent bbf0dd4453
commit 26b97265c6
15 changed files with 1730 additions and 129 deletions

View file

@ -1,5 +1,6 @@
import { ServiceContainerBuilder } from '@stock-bot/di';
import type { StockAppConfig } from '@stock-bot/stock-config';
import { assertResearchConcurrency } from './backtest/ResearchBacktestPool';
import { paperConfigurationSchema } from './contracts/paper-runtime';
import { validatePaperConfiguration } from './paper/feed';
import {
@ -28,6 +29,9 @@ export async function createContainer(
const useRustEngine = configuredEngine === undefined ? true : configuredEngine;
// Fail before opening connections as well as before registering runtime services.
assertSupportedComposition(role, useRustEngine);
const maxConcurrent =
settings?.backtesting?.maxConcurrent === undefined ? 1 : settings.backtesting.maxConcurrent;
assertResearchConcurrency(maxConcurrent);
if (settings?.canonicalPaper !== undefined && role !== 'paper') {
throw new Error('Canonical paper configuration requires a paper composition');
}
@ -58,6 +62,7 @@ export async function createContainer(
await registerOrchestratorServices(container, {
role,
useRustEngine,
maxConcurrent,
allowSyntheticData: config.services?.orchestrator?.backtesting?.allowSyntheticData ?? false,
syntheticSeed: config.services?.orchestrator?.backtesting?.syntheticSeed ?? 42,
nativeExecutionTimeoutMs: config.services?.orchestrator?.backtesting?.executionTimeoutMs,