refactor(api): compose research services with narrow collaborators (CL28)
This commit is contained in:
parent
3a63b2039e
commit
24487d35da
28 changed files with 281 additions and 94 deletions
|
|
@ -16,13 +16,13 @@ import { parseValidationDetail } from '../../apps/stock/config/src/contracts/res
|
|||
import { parseChronologicalValidationPreview } from '../../apps/stock/config/src/contracts/research-responses/validation-preview';
|
||||
import { parseWalkForwardDetail } from '../../apps/stock/config/src/contracts/research-responses/walk-forward';
|
||||
import { canonicalRiskSessionClock } from '../../apps/stock/web-api/src/services/canonical-risk-clock';
|
||||
import { ChronologicalValidationService } from '../../apps/stock/web-api/src/services/chronological-validation.service';
|
||||
import {
|
||||
buildExperimentPreview,
|
||||
experimentHash,
|
||||
experimentTrialRequest,
|
||||
} from '../../apps/stock/web-api/src/services/experiment-input';
|
||||
import { ExperimentsService } from '../../apps/stock/web-api/src/services/experiments.service';
|
||||
import { createResearchServices } from '../../apps/stock/web-api/src/services/research-services';
|
||||
import {
|
||||
selectValidationWinner,
|
||||
validationPhasePreview,
|
||||
|
|
@ -181,7 +181,7 @@ async function pendingValidation(preview: ChronologicalValidationPreview, id = v
|
|||
validation_selection: null,
|
||||
validation_report: null,
|
||||
});
|
||||
return new ChronologicalValidationService(stored.container).readDetail(stored.client, id);
|
||||
return createResearchServices(stored.container).validations.readDetail(stored.client, id);
|
||||
}
|
||||
|
||||
for (const [label, parameters] of [
|
||||
|
|
|
|||
112
test/integration/research-service-composition.test.ts
Normal file
112
test/integration/research-service-composition.test.ts
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
import { randomUUID } from 'node:crypto';
|
||||
import { expect, mock, test } from 'bun:test';
|
||||
import { Hono } from 'hono';
|
||||
import type { PoolClient } from 'pg';
|
||||
import type { IServiceContainer } from '@stock-bot/services';
|
||||
import { createExperimentRoutes } from '../../apps/stock/web-api/src/routes/experiments.routes';
|
||||
import { createPaperDeploymentRoutes } from '../../apps/stock/web-api/src/routes/paper-deployments.routes';
|
||||
import { createResearchRoutes } from '../../apps/stock/web-api/src/routes/research.routes';
|
||||
import { createStrategyRoutes } from '../../apps/stock/web-api/src/routes/strategies.routes';
|
||||
import { ResearchEvidenceResolver } from '../../apps/stock/web-api/src/services/research-evidence';
|
||||
import { createResearchServices } from '../../apps/stock/web-api/src/services/research-services';
|
||||
import { walkForwardDataset } from '../fixtures/walk-forward';
|
||||
|
||||
test('composing research services and reading lists needs no worker, paper host, or transaction', async () => {
|
||||
const query = mock(async () => ({ rows: [] }));
|
||||
const transaction = mock(async () => {
|
||||
throw new Error('Read-only listing must not start a transaction');
|
||||
});
|
||||
const paperIdentity = mock(async () => {
|
||||
throw new Error('Read-only listing must not load a paper host');
|
||||
});
|
||||
const container = { postgres: { query, transaction } } as unknown as IServiceContainer;
|
||||
const services = createResearchServices(container, { paperIdentity });
|
||||
expect(query).not.toHaveBeenCalled();
|
||||
const app = new Hono()
|
||||
.route('/', createResearchRoutes(container, services.research))
|
||||
.route('/', createExperimentRoutes(container, services))
|
||||
.route('/', createStrategyRoutes(container, services.catalog))
|
||||
.route(
|
||||
'/',
|
||||
createPaperDeploymentRoutes(container, {
|
||||
service: services.paperDeployments,
|
||||
origins: ['http://fixture.test'],
|
||||
})
|
||||
);
|
||||
for (const [path, key] of [
|
||||
['research-projects', 'projects'],
|
||||
['experiments', 'experiments'],
|
||||
['strategies', 'strategies'],
|
||||
['paper-deployments', 'deployments'],
|
||||
] as const) {
|
||||
const response = await app.request(`/api/v2/${path}`);
|
||||
expect(response.status).toBe(200);
|
||||
expect(await response.json()).toEqual({ [key]: [] });
|
||||
}
|
||||
expect(query).toHaveBeenCalledTimes(4);
|
||||
expect(transaction).not.toHaveBeenCalled();
|
||||
expect(paperIdentity).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('walk-forward and chronological validation share the injected experiment preview inside their caller transaction', async () => {
|
||||
const client = { query: mock(async () => ({ rows: [] })) } as unknown as PoolClient;
|
||||
const poolQuery = mock(async () => {
|
||||
throw new Error('Collaborator escaped its transaction');
|
||||
});
|
||||
const transaction = mock(async <T>(work: (client: PoolClient) => Promise<T>) => work(client));
|
||||
const services = createResearchServices({
|
||||
postgres: { query: poolQuery, transaction },
|
||||
} as unknown as IServiceContainer);
|
||||
const failure = new Error('Injected preview failure');
|
||||
const lockedPreview = mock(async () => {
|
||||
throw failure;
|
||||
});
|
||||
services.experiments.lockedPreview = lockedPreview;
|
||||
const base = { backtestId: randomUUID(), name: 'Shared preview', grid: { fastPeriod: [1, 2] } };
|
||||
const windows = walkForwardDataset().windows;
|
||||
await expect(services.walkForwards.preview({ ...base, windows })).rejects.toBe(failure);
|
||||
expect(lockedPreview).toHaveBeenLastCalledWith(client, base, 'operator');
|
||||
await expect(
|
||||
services.validations.submit(
|
||||
{ ...base, recipe: windows[0], previewHash: 'a'.repeat(64) },
|
||||
{ principal: 'operator', key: 'validation-preview' }
|
||||
)
|
||||
).rejects.toBe(failure);
|
||||
expect(lockedPreview).toHaveBeenLastCalledWith(client, base, 'operator');
|
||||
expect(lockedPreview).toHaveBeenCalledTimes(2);
|
||||
expect(transaction).toHaveBeenCalledTimes(2);
|
||||
expect(poolQuery).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('evidence accepts only a result-reader collaborator and passes through the supplied transaction', async () => {
|
||||
const runId = randomUUID();
|
||||
const client = {
|
||||
query: mock(async () => ({
|
||||
rows: [{ id: runId, backtest_id: randomUUID(), status: 'completed' }],
|
||||
})),
|
||||
} as unknown as PoolClient;
|
||||
const poolQuery = mock(async () => {
|
||||
throw new Error('Evidence escaped the supplied transaction');
|
||||
});
|
||||
const transaction = mock(async () => {
|
||||
throw new Error('Evidence must not open a nested transaction');
|
||||
});
|
||||
const getRunResults = mock(async () => null);
|
||||
const evidence = new ResearchEvidenceResolver(
|
||||
{ postgres: { query: poolQuery, transaction } } as unknown as IServiceContainer,
|
||||
{ getRunResults }
|
||||
);
|
||||
await expect(
|
||||
evidence.resolve(
|
||||
{
|
||||
runId,
|
||||
metricsVersion: 'canonical-analytics/v1',
|
||||
metricPath: 'analytics.metrics.totalReturn',
|
||||
},
|
||||
client
|
||||
)
|
||||
).rejects.toThrow('Retained evidence result is missing');
|
||||
expect(getRunResults).toHaveBeenCalledWith(runId, client);
|
||||
expect(poolQuery).not.toHaveBeenCalled();
|
||||
expect(transaction).not.toHaveBeenCalled();
|
||||
});
|
||||
|
|
@ -18,7 +18,7 @@ import { createResearchAgentRoutes } from '../../apps/stock/web-api/src/routes/r
|
|||
import { createResearchRoutes } from '../../apps/stock/web-api/src/routes/research.routes';
|
||||
import { createStrategyRoutes } from '../../apps/stock/web-api/src/routes/strategies.routes';
|
||||
import { ResearchAgentsService } from '../../apps/stock/web-api/src/services/research-agents.service';
|
||||
import { ResearchService } from '../../apps/stock/web-api/src/services/research.service';
|
||||
import { createResearchServices } from '../../apps/stock/web-api/src/services/research-services';
|
||||
import {
|
||||
runResearchCycle,
|
||||
type ResearchCycleEvent,
|
||||
|
|
@ -91,7 +91,7 @@ async function fixture() {
|
|||
);
|
||||
const container = { postgres, logger };
|
||||
const agents = new ResearchAgentsService(container),
|
||||
research = new ResearchService(container);
|
||||
research = createResearchServices(container).research;
|
||||
const project = await research.createProject({ title: 'AI research acceptance' }, 'operator');
|
||||
const provisioned = await agents.create({
|
||||
name: 'Workflow researcher',
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ import { PostgresBacktestRunRepository } from '../../apps/stock/orchestrator/src
|
|||
import { RustBacktestAdapter } from '../../apps/stock/orchestrator/src/backtest/RustBacktestAdapter';
|
||||
import { createExperimentRoutes } from '../../apps/stock/web-api/src/routes/experiments.routes';
|
||||
import { BacktestServiceV2 } from '../../apps/stock/web-api/src/services/backtest-v2.service';
|
||||
import { ChronologicalValidationService } from '../../apps/stock/web-api/src/services/chronological-validation.service';
|
||||
import { experimentHash } from '../../apps/stock/web-api/src/services/experiment-input';
|
||||
import { ExperimentsService } from '../../apps/stock/web-api/src/services/experiments.service';
|
||||
import { createResearchServices } from '../../apps/stock/web-api/src/services/research-services';
|
||||
import { StrategyCatalogService } from '../../apps/stock/web-api/src/services/strategy-catalog.service';
|
||||
import {
|
||||
selectValidationWinner,
|
||||
|
|
@ -168,7 +168,7 @@ async function fixture(poolMax = 1, withValidation = true) {
|
|||
}
|
||||
return rows;
|
||||
};
|
||||
const validations = new ChronologicalValidationService(container);
|
||||
const validations = createResearchServices(container).validations;
|
||||
const repository = new PostgresBacktestRunRepository(postgres);
|
||||
const execute = async (id: string) => {
|
||||
const engine = new RustBacktestAdapter({
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ import { PostgresBacktestRunRepository } from '../../apps/stock/orchestrator/src
|
|||
import { RustBacktestAdapter } from '../../apps/stock/orchestrator/src/backtest/RustBacktestAdapter';
|
||||
import { createExperimentRoutes } from '../../apps/stock/web-api/src/routes/experiments.routes';
|
||||
import { BacktestServiceV2 } from '../../apps/stock/web-api/src/services/backtest-v2.service';
|
||||
import { ChronologicalValidationService } from '../../apps/stock/web-api/src/services/chronological-validation.service';
|
||||
import { ExperimentError } from '../../apps/stock/web-api/src/services/experiment-input';
|
||||
import { ExperimentsService } from '../../apps/stock/web-api/src/services/experiments.service';
|
||||
import { canonicalReproductionHash } from '../../apps/stock/web-api/src/services/reproduction-comparison';
|
||||
import { createResearchServices } from '../../apps/stock/web-api/src/services/research-services';
|
||||
import { StrategyCatalogService } from '../../apps/stock/web-api/src/services/strategy-catalog.service';
|
||||
import { retainResearchDataset } from '../../scripts/import-research-dataset';
|
||||
import { packageBuiltinStrategies } from '../../scripts/package-builtin-strategies';
|
||||
|
|
@ -162,7 +162,7 @@ async function fixture(poolMax = 1, withCosts = true, capital = 10000) {
|
|||
}
|
||||
return rows;
|
||||
};
|
||||
const validations = new ChronologicalValidationService(container);
|
||||
const validations = createResearchServices(container).validations;
|
||||
const repository = new PostgresBacktestRunRepository(postgres);
|
||||
const execute = async (id: string) => {
|
||||
const engine = new RustBacktestAdapter({
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import { PostgresBacktestRunRepository } from '../../apps/stock/orchestrator/src
|
|||
import { RustBacktestAdapter } from '../../apps/stock/orchestrator/src/backtest/RustBacktestAdapter';
|
||||
import { createExperimentRoutes } from '../../apps/stock/web-api/src/routes/experiments.routes';
|
||||
import { BacktestServiceV2 } from '../../apps/stock/web-api/src/services/backtest-v2.service';
|
||||
import { ChronologicalValidationService } from '../../apps/stock/web-api/src/services/chronological-validation.service';
|
||||
import { ExperimentsService } from '../../apps/stock/web-api/src/services/experiments.service';
|
||||
import { createResearchServices } from '../../apps/stock/web-api/src/services/research-services';
|
||||
import { StrategyCatalogService } from '../../apps/stock/web-api/src/services/strategy-catalog.service';
|
||||
import { retainResearchDataset } from '../../scripts/import-research-dataset';
|
||||
import { packageBuiltinStrategies } from '../../scripts/package-builtin-strategies';
|
||||
|
|
@ -163,7 +163,7 @@ async function fixture(poolMax = 1, withCosts = true, capital = 10000) {
|
|||
}
|
||||
return rows;
|
||||
};
|
||||
const validations = new ChronologicalValidationService(container);
|
||||
const validations = createResearchServices(container).validations;
|
||||
const repository = new PostgresBacktestRunRepository(postgres);
|
||||
const execute = async (id: string) => {
|
||||
const engine = new RustBacktestAdapter({
|
||||
|
|
|
|||
|
|
@ -13,11 +13,10 @@ import { PostgresBacktestRunRepository } from '../../apps/stock/orchestrator/src
|
|||
import { RustBacktestAdapter } from '../../apps/stock/orchestrator/src/backtest/RustBacktestAdapter';
|
||||
import { runStrategyReplay } from '../../apps/stock/orchestrator/src/backtest/strategy-runtime';
|
||||
import { createBuiltinStrategy } from '../../apps/stock/orchestrator/src/strategies/canonical-builtins';
|
||||
import { ChronologicalValidationService } from '../../apps/stock/web-api/src/services/chronological-validation.service';
|
||||
import { ExperimentsService } from '../../apps/stock/web-api/src/services/experiments.service';
|
||||
import { researchGrantPolicy } from '../../apps/stock/web-api/src/services/research-agent-budget';
|
||||
import { ResearchAgentsService } from '../../apps/stock/web-api/src/services/research-agents.service';
|
||||
import { WalkForwardService } from '../../apps/stock/web-api/src/services/walk-forward.service';
|
||||
import { createResearchServices } from '../../apps/stock/web-api/src/services/research-services';
|
||||
import { retainResearchDataset } from '../../scripts/import-research-dataset';
|
||||
import { canonicalAdmissionFixture } from '../fixtures/canonical-admission';
|
||||
import { walkForwardDataset } from '../fixtures/walk-forward';
|
||||
|
|
@ -359,8 +358,7 @@ suite('isolated candidate durable research', () => {
|
|||
endDate: new Date(data.dataset.manifest.bounds.tradeEnd).toISOString(),
|
||||
config: { ...f.definition.config, datasetHash: data.dataset.manifest.hash },
|
||||
});
|
||||
const walks = new WalkForwardService(f.container),
|
||||
validations = new ChronologicalValidationService(f.container);
|
||||
const { walkForwards: walks, validations } = createResearchServices(f.container);
|
||||
const input = {
|
||||
name: 'Candidate rolling windows',
|
||||
backtestId: f.draft.id,
|
||||
|
|
|
|||
|
|
@ -17,9 +17,8 @@ import {
|
|||
import { readPaperHostIdentity } from '../../apps/stock/orchestrator/src/paper/paper-host-identity';
|
||||
import { PaperDeploymentHost } from '../../apps/stock/orchestrator/src/paper/PaperDeploymentHost';
|
||||
import { BacktestServiceV2 } from '../../apps/stock/web-api/src/services/backtest-v2.service';
|
||||
import { ChronologicalValidationService } from '../../apps/stock/web-api/src/services/chronological-validation.service';
|
||||
import { ExperimentsService } from '../../apps/stock/web-api/src/services/experiments.service';
|
||||
import { PaperDeploymentsService } from '../../apps/stock/web-api/src/services/paper-deployments.service';
|
||||
import { createResearchServices } from '../../apps/stock/web-api/src/services/research-services';
|
||||
import { StrategyCatalogService } from '../../apps/stock/web-api/src/services/strategy-catalog.service';
|
||||
import { retainResearchDataset } from '../../scripts/import-research-dataset';
|
||||
import { packageBuiltinStrategies } from '../../scripts/package-builtin-strategies';
|
||||
|
|
@ -72,11 +71,12 @@ async function fixture(max = 1, withPromotion = true, candidate = false) {
|
|||
Object.defineProperty(postgres, 'connectionPool', { get: () => pool });
|
||||
Object.defineProperty(postgres, 'query', { value: pool.query.bind(pool) });
|
||||
const container = { postgres, logger },
|
||||
researchServices = createResearchServices(container),
|
||||
api = new BacktestServiceV2(container),
|
||||
experiments = new ExperimentsService(container),
|
||||
validations = new ChronologicalValidationService(container),
|
||||
validations = researchServices.validations,
|
||||
catalog = new StrategyCatalogService(container),
|
||||
service = new PaperDeploymentsService(container);
|
||||
service = researchServices.paperDeployments;
|
||||
const pkg = (await packageBuiltinStrategies())[0];
|
||||
if (!pkg) {
|
||||
throw new Error('Missing builtin');
|
||||
|
|
@ -495,14 +495,18 @@ describe.skipIf(!url)('human-reviewed paper deployment', () => {
|
|||
}, 60000);
|
||||
test('changed installed host and retained artifact cannot initialize or overwrite an account', async () => {
|
||||
const f = await fixture(),
|
||||
drifted = new PaperDeploymentsService(f.container, async () => ({
|
||||
drifted = createResearchServices(f.container, {
|
||||
paperIdentity: async () => ({
|
||||
...(await readPaperHostIdentity()),
|
||||
hostSha256: 'f'.repeat(64),
|
||||
}),
|
||||
}).paperDeployments;
|
||||
const wrongNative = createResearchServices(f.container, {
|
||||
paperIdentity: async () => ({
|
||||
...(await readPaperHostIdentity()),
|
||||
hostSha256: 'f'.repeat(64),
|
||||
}));
|
||||
const wrongNative = new PaperDeploymentsService(f.container, async () => ({
|
||||
...(await readPaperHostIdentity()),
|
||||
engineBinarySha256: 'f'.repeat(64),
|
||||
}));
|
||||
engineBinarySha256: 'f'.repeat(64),
|
||||
}),
|
||||
}).paperDeployments;
|
||||
await expect(wrongNative.preview(f.promotion)).rejects.toThrow('same native');
|
||||
const preview = await drifted.preview(f.promotion),
|
||||
saved = await drifted.create(
|
||||
|
|
|
|||
|
|
@ -17,13 +17,11 @@ import { createRoutes } from '../../apps/stock/web-api/src/routes/create-routes'
|
|||
import { createExperimentRoutes } from '../../apps/stock/web-api/src/routes/experiments.routes';
|
||||
import { BacktestServiceV2 } from '../../apps/stock/web-api/src/services/backtest-v2.service';
|
||||
import { BacktestDispatcher } from '../../apps/stock/web-api/src/services/BacktestDispatcher';
|
||||
import { ChronologicalValidationService } from '../../apps/stock/web-api/src/services/chronological-validation.service';
|
||||
import { ExperimentsService } from '../../apps/stock/web-api/src/services/experiments.service';
|
||||
import { researchGrantPolicy } from '../../apps/stock/web-api/src/services/research-agent-budget';
|
||||
import { ResearchAgentsService } from '../../apps/stock/web-api/src/services/research-agents.service';
|
||||
import { ResearchService } from '../../apps/stock/web-api/src/services/research.service';
|
||||
import { createResearchServices } from '../../apps/stock/web-api/src/services/research-services';
|
||||
import { StrategyCatalogService } from '../../apps/stock/web-api/src/services/strategy-catalog.service';
|
||||
import { WalkForwardService } from '../../apps/stock/web-api/src/services/walk-forward.service';
|
||||
import { retainResearchDataset } from '../../scripts/import-research-dataset';
|
||||
import { packageBuiltinStrategies } from '../../scripts/package-builtin-strategies';
|
||||
import { canonicalSettings } from '../fixtures/canonical-research';
|
||||
|
|
@ -142,7 +140,7 @@ async function fixture(poolMax = 4, withAgents = true, dataset = canonicalSmaFix
|
|||
postgres,
|
||||
container,
|
||||
agents: new ResearchAgentsService(container),
|
||||
research: new ResearchService(container),
|
||||
research: createResearchServices(container).research,
|
||||
schema,
|
||||
api,
|
||||
experiments,
|
||||
|
|
@ -687,8 +685,7 @@ describe.skipIf(!url)('authoritative research principals and budgets', () => {
|
|||
);
|
||||
expect(cost.trials).toHaveLength(2);
|
||||
await f.experiments.cancel(cost.id);
|
||||
const validation = new ChronologicalValidationService(f.container),
|
||||
walk = new WalkForwardService(f.container);
|
||||
const { validations: validation, walkForwards: walk } = createResearchServices(f.container);
|
||||
const input = {
|
||||
backtestId: f.draft.id,
|
||||
name: 'Validation',
|
||||
|
|
@ -909,7 +906,7 @@ describe.skipIf(!url)('authoritative research principals and budgets', () => {
|
|||
[randomUUID(), runId, b.agent.id, randomUUID(), 'a'.repeat(64)]
|
||||
)
|
||||
).rejects.toThrow(/owning.*principal/);
|
||||
const validation = new ChronologicalValidationService(f.container),
|
||||
const validation = createResearchServices(f.container).validations,
|
||||
input = {
|
||||
backtestId: f.draft.id,
|
||||
name: 'Owned phases',
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { PostgresBacktestRunRepository } from '../../apps/stock/orchestrator/src
|
|||
import { BacktestLeaseLostError } from '../../apps/stock/orchestrator/src/backtest/run-repository';
|
||||
import { canonicalReproductionHash } from '../../apps/stock/web-api/src/services/reproduction-comparison';
|
||||
import { ResearchAgentsService } from '../../apps/stock/web-api/src/services/research-agents.service';
|
||||
import { ResearchService } from '../../apps/stock/web-api/src/services/research.service';
|
||||
import { createResearchServices } from '../../apps/stock/web-api/src/services/research-services';
|
||||
import { deferred } from '../fixtures/canonical-runner';
|
||||
import { logger } from '../fixtures/execution';
|
||||
import { nativeReplayFixture } from '../fixtures/native-replay';
|
||||
|
|
@ -201,7 +201,7 @@ describe.skipIf(!process.env.PIPELINE_TEST_DATABASE_URL || !process.env.BACKTEST
|
|||
}, 60000);
|
||||
test('four slots cannot bypass agent admission capacity or per-attempt absolute deadlines', async () => {
|
||||
const f = await fixture();
|
||||
const research = new ResearchService({ postgres: f.postgres, logger });
|
||||
const research = createResearchServices({ postgres: f.postgres, logger }).research;
|
||||
const project = await research.createProject({ title: 'Pool budget gate' }, 'operator');
|
||||
const agents = new ResearchAgentsService({ postgres: f.postgres, logger });
|
||||
const agent = await agents.create({
|
||||
|
|
|
|||
|
|
@ -13,12 +13,10 @@ import { PostgresBacktestRunRepository } from '../../apps/stock/orchestrator/src
|
|||
import { RustBacktestAdapter } from '../../apps/stock/orchestrator/src/backtest/RustBacktestAdapter';
|
||||
import { createResearchRoutes } from '../../apps/stock/web-api/src/routes/research.routes';
|
||||
import { BacktestServiceV2 } from '../../apps/stock/web-api/src/services/backtest-v2.service';
|
||||
import { ChronologicalValidationService } from '../../apps/stock/web-api/src/services/chronological-validation.service';
|
||||
import { experimentHash } from '../../apps/stock/web-api/src/services/experiment-input';
|
||||
import { ExperimentsService } from '../../apps/stock/web-api/src/services/experiments.service';
|
||||
import { ResearchService } from '../../apps/stock/web-api/src/services/research.service';
|
||||
import { createResearchServices } from '../../apps/stock/web-api/src/services/research-services';
|
||||
import { StrategyCatalogService } from '../../apps/stock/web-api/src/services/strategy-catalog.service';
|
||||
import { WalkForwardService } from '../../apps/stock/web-api/src/services/walk-forward.service';
|
||||
import { retainResearchDataset } from '../../scripts/import-research-dataset';
|
||||
import { packageBuiltinStrategies } from '../../scripts/package-builtin-strategies';
|
||||
import { canonicalSettings } from '../fixtures/canonical-research';
|
||||
|
|
@ -145,7 +143,8 @@ async function fixture(poolMax = 1, withSources = true) {
|
|||
}
|
||||
return rows;
|
||||
};
|
||||
const validations = new ChronologicalValidationService(container);
|
||||
const services = createResearchServices(container);
|
||||
const validations = services.validations;
|
||||
const repository = new PostgresBacktestRunRepository(postgres);
|
||||
const execute = async (id: string) => {
|
||||
const engine = new RustBacktestAdapter({
|
||||
|
|
@ -179,7 +178,7 @@ async function fixture(poolMax = 1, withSources = true) {
|
|||
{ autoStart: false }
|
||||
),
|
||||
validations,
|
||||
walks: new WalkForwardService(container),
|
||||
walks: services.walkForwards,
|
||||
repository,
|
||||
execute,
|
||||
api,
|
||||
|
|
@ -191,7 +190,7 @@ async function fixture(poolMax = 1, withSources = true) {
|
|||
draft,
|
||||
dataset,
|
||||
input,
|
||||
research: new ResearchService(container),
|
||||
research: services.research,
|
||||
container,
|
||||
schema,
|
||||
review,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { BacktestRunner } from '../../apps/stock/orchestrator/src/backtest/Backt
|
|||
import { PostgresBacktestRunRepository } from '../../apps/stock/orchestrator/src/backtest/PostgresBacktestRunRepository';
|
||||
import { RustBacktestAdapter } from '../../apps/stock/orchestrator/src/backtest/RustBacktestAdapter';
|
||||
import { BacktestServiceV2 } from '../../apps/stock/web-api/src/services/backtest-v2.service';
|
||||
import { ResearchService } from '../../apps/stock/web-api/src/services/research.service';
|
||||
import { createResearchServices } from '../../apps/stock/web-api/src/services/research-services';
|
||||
import { StrategyCatalogService } from '../../apps/stock/web-api/src/services/strategy-catalog.service';
|
||||
import { retainResearchDataset } from '../../scripts/import-research-dataset';
|
||||
import { packageBuiltinStrategies } from '../../scripts/package-builtin-strategies';
|
||||
|
|
@ -81,7 +81,7 @@ async function fixture(applyWorkspace = true, maxConnections = 10) {
|
|||
Object.defineProperty(postgres, 'connectionPool', { get: () => pool });
|
||||
Object.defineProperty(postgres, 'query', { value: pool.query.bind(pool) });
|
||||
const container = { postgres, logger };
|
||||
const service = new ResearchService(container);
|
||||
const service = createResearchServices(container).research;
|
||||
const backtests = new BacktestServiceV2(container);
|
||||
const catalog = new StrategyCatalogService(container);
|
||||
const legacy = async (status = 'completed') => {
|
||||
|
|
|
|||
|
|
@ -12,11 +12,10 @@ import { PostgresBacktestRunRepository } from '../../apps/stock/orchestrator/src
|
|||
import { RustBacktestAdapter } from '../../apps/stock/orchestrator/src/backtest/RustBacktestAdapter';
|
||||
import { createExperimentRoutes } from '../../apps/stock/web-api/src/routes/experiments.routes';
|
||||
import { BacktestServiceV2 } from '../../apps/stock/web-api/src/services/backtest-v2.service';
|
||||
import { ChronologicalValidationService } from '../../apps/stock/web-api/src/services/chronological-validation.service';
|
||||
import { ExperimentError } from '../../apps/stock/web-api/src/services/experiment-input';
|
||||
import { ExperimentsService } from '../../apps/stock/web-api/src/services/experiments.service';
|
||||
import { createResearchServices } from '../../apps/stock/web-api/src/services/research-services';
|
||||
import { StrategyCatalogService } from '../../apps/stock/web-api/src/services/strategy-catalog.service';
|
||||
import { WalkForwardService } from '../../apps/stock/web-api/src/services/walk-forward.service';
|
||||
import { retainResearchDataset } from '../../scripts/import-research-dataset';
|
||||
import { packageBuiltinStrategies } from '../../scripts/package-builtin-strategies';
|
||||
import { canonicalSettings } from '../fixtures/canonical-research';
|
||||
|
|
@ -158,7 +157,8 @@ async function fixture(poolMax = 1, withWalkForward = true) {
|
|||
}
|
||||
return rows;
|
||||
};
|
||||
const validations = new ChronologicalValidationService(container);
|
||||
const services = createResearchServices(container);
|
||||
const validations = services.validations;
|
||||
const repository = new PostgresBacktestRunRepository(postgres);
|
||||
const execute = async (id: string) => {
|
||||
const engine = new RustBacktestAdapter({
|
||||
|
|
@ -192,7 +192,7 @@ async function fixture(poolMax = 1, withWalkForward = true) {
|
|||
{ autoStart: false }
|
||||
),
|
||||
validations,
|
||||
walks: new WalkForwardService(container),
|
||||
walks: services.walkForwards,
|
||||
repository,
|
||||
execute,
|
||||
api,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue