The backtest-kit library uses a small set of string enums to identify exchanges, backtesting frames, and strategies throughout the codebase. These values appear as components of composite Redis cache keys, Mongoose document filter fields, and adapter configuration objects. Alongside the enums, the library ships a set of genericDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit-redis-mongo-docker/llms.txt
Use this file to discover all available pages before exploring further.
ParseFormat utility types that enable structured, type-safe extraction of fields from free-form text — useful when parsing LLM outputs or loosely-structured API responses.
Enums
Three string enums —
ExchangeName, FrameName, and StrategyName — provide compile-time safety for the string identifiers threaded through every service call.ParseFormat types
A family of four generic utility types —
ExtractConfig, FieldMapping, ExtractedData, and ParseFormat — for declarative regex-based field extraction with optional transforms and validation.Enums
ExchangeName
ExchangeName identifies the exchange adapter used by the backtesting engine. The string value is embedded directly in Redis cache keys and Mongoose filter documents as the exchangeName field.
| Member | String value | Usage |
|---|---|---|
ExchangeName.CCXT | "ccxt-exchange" | The CCXT-based exchange adapter. Appears in cache keys such as signal_cache:ccxt-exchange:jan_2026_strategy:TRXUSDT. |
FrameName
FrameName identifies a backtesting time frame — a named window of historical data with defined start and end boundaries. Frame names appear in configuration objects that select which dataset a strategy runs against.
| Member | String value | Usage |
|---|---|---|
FrameName.Jan2026Frame | "jan_2026_frame" | The January 2026 backtesting dataset. |
StrategyName
StrategyName identifies a trading strategy implementation. The string value is used as the strategyName component of composite cache keys and Mongoose filter queries.
| Member | String value | Usage |
|---|---|---|
StrategyName.Jan2026Strategy | "jan_2026_strategy" | The January 2026 strategy. Appears in cache keys such as signal_cache:ccxt-exchange:jan_2026_strategy:TRXUSDT. |
Enum string values are written into MongoDB documents and Redis keys. Changing an existing enum value after data has been stored will orphan existing records — the old keys will no longer be found by
findByContext or the cache lookup. Always treat enum string values as immutable once data is in production.ParseFormat types
TheParseFormat family of types in src/model/ParseFormat.model.ts provides a declarative, type-safe API for extracting structured fields from free-form strings using regular expressions. It is particularly useful when processing LLM completions or API text responses that follow a semi-structured pattern but cannot be reliably parsed with a JSON schema.
ExtractConfig<T>
ExtractConfig is the per-field extraction descriptor. It tells the parser how to find, transform, and validate a single field’s value within a larger string.
The regular expression applied to the input string to locate this field’s value. This is the only required property.
The capture group index within
pattern whose text is used as the raw value. Defaults to group 1 if omitted. Use 0 to capture the entire match.An optional function that converts the raw captured string into the desired type
T. Receives both the raw captured string and the full RegExpMatchArray so you can reference other groups during transformation.An optional predicate run after
transform. If it returns false, the field is treated as unmatched. Use this to reject captures that match the pattern but fail a semantic check (e.g., a number that is out of range).When
true, the parser collects all matches of pattern in the input string rather than stopping at the first match. The extracted field type becomes T[] instead of T. Reflected in ExtractedData via the conditional M[K] extends { multi: true } ? R[] : R.When
true, a failure to match pattern is not treated as a parse error — the field is simply absent or undefined in the result. When false (the default), a missing match raises an error.FieldMapping
FieldMapping is a plain record type where each key is a field name and each value is either a bare RegExp (shorthand for ExtractConfig with just a pattern) or a full ExtractConfig object.
RegExp value is equivalent to { pattern: theRegex } — it extracts the first capture group as a string with no transform, validation, or multi-match.
ExtractedData<M>
ExtractedData is a mapped type that derives the shape of the parsed result object from a FieldMapping. The conditional types preserve the correct output type for each field:
- A field with a bare
RegExpproducesstring. - A field with
ExtractConfig<R>producesR. - A field with
ExtractConfig<R> & { multi: true }producesR[].
ParseFormat<T>
ParseFormat<T> is the inverse of ExtractedData — given a known output type T, it produces the type of the mapping object needed to parse it. This is useful when you want to define a parser that is statically typed to produce a known interface T.
T[K] extends (infer U)[] ? U : T[K] unwraps array fields so that ExtractConfig is typed for the element type rather than the array type — the multi: true flag on the config is what produces the array in the output.
When to use ParseFormat
A minimal example:ExtractedData<typeof format> type resolves to { symbol: string; price: number; tags: string[] }, matching TradeSignal exactly.