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
|
|
@ -8,10 +8,8 @@ import { registerOrchestratorServices } from '../../apps/stock/orchestrator/src/
|
|||
import { builtinStrategySelectionSchema } from '../../apps/stock/orchestrator/src/contracts/builtin-strategy';
|
||||
import type { PaperRuntime } from '../../apps/stock/orchestrator/src/contracts/paper-runtime';
|
||||
import { createBuiltinStrategy } from '../../apps/stock/orchestrator/src/strategies/canonical-builtins';
|
||||
import {
|
||||
BacktestConfigSchema,
|
||||
type OrchestratorServices,
|
||||
} from '../../apps/stock/orchestrator/src/types';
|
||||
import type { OrchestratorServices } from '../../apps/stock/orchestrator/src/types';
|
||||
import { canonicalAdmissionFixture } from '../fixtures/canonical-admission';
|
||||
import { logger } from '../fixtures/execution';
|
||||
import { paperConfig, paperFixture, paperFrame } from '../fixtures/paper-runtime';
|
||||
|
||||
|
|
@ -131,6 +129,7 @@ describe.skipIf(!process.env.PIPELINE_TEST_DATABASE_URL)(
|
|||
const services: OrchestratorServices = { logger, postgres: f.postgres };
|
||||
container.register({ serviceContainer: asValue(services) });
|
||||
await registerOrchestratorServices(container, {
|
||||
role: 'paper',
|
||||
canonicalPaper: config,
|
||||
nativeExecutionTimeoutMs: 10000,
|
||||
});
|
||||
|
|
@ -153,36 +152,15 @@ describe.skipIf(!process.env.PIPELINE_TEST_DATABASE_URL)(
|
|||
}
|
||||
expect((await custom.CanonicalPaperRuntime!.status()).active).toBe(false);
|
||||
const before = await f.snapshot();
|
||||
const research = BacktestConfigSchema.parse({
|
||||
mode: 'backtest',
|
||||
strategy: 'sma-crossover',
|
||||
symbols: ['RESEARCH.TEST'],
|
||||
startDate: '2024-01-01T00:00:00.000Z',
|
||||
endDate: '2024-01-21T00:00:00.000Z',
|
||||
initialCapital: 100000,
|
||||
dataFrequency: '1d',
|
||||
commission: 0,
|
||||
slippage: 0,
|
||||
config: { fastPeriod: 2, slowPeriod: 3 },
|
||||
});
|
||||
custom.StorageService!.getHistoricalBars = async () =>
|
||||
Array.from({ length: 20 }, (_, i) => {
|
||||
const close = 100 + Math.sin(i) * 5;
|
||||
return {
|
||||
symbol: 'RESEARCH.TEST',
|
||||
source: 'eod' as const,
|
||||
timestamp: new Date(Date.parse(research.startDate) + i * 86400000),
|
||||
open: close,
|
||||
high: close + 1,
|
||||
low: close - 1,
|
||||
close,
|
||||
volume: 1000000,
|
||||
};
|
||||
});
|
||||
expect((await custom.BacktestEngine!.runBacktest(research)).status).toBe('completed');
|
||||
const research = await canonicalAdmissionFixture(f.pool, f.postgres);
|
||||
custom.StorageService!.getHistoricalBars = async () => {
|
||||
throw new Error('Canonical execution cannot query providers');
|
||||
};
|
||||
const run = await research.api.createRun({ backtestId: research.draft.id });
|
||||
expect((await custom.BacktestRunner!.runQueued(run.id)).status).toBe('completed');
|
||||
expect(await f.snapshot()).toEqual(before);
|
||||
await expect(
|
||||
registerOrchestratorServices(container, { canonicalPaper: config })
|
||||
registerOrchestratorServices(container, { role: 'paper', canonicalPaper: config })
|
||||
).rejects.toThrow('fresh runtime composition');
|
||||
await expect(registerOrchestratorServices(container)).rejects.toThrow(
|
||||
'fresh runtime composition'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue