import { ServiceContainerBuilder } from '@stock-bot/di'; import { ModeManager } from '../src/core/ModeManager'; import { ExecutionService } from '../src/services/ExecutionService'; import { MarketDataService } from '../src/services/MarketDataService'; import { StorageService } from '../src/services/StorageService'; import { createBuiltinStrategyRegistry } from '../src/strategies/builtin-strategies'; import { StrategyManager } from '../src/strategies/StrategyManager'; import type { OrchestratorServices } from '../src/types'; /** Legacy algorithm examples only: no queue, HTTP server, durable runs, or paper account. */ export async function createExampleRuntime() { const di = await new ServiceContainerBuilder() .withOptions({ enableCache: false, enableQueue: false, enableMongoDB: false, enablePostgres: false, enableQuestDB: false, enableBrowser: false, enableProxy: false, }) .build(); const container = di.resolve('serviceContainer') as OrchestratorServices; const storageService = new StorageService(container.logger, null, null, { allowSyntheticData: true, syntheticSeed: 42, }); const marketDataService: MarketDataService = new MarketDataService({ logger: container.logger, storage: storageService, drainStrategies: () => strategyManager.drain(), }); const executionService = new ExecutionService(container, storageService, { allowedMode: 'backtest', }); const registry = createBuiltinStrategyRegistry(); const strategyManager: StrategyManager = new StrategyManager({ logger: container.logger, marketData: marketDataService, execution: executionService, createStrategy: config => registry.create(config, { modeManager, execution: executionService }), }); const modeManager: ModeManager = new ModeManager({ allowedMode: 'backtest', logger: container.logger, marketData: marketDataService, execution: executionService, strategies: strategyManager, }); const custom = container.custom ?? {}; if (!container.custom) { Object.defineProperty(container, 'custom', { value: custom, enumerable: true }); } Object.assign(custom, { StorageService: storageService, MarketDataService: marketDataService, ExecutionService: executionService, StrategyManager: strategyManager, ModeManager: modeManager, }); strategyManager.setupEventListeners(); return { container, storageService, marketDataService, executionService, modeManager, strategyManager, }; }