Documentation Index
Fetch the complete documentation index at: https://mintlify.com/backtest-kit/backtest-monorepo-parallel/llms.txt
Use this file to discover all available pages before exploring further.
@pro/core registers five services in its IoC container. Each is a lazy singleton resolved via inject<T>(TYPES.token) and accessible as a property on the core global in any strategy file. This page covers the public API of every service, their configuration requirements, and real usage examples drawn directly from the source.
LoggerService
LoggerService is the central logging abstraction for all packages in the monorepo. Out of the box it is a no-op — no output is produced until a real logger is installed via setLogger. This design keeps test and CI environments silent by default while allowing applications to plug in any compatible logging library.
Accessed via: core.loggerService or inject<LoggerService>(TYPES.loggerService)
ILogger interface
Every method receives atopic string first, followed by optional structured data arguments:
NOOP_LOGGER
The default internal logger isNOOP_LOGGER — all four methods call void 0 and return immediately. This is replaced when setLogger is called.
Methods
log(topic, ...args)
log(topic, ...args)
debug(topic, ...args)
debug(topic, ...args)
info(topic, ...args)
info(topic, ...args)
warn(topic, ...args)
warn(topic, ...args)
setLogger(logger)
setLogger(logger)
Replaces the internal Returns:
_commonLogger with a custom implementation. Call this once at application startup, before any service that uses logging is invoked.Any object satisfying the
ILogger interface.voidUsage example
ScraperService
ScraperService retrieves raw Telegram messages from a public or private channel for a specific calendar day. It uses a singleton MTProto client created by getTelegram() — a singleshot wrapper around TelegramClient from the telegram library. The client reads its session string from ./session.txt on first call.
Accessed via: core.scraperService or inject<ScraperService>(TYPES.scraperService)
Before
ScraperService can be used, you must have generated a session.txt file by running the application once with the --auth flag: npm start -- --auth. Without this file, getTelegram() will throw and prevent the service from initialising.ScraperMessage model
Methods
scrapeDay(channel, date)
Iterates Telegram messages for channel within the UTC day boundaries of date and returns all messages that contain a non-empty text body.
Telegram channel username (e.g.
"crypto_yoda_channel") or numeric channel ID.Any
Date whose UTC date component defines the day to scrape. Time components are discarded — the method always scans 00:00:00.000 to 23:59:59.999 UTC.Promise<ScraperMessage[]> — messages in reverse chronological order (newest first) as returned by client.iterMessages.
Internally, the method:
- Sets
dayStart=datewith UTC hours reset to00:00:00.000 - Sets
dayEnd=datewith UTC hours set to23:59:59.999 - Calls
client.iterMessages(channel, { offsetDate: Math.floor(dayEnd.getTime() / 1000) + 1, reverse: false }) - Skips messages without a text body (
message.messagefalsy) - Breaks iteration once a message timestamp falls before
dayStart
ParserService
ParserService applies a declarative field-extraction format to an array of ScraperMessage objects. Each message is tested against the format’s regex patterns; successfully extracted fields are attached as data, while messages that fail a required pattern receive data: null.
Accessed via: core.parserService or inject<ParserService>(TYPES.parserService)
Type system
ExtractConfig<T>
Describes how to extract a single typed field from raw message text:
FieldMapping
A plain object mapping field names to RegExp | ExtractConfig<any>:
ExtractedData<M>
Derives the output type from a FieldMapping — multi fields become arrays, transform return types flow through correctly:
ParseFormat<T>
Convenience alias when you already have a known output type T:
ParserMessageRaw<M>
Extends ScraperMessage with a nullable data field:
ParserMessageSuccess<M>
A narrowed variant of ParserMessageRaw<M> where data is guaranteed non-null. Use this type after filtering out messages with data === null:
Methods
parseDay<M>(messages, format)
Processes each ScraperMessage against the provided format and returns an array of annotated messages.
Raw messages returned by
ScraperService.scrapeDay.Declarative field extraction definition. Each key maps to a
RegExp (simple string capture) or full ExtractConfig<T> (with transform, validate, multi, optional).Promise<ParserMessageRaw<M>[]> — one entry per input message; data is null if any non-optional field fails to match or validate.
CryptoYodaScreenService
CryptoYodaScreenService orchestrates scraping and parsing for the crypto_yoda_channel Telegram channel. It combines ScraperService and ParserService with a hard-coded signal format to produce typed trading signals.
Accessed via: core.cryptoYodaScreenService or inject<CryptoYodaScreenService>(TYPES.cryptoYodaScreenService)
Signal format
TheSIGNAL_FORMAT definition extracted from the source drives the parser:
| Field | Type | Source pattern |
|---|---|---|
symbol | string | #BTCUSDT → "BTC" |
direction | "short" | "long" | ШОРТ → "short", ЛОНГ → "long" |
entry | { from: number; to: number } | Price range after "в зоне" |
targets | number[] | All "Закрыть по" prices (multi) |
stoploss | number | Price after "СТОП-ЛОСС:" |
Methods
screenDay(date)
Scrapes the crypto_yoda_channel for the given date and immediately parses the results using SIGNAL_FORMAT.
UTC date to screen. Passed directly to
ScraperService.scrapeDay.Promise<ParserMessageRaw<typeof SIGNAL_FORMAT>[]> — all messages with parsed signal data (or data: null for non-signal messages).
parseDay(scraperList)
Parses a pre-fetched list of messages without re-scraping. Useful when you already have messages from a previous scrape and want to re-parse with the same format.
Raw messages to parse.
Promise<ParserMessageRaw<typeof SIGNAL_FORMAT>[]>
Usage example
CandleDbService
CandleDbService extends BaseCRUD(CandleModel) and adds candle-specific query helpers. All base CRUD methods (update, findById, findAll, iterate, paginate) are inherited unchanged. The create method is overridden with an atomic upsert to guarantee idempotency.
Accessed via: core.candleDbService or inject<CandleDbService>(TYPES.candleDbService)
Data types
{ symbol: 1, interval: 1, timestamp: 1 } is unique: true, preventing duplicate candles at the schema level.
Methods
create(dto)
Atomically inserts a candle or returns the existing one. Uses findOneAndUpdate with $setOnInsert so calling create twice with identical (symbol, interval, timestamp) is always safe.
Candle data to insert.
exchangeName is set internally to "ccxt_binance" and cannot be overridden via dto.Promise<ICandleRow> — the newly created or already-existing candle document.
hasCandle(symbol, interval, timestamp)
Convenience method that returns true when a candle for the given coordinates exists in the database.
Trading pair symbol, e.g.
"BTCUSDT".Candle interval string. One of
"1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "1d".Unix epoch milliseconds for the candle open time.
Promise<boolean>
findBySymbolIntervalTimestamp(symbol, interval, timestamp)
Looks up a single candle by its three primary coordinates plus the internal exchangeName.
Trading pair symbol.
Candle interval string.
Unix epoch milliseconds for the candle open time.
Promise<ICandleRow | null> — the matching candle, or null if not found.