cleanup
This commit is contained in:
parent
e4925ecdfe
commit
b7aeca4888
20 changed files with 490 additions and 248 deletions
6
test/fixtures/backtest-crash-owner.ts
vendored
6
test/fixtures/backtest-crash-owner.ts
vendored
|
|
@ -5,6 +5,7 @@ import { PostgreSQLClient } from '@stock-bot/postgres';
|
|||
import { BacktestRunner } from '../../apps/stock/orchestrator/src/backtest/BacktestRunner';
|
||||
import { PostgresBacktestRunRepository } from '../../apps/stock/orchestrator/src/backtest/PostgresBacktestRunRepository';
|
||||
import { RustBacktestAdapter } from '../../apps/stock/orchestrator/src/backtest/RustBacktestAdapter';
|
||||
import { StorageService } from '../../apps/stock/orchestrator/src/services/StorageService';
|
||||
|
||||
setLoggerConfig({ logLevel: 'fatal', logConsole: false });
|
||||
const url = process.env.PIPELINE_TEST_DATABASE_URL;
|
||||
|
|
@ -27,7 +28,10 @@ const postgres = new PostgreSQLClient(
|
|||
Object.defineProperty(postgres, 'connectionPool', { get: () => pool });
|
||||
const repository = new PostgresBacktestRunRepository(postgres, 500);
|
||||
const runner = new BacktestRunner({
|
||||
engine: new RustBacktestAdapter({ logger }),
|
||||
engine: new RustBacktestAdapter({
|
||||
logger,
|
||||
storage: new StorageService({ logger }, null, null, null),
|
||||
}),
|
||||
engineName: 'native',
|
||||
repository,
|
||||
logger,
|
||||
|
|
|
|||
36
test/fixtures/strategy-recovery.ts
vendored
36
test/fixtures/strategy-recovery.ts
vendored
|
|
@ -1,3 +1,4 @@
|
|||
import { EventEmitter } from 'node:events';
|
||||
import { z } from 'zod';
|
||||
import type { ModeManager } from '../../apps/stock/orchestrator/src/core/ModeManager';
|
||||
import type {
|
||||
|
|
@ -12,7 +13,12 @@ import {
|
|||
BaseStrategy,
|
||||
type Signal,
|
||||
} from '../../apps/stock/orchestrator/src/strategies/BaseStrategy';
|
||||
import { createBuiltinStrategyRegistry } from '../../apps/stock/orchestrator/src/strategies/builtin-strategies';
|
||||
import { StrategyManager } from '../../apps/stock/orchestrator/src/strategies/StrategyManager';
|
||||
import type {
|
||||
StrategyDependencies,
|
||||
StrategyRegistry,
|
||||
} from '../../apps/stock/orchestrator/src/strategies/StrategyRegistry';
|
||||
import type { MarketData, StrategyConfig } from '../../apps/stock/orchestrator/src/types';
|
||||
import { logger } from './execution';
|
||||
|
||||
|
|
@ -24,6 +30,20 @@ export const recoveryConfig: StrategyConfig = {
|
|||
allocation: 1,
|
||||
enabled: true,
|
||||
};
|
||||
export function makeStrategyManager({
|
||||
execution,
|
||||
modeManager,
|
||||
registry = createBuiltinStrategyRegistry(),
|
||||
marketData = new EventEmitter(),
|
||||
}: StrategyDependencies & { registry?: StrategyRegistry; marketData?: EventEmitter }) {
|
||||
return new StrategyManager({
|
||||
logger,
|
||||
execution,
|
||||
marketData,
|
||||
createStrategy: config => registry.create(config, { execution, modeManager }),
|
||||
});
|
||||
}
|
||||
|
||||
export class CounterStrategy extends BaseStrategy {
|
||||
count = 0;
|
||||
equities: number[] = [];
|
||||
|
|
@ -69,8 +89,20 @@ export async function attachCounter(
|
|||
execution: ExecutionService,
|
||||
strategy = new CounterStrategy(execution)
|
||||
) {
|
||||
const manager = new StrategyManager({ logger, custom: { ExecutionService: execution } });
|
||||
await manager.attachStrategy(strategy);
|
||||
const manager = new StrategyManager({
|
||||
logger,
|
||||
execution,
|
||||
marketData: new EventEmitter(),
|
||||
createStrategy: () => {
|
||||
throw new Error('Counter fixtures attach their strategies directly');
|
||||
},
|
||||
});
|
||||
try {
|
||||
await manager.attachStrategy(strategy);
|
||||
} catch (error) {
|
||||
await manager.shutdown();
|
||||
throw error;
|
||||
}
|
||||
return { manager, strategy };
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue