feat(research): cut over canonical runtime and enforce agent budgets
This commit is contained in:
parent
ab08db82fd
commit
bbf0dd4453
103 changed files with 6138 additions and 3112 deletions
|
|
@ -1,9 +1,13 @@
|
|||
import { ServiceContainerBuilder } from '@stock-bot/di';
|
||||
import { defined } from '@stock-bot/invariants';
|
||||
import { registerOrchestratorServices } from '../src/container';
|
||||
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';
|
||||
|
||||
/** Offline examples explicitly opt into seeded synthetic data. No provider credentials are used. */
|
||||
/** Legacy algorithm examples only: no queue, HTTP server, durable runs, or paper account. */
|
||||
export async function createExampleRuntime() {
|
||||
const di = await new ServiceContainerBuilder()
|
||||
.withOptions({
|
||||
|
|
@ -16,18 +20,52 @@ export async function createExampleRuntime() {
|
|||
enableProxy: false,
|
||||
})
|
||||
.build();
|
||||
await registerOrchestratorServices(di, {
|
||||
initializeMode: false,
|
||||
const container = di.resolve('serviceContainer') as OrchestratorServices;
|
||||
const storageService = new StorageService(container, null, null, null, {
|
||||
allowSyntheticData: true,
|
||||
syntheticSeed: 42,
|
||||
});
|
||||
const container = di.resolve('serviceContainer') as OrchestratorServices;
|
||||
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,
|
||||
storage: storageService,
|
||||
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: defined(container.custom?.StorageService),
|
||||
marketDataService: defined(container.custom?.MarketDataService),
|
||||
executionService: defined(container.custom?.ExecutionService),
|
||||
modeManager: defined(container.custom?.ModeManager),
|
||||
strategyManager: defined(container.custom?.StrategyManager),
|
||||
storageService,
|
||||
marketDataService,
|
||||
executionService,
|
||||
modeManager,
|
||||
strategyManager,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue