A frame defines the backtest time window — the start date, end date, and candle interval that backtest-kit uses to drive the historical replay. An exchange schema wires in the market data source, providing OHLCV candles, order book snapshots, and price/quantity formatting functions. This project ships a single ccxt Binance exchange schema used identically across backtest, live, and paper modes.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit-minio-s3-docker/llms.txt
Use this file to discover all available pages before exploring further.
addFrameSchema
Frame schemas are registered at module load time withaddFrameSchema. The jan_2026.frame.ts file defines a one-month backtest window at 1-minute resolution:
| Field | Type | Description |
|---|---|---|
frameName | string | Unique identifier for this frame, sourced from the FrameName enum |
interval | CandleInterval | Candle interval — "1m" through "1d". Drives the tick frequency during backtest replay |
startDate | Date | Inclusive start of the backtest window (UTC) |
endDate | Date | Inclusive end of the backtest window (UTC) |
note | string | Human-readable label shown in the UI |
FrameName enum maps enum members to the string identifiers that backtest-kit uses internally:
"jan_2026_frame" must match the frameName passed to Backtest.background() in the entry point. A mismatch causes backtest-kit to report an unknown frame error at startup.
addExchangeSchema
Exchange schemas are registered inmodules/backtest.module.ts, modules/live.module.ts, and modules/paper.module.ts — all three files contain an identical registration, since the same Binance ccxt adapter is used in every mode. The schema is registered with addExchangeSchema and identified by exchangeName:
Lazy exchange initialisation with singleshot
ThegetExchange factory is wrapped with singleshot from functools-kit. This ensures that new ccxt.binance(...) and exchange.loadMarkets() are called exactly once across the lifetime of the process, regardless of how many times getCandles, getOrderBook, formatPrice, or formatQuantity are invoked concurrently. Subsequent calls receive the already-initialised exchange instance from a cached Promise.
getCandles
Fetches OHLCV data from Binance and maps the raw tuple array to backtest-kit’sCandleData shape:
since is passed as a Date by backtest-kit and converted to milliseconds via .getTime() to match the ccxt fetchOHLCV API. The returned array must be in ascending timestamp order.
getOrderBook
Fetches a live order book from Binance. The function accepts abacktest boolean flag — when true (historical replay), it throws immediately because there is no meaningful order book data to return for a past timestamp:
formatPrice
Rounds a raw price to the market’s tick size usingroundTicks from backtest-kit. Falls back to ccxt’s priceToPrecision if no tick size is available:
formatQuantity
Rounds a raw quantity to the market’s step size usingroundTicks. Falls back to amountToPrecision if no step size is available:
ExchangeName enum
TheexchangeName string passed to addExchangeSchema must match the value used in Backtest.background(), Live.background(), and warmCandles(). The ExchangeName enum is the single source of truth:
setConfig
setConfig from backtest-kit is called before addExchangeSchema to override framework defaults:
CC_MAX_STOPLOSS_DISTANCE_PERCENT: 100 raises the maximum allowed stop-loss distance to 100% of the entry price. The default value is much lower and would reject wide stops. Since the January 2026 signals use HARD_STOP = 1.0 (percent), this setting is not strictly required for normal operation, but it prevents backtest-kit from silently clamping or rejecting stop levels on volatile assets.
The ccxt Binance adapter is initialised with two important options for live and paper modes:
adjustForTimeDifference: true automatically corrects for clock skew between your server and Binance, and recvWindow: 60000 extends the request validity window to 60 seconds. Both options reduce the frequency of Timestamp for this request is outside of the recvWindow errors in production.