The DI system inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-monorepo-parallel/llms.txt
Use this file to discover all available pages before exploring further.
@pro/core uses symbol-keyed tokens managed by di-kit’s createActivator("pro"). Adding a service is a deterministic five-step recipe that touches exactly four files in packages/core/ — no content files under ./content/ ever need to change, because globalThis.core is a typed reference to the ioc object and gains the new service automatically once ioc is updated and the package is rebuilt.
File — create the service class
Drop your new service file under the appropriate category directory:For reference, the existing A hypothetical
CryptoYodaScreenService lives under services/screen/ and injects its own dependencies lazily via inject():PriceAlertService would follow the same structure:Symbol — register a DI token in types.ts
Open
packages/core/src/lib/core/types.ts and add your symbol to the appropriate group. The file currently defines four groups that are spread into TYPES:Provider — register a factory in provide.ts
Open
packages/core/src/lib/core/provide.ts and add a provide() call. Each call associates the symbol from TYPES with a factory function that constructs the service instance. The existing file uses braced blocks to keep groups visually separated:Expose — add to the ioc object in lib/index.ts
Open The
packages/core/src/lib/index.ts and add an inject<T>() entry to the appropriate group object. The ioc export is what gets assigned to globalThis.core — every field added here becomes immediately accessible as core.<field> in strategy files:declare global { var core: typeof ioc; } block at the bottom of index.ts ensures TypeScript infers the new field across the entire workspace without any additional type declarations.Why content/ files never need to change
globalThis.core is assigned in packages/core/src/lib/index.ts with Object.assign(globalThis, { core: ioc }). The declare global { var core: typeof ioc; } block in the same file makes TypeScript treat core as a globally typed variable throughout the workspace, resolved via the paths entry in tsconfig.json that points at the rolled-up types.d.ts. Once ioc gains a new service entry, that service is automatically available on core in every strategy file — no re-bundling or import changes required in ./content/.
The DI system uses lazy injection —
inject() resolves the service instance when the property is first accessed, not at module load time. This means circular dependencies between services are safe as long as services do not access each other during their own construction (i.e., not in a constructor body). Accessing this.otherService inside a method is always safe.