Skip to main content

Documentation 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 exports a dependency-injection container built on di-kit’s createActivator('pro'), wiring every built-in service into a single typed object that is simultaneously exported as ioc and assigned to globalThis.core — so strategy files anywhere in the monorepo can access services without a single import statement.

createActivator(‘pro’)

The container is bootstrapped in packages/core/src/lib/core/di.ts:
import { createActivator } from "di-kit";

export const { init, inject, provide } = createActivator("pro");
The three returned functions cover the entire public surface of the container.

provide()

provide(token: Symbol, factory: () => T): void
Registers a factory function for the given DI token. The factory is called lazily — only when inject() first resolves the token.
token
Symbol
required
A unique symbol from the TYPES map that identifies the service.
factory
() => T
required
A zero-argument factory that constructs and returns the service instance.

inject()

inject<T>(token: Symbol): T
Lazily resolves a registered service. The first call for a given token invokes its factory and caches the result; subsequent calls return the same singleton instance.
token
Symbol
required
The TYPES symbol for the service you want to resolve.

init()

init(): void
Triggers eager initialization of all registered providers, ensuring every factory has been invoked and every singleton is live before any consumer code runs.
init() is called automatically at the bottom of packages/core/src/lib/index.ts, after all inject() calls have registered the service references. You do not need to call it manually.

TYPES

TYPES is the canonical symbol token map defined in packages/core/src/lib/core/types.ts. Each symbol is the lookup key used with provide() and inject().
export const TYPES = {
  // base services
  loggerService:             Symbol('loggerService'),

  // db services
  candleDbService:           Symbol('candleDbService'),

  // core services
  scraperService:            Symbol('scraperService'),
  parserService:             Symbol('parserService'),

  // screen services
  cryptoYodaScreenService:   Symbol('cryptoYodaScreenService'),
};
TYPES.loggerService
Symbol
Token for the LoggerService singleton.
TYPES.candleDbService
Symbol
Token for the CandleDbService singleton.
TYPES.scraperService
Symbol
Token for the ScraperService singleton.
TYPES.parserService
Symbol
Token for the ParserService singleton.
TYPES.cryptoYodaScreenService
Symbol
Token for the CryptoYodaScreenService singleton.

ioc

ioc is the fully-typed service bag exported from packages/core/src/lib/index.ts. It is assembled by calling inject<T>() for each token, then spread into a single object.
import "./core/provide";
import { inject, init } from "./core/di";
import TYPES from "./core/types";

import LoggerService              from "./services/base/LoggerService";
import ScraperService             from "./services/core/ScraperService";
import ParserService              from "./services/core/ParserService";
import CryptoYodaScreenService    from "./services/screen/CryptoYodaScreenService";
import CandleDbService            from "./services/db/CandleDbService";

const baseServices = {
  loggerService: inject<LoggerService>(TYPES.loggerService),
};

const dbServices = {
  candleDbService: inject<CandleDbService>(TYPES.candleDbService),
};

const coreServices = {
  scraperService: inject<ScraperService>(TYPES.scraperService),
  parserService:  inject<ParserService>(TYPES.parserService),
};

const screenServices = {
  cryptoYodaScreenService: inject<CryptoYodaScreenService>(TYPES.cryptoYodaScreenService),
};

export const ioc = {
  ...baseServices,
  ...coreServices,
  ...dbServices,
  ...screenServices,
};

init();
ioc.loggerService
LoggerService
General-purpose async logger. Defaults to a no-op implementation — call setLogger() to activate.
ioc.candleDbService
CandleDbService
Mongoose-backed OHLCV candle store with atomic upsert support.
ioc.scraperService
ScraperService
Telegram MTProto scraper for fetching a full day of channel messages.
ioc.parserService
ParserService
Regex-based field extractor that maps raw Telegram messages to typed data.
ioc.cryptoYodaScreenService
CryptoYodaScreenService
Pre-built screener for the crypto_yoda_channel Telegram signal channel.

globalThis.core

After assembling ioc, packages/core/src/lib/index.ts assigns it to globalThis and declares the ambient type so TypeScript resolves it everywhere:
declare global {
  var core: typeof ioc;
}

Object.assign(globalThis, { core: ioc });
This means any file in the monorepo — including strategy files under ./content/ — can call services without any import:
// content/my-strategy.ts  — no imports needed
const hasData = await core.candleDbService.hasCandle(
  "BTCUSDT",
  "1h",
  Date.now() - 3600_000,
);

const messages = await core.scraperService.scrapeDay(
  "my_channel",
  new Date("2024-01-15"),
);
TypeScript types are resolved by mapping @pro/corepackages/core/types.d.ts in the root tsconfig.json paths config, so IDE auto-complete and strict type checking work out of the box.
Because globalThis.core is a reference to the same ioc object, services obtained via core.x are the same singleton instances as those resolved with inject(TYPES.x).

Build docs developers (and LLMs) love