Remove legacy strategy frameworks and clarify supported execution paths
This commit is contained in:
parent
4207bf2c1c
commit
783b619846
28 changed files with 996 additions and 4689 deletions
|
|
@ -9,6 +9,7 @@ import { PostgreSQLClient } from '@stock-bot/postgres';
|
|||
import type { MongoDBClient } from '@stock-bot/services';
|
||||
import type { BacktestRunResult } from '@stock-bot/types';
|
||||
import { persistEodPrices } from '../../apps/stock/data-ingestion/src/handlers/eod/shared/price-storage';
|
||||
import { runMultiStrategyBacktest } from '../../apps/stock/orchestrator/examples/multi-strategy-backtest';
|
||||
import { createBacktestRoutes } from '../../apps/stock/orchestrator/src/api/rest/backtest';
|
||||
import { BacktestRunner } from '../../apps/stock/orchestrator/src/backtest/BacktestRunner';
|
||||
import {
|
||||
|
|
@ -276,6 +277,36 @@ describe('one backtest execution workflow', () => {
|
|||
}
|
||||
});
|
||||
|
||||
test('the maintained multi-strategy example runs through the composed runner and persists real results', async () => {
|
||||
const f = await fixture();
|
||||
const services = await typescriptRuntime(f);
|
||||
const runner = services.custom!.BacktestRunner!;
|
||||
cleanup.unshift(async () => {
|
||||
await runner.shutdown();
|
||||
await services.custom?.ModeManager?.shutdown();
|
||||
});
|
||||
const result = await runMultiStrategyBacktest(runner, config);
|
||||
expect(result.status).toBe('completed');
|
||||
expect(result.engine).toBe('typescript');
|
||||
expect(result.trades.length).toBeGreaterThan(0);
|
||||
expect(result.config.config).toBeUndefined();
|
||||
expect(config.config).toEqual({ fastPeriod: 3, slowPeriod: 7 });
|
||||
expect(result.config.strategies?.map(strategy => strategy.name)).toEqual([
|
||||
'sma-crossover',
|
||||
'mean-reversion',
|
||||
]);
|
||||
const strategies = services.custom!.StrategyManager!.getAllStrategies();
|
||||
expect(strategies.map(strategy => strategy.getCheckpointVersion())).toEqual([
|
||||
'sma-crossover-fixed/v2',
|
||||
'mean-reversion/v2',
|
||||
]);
|
||||
expect(result.config.dataset?.barCount).toBe(70);
|
||||
expect((await f.postgres.query('SELECT status FROM runs')).rows).toEqual([
|
||||
{ status: 'completed' },
|
||||
]);
|
||||
expect((await f.postgres.query('SELECT * FROM backtest_results')).rows).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('TypeScript cancellation is persisted without a partial success or completion event', async () => {
|
||||
const f = await fixture();
|
||||
const services = await typescriptRuntime(f);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue