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
36
apps/stock/web-api/src/services/research-services.ts
Normal file
36
apps/stock/web-api/src/services/research-services.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { requireServices, type IServiceContainer } from '@stock-bot/services';
|
||||
import { BacktestResults } from './backtests/results';
|
||||
import { ChronologicalValidationService } from './chronological-validation.service';
|
||||
import { ExperimentsService } from './experiments.service';
|
||||
import { PaperDeploymentsService } from './paper-deployments.service';
|
||||
import { ResearchEvidenceResolver } from './research-evidence';
|
||||
import { ResearchService } from './research.service';
|
||||
import { StrategyCatalogService } from './strategy-catalog.service';
|
||||
import { WalkForwardService } from './walk-forward.service';
|
||||
|
||||
/** Per-application composition only: constructors do no I/O and do not start workers or paper hosts. */
|
||||
export function createResearchServices(
|
||||
container: IServiceContainer,
|
||||
options: { paperIdentity?: ConstructorParameters<typeof PaperDeploymentsService>[2] } = {}
|
||||
) {
|
||||
const results = new BacktestResults(requireServices(container, 'postgres'));
|
||||
const experiments = new ExperimentsService(container);
|
||||
const validations = new ChronologicalValidationService(container, { experiments, results });
|
||||
const walkForwards = new WalkForwardService(container, { experiments, validations });
|
||||
const catalog = new StrategyCatalogService(container);
|
||||
const evidence = new ResearchEvidenceResolver(container, results);
|
||||
const research = new ResearchService(container, { evidence, catalog });
|
||||
const paperDeployments = new PaperDeploymentsService(container, results, options.paperIdentity);
|
||||
return {
|
||||
results,
|
||||
experiments,
|
||||
validations,
|
||||
walkForwards,
|
||||
catalog,
|
||||
evidence,
|
||||
research,
|
||||
paperDeployments,
|
||||
};
|
||||
}
|
||||
|
||||
export type ResearchServices = ReturnType<typeof createResearchServices>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue