The parser uses a typed field mapping schema to extract structured data from freeform text. Each field in aDocumentation 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.
ParseFormat<M> object maps to either a bare RegExp (extract the first capture group as a string) or a full ExtractConfig<T> object that adds capture group selection, type transformation, validation, optional marking, and multi-match support. ParserService.parseDay() applies the format to every message in a ScraperMessage[] array and returns a ParserMessageRaw<M>[] where data is either the fully-typed extracted object or null.
ExtractConfig<T>
ExtractConfig<T> is the per-field configuration object. T is the TypeScript type of the extracted value for that field.
The regex applied to the message text. For single-match fields,
String.prototype.match() is used. For multi: true fields, String.prototype.matchAll() is used — the pattern must have the global flag (g).Capture group index to extract from the match array. Defaults to
1. Set to 0 to use the entire match.Optional transform applied to the raw capture group string. Receives the captured string as
raw and the full RegExpMatchArray as match (useful when you need multiple groups). The return value becomes the field’s typed value.Optional validation function. If it returns
false for any value (including any element of a multi array), the entire message returns data: null — it is treated as a non-matching message, not just a missing field.When
true, a missing pattern match returns undefined for this field rather than causing the whole message to return data: null. Useful for fields that are not always present in every message format.When
true, uses matchAll() to collect every occurrence of pattern in the message text. The field’s value becomes T[] instead of T. Requires the g (global) flag on pattern.ParseFormat<M>
ParseFormat<M> is the top-level field mapping type. It is a mapped type over M where each key maps to either a bare RegExp or an ExtractConfig typed to match M[K].
RegExp value is shorthand for { pattern: regexp } — it extracts capture group 1 as a string with no transform or validation.
ExtractedData<M>
ExtractedData<M> is the inferred output type when all fields in a FieldMapping are successfully extracted. It respects the multi flag by mapping multi: true fields to R[].
Worked Example: SIGNAL_FORMAT
CryptoYodaScreenService defines SIGNAL_FORMAT as a ParseFormat<SignalFields> that extracts five fields from Russian-language CryptoYoda trade signals. This is the canonical example of every ExtractConfig feature in use.
Field Breakdown
symbol — hashtag extraction
symbol — hashtag extraction
#BTC/USDT and captures the base asset (BTC). Group 1 extracts just the symbol name without the # prefix or /USDT suffix. Validation rejects empty strings.direction — Cyrillic keyword transform
direction — Cyrillic keyword transform
transform normalizes them to the English lowercase strings "short" / "long". No explicit group — defaults to group 1, which is the full keyword match.entry — multi-group transform to object
entry — multi-group transform to object
m[1] and m[2]) in the transform to build a { from, to } range object. The num() helper normalizes European decimal commas to dots before parseFloat. Validation rejects ranges where either bound is non-finite, non-positive, or from >= to.targets — multi: true with global flag
targets — multi: true with global flag
multi: true field. The pattern has the g flag — matchAll() collects every “Закрыть по цене $X” line in the message. Each match is individually transformed and validated. The result is number[]. If no matches are found and optional is not set, the message returns data: null.stoploss — simple numeric extraction
stoploss — simple numeric extraction
СТОП-ЛОСС: or СТОПЛОСС: followed by an optional $ and a number. The num() helper normalizes the captured string to a JavaScript number.Extraction Logic
The internalEXTRACT_DATA_FN in ParserService processes each field in order:
- Normalize the spec: bare
RegExpvalues are wrapped as{ pattern: regexp }. - For
multi: truefields: callmatchAll(pattern). If no matches and notoptional, returnnull. Applytransformandvalidateto each match. Store asT[]. - For single fields: call
match(pattern). If no match and notoptional, returnnull. Applytransformandvalidate. Store asT. - If any field’s
validatereturnsfalse, returnnullfor the entire message. - Return the accumulated result as
ExtractedData<M>.
If a field is not
optional and its pattern doesn’t match, the entire message returns data: null — not just that field. This is intentional: it filters out non-signal messages efficiently without requiring downstream null checks on individual fields.