cleanup
This commit is contained in:
parent
e4925ecdfe
commit
b7aeca4888
20 changed files with 490 additions and 248 deletions
|
|
@ -5,6 +5,7 @@ import { ModeManager } from '../../apps/stock/orchestrator/src/core/ModeManager'
|
|||
import { ExecutionService } from '../../apps/stock/orchestrator/src/services/ExecutionService';
|
||||
import { MarketDataService } from '../../apps/stock/orchestrator/src/services/MarketDataService';
|
||||
import { StorageService } from '../../apps/stock/orchestrator/src/services/StorageService';
|
||||
import { createBuiltinStrategyRegistry } from '../../apps/stock/orchestrator/src/strategies/builtin-strategies';
|
||||
import { StrategyManager } from '../../apps/stock/orchestrator/src/strategies/StrategyManager';
|
||||
import {
|
||||
BacktestConfigSchema,
|
||||
|
|
@ -29,22 +30,37 @@ afterEach(async () => {
|
|||
for (const close of cleanup.splice(0).reverse()) await close();
|
||||
});
|
||||
async function fixture() {
|
||||
const services: OrchestratorServices = { logger, custom: {} };
|
||||
const services: OrchestratorServices = { logger };
|
||||
const storage = new StorageService(services, null, null, null, {
|
||||
allowSyntheticData: true,
|
||||
syntheticSeed: 42,
|
||||
});
|
||||
const market = new MarketDataService(services);
|
||||
const market: MarketDataService = new MarketDataService({
|
||||
logger,
|
||||
storage,
|
||||
drainStrategies: () => manager.drain(),
|
||||
});
|
||||
const execution = new ExecutionService(services, storage);
|
||||
const manager = new StrategyManager(services);
|
||||
const mode = new ModeManager(services, market, execution, storage);
|
||||
const backend = new BacktestEngine(services, storage, manager);
|
||||
Object.assign(services.custom!, {
|
||||
StorageService: storage,
|
||||
ExecutionService: execution,
|
||||
StrategyManager: manager,
|
||||
ModeManager: mode,
|
||||
MarketDataService: market,
|
||||
const registry = createBuiltinStrategyRegistry();
|
||||
const manager: StrategyManager = new StrategyManager({
|
||||
logger,
|
||||
marketData: market,
|
||||
execution,
|
||||
createStrategy: config => registry.create(config, { execution, modeManager: mode }),
|
||||
});
|
||||
const mode: ModeManager = new ModeManager({
|
||||
logger,
|
||||
marketData: market,
|
||||
execution,
|
||||
storage,
|
||||
strategies: manager,
|
||||
});
|
||||
const backend = new BacktestEngine({
|
||||
logger,
|
||||
storage,
|
||||
strategies: manager,
|
||||
execution,
|
||||
getTradingEngine: () => mode.getTradingEngine(),
|
||||
});
|
||||
await mode.initializeMode(config);
|
||||
cleanup.push(async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue