26 lines
1.2 KiB
TypeScript
26 lines
1.2 KiB
TypeScript
import { ServiceContainerBuilder } from '@stock-bot/di';
|
|
import type { StockAppConfig } from '@stock-bot/stock-config';
|
|
import { registerOrchestratorServices } from './container';
|
|
import type { OrchestratorServices } from './types';
|
|
|
|
/** Use the shared builder for connection setup and adapter ownership. */
|
|
export async function createContainer(config: StockAppConfig) {
|
|
const container = await new ServiceContainerBuilder()
|
|
.withConfig(config)
|
|
.withOptions({
|
|
enableMongoDB: config.database?.mongodb?.enabled ?? false,
|
|
enablePostgres: config.database?.postgres?.enabled ?? false,
|
|
enableCache: config.database?.dragonfly?.enabled ?? false,
|
|
enableQueue: config.queue?.enabled ?? false,
|
|
enableQuestDB: config.database?.questdb?.enabled ?? false,
|
|
enableBrowser: false,
|
|
enableProxy: false,
|
|
})
|
|
.build();
|
|
await registerOrchestratorServices(container, {
|
|
useRustEngine: config.services?.orchestrator?.backtesting?.useRustEngine ?? true,
|
|
allowSyntheticData: config.services?.orchestrator?.backtesting?.allowSyntheticData ?? false,
|
|
syntheticSeed: config.services?.orchestrator?.backtesting?.syntheticSeed ?? 42,
|
|
});
|
|
return container.resolve('serviceContainer') as OrchestratorServices;
|
|
}
|