Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/backtest-kit/backtest-kit-redis-mongo-docker/llms.txt

Use this file to discover all available pages before exploring further.

A frame is the simulation time window for a backtest. It tells backtest-kit which slice of historical market data to replay, at what candle resolution, and how to label the run. Every strategy run must reference exactly one frame; the frame is identified by a string name that links the addFrameSchema registration to the Backtest.background call in the entry point.

Frame definition

src/logic/frame/jan_2026.frame.ts registers the January 2026 frame:
import { addFrameSchema } from "backtest-kit";
import { FrameName } from "../../enum/FrameName";

addFrameSchema({
  frameName: FrameName.Jan2026Frame,
  interval: "1m",
  startDate: new Date("2026-01-01T00:00:00Z"),
  endDate: new Date("2026-01-31T23:59:59Z"),
  note: "January 2026",
});

addFrameSchema parameters

ParameterTypeDescription
frameNamestringUnique identifier for this frame. Must match the enum value ("jan_2026_frame").
intervalCandleIntervalCandle interval used during the simulation ("1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "1d").
startDateDateUTC Date marking the beginning of the simulation window.
endDateDateUTC Date marking the end of the simulation window (inclusive).
notestringHuman-readable label shown in reports and logs.

FrameName enum

export enum FrameName {
  Jan2026Frame = "jan_2026_frame",
}
Add a new member here whenever you introduce a new frame file. The string value must match the frameName passed to addFrameSchema.

Referencing a frame in the entry point

The frame name, exchange name, and strategy name are passed together when launching a backtest in src/main/backtest.ts:
Backtest.background("TRXUSDT", {
  exchangeName: ExchangeName.CCXT,
  frameName: FrameName.Jan2026Frame,
  strategyName: StrategyName.Jan2026Strategy,
});
backtest-kit resolves the registered frame schema by its name and uses startDate, endDate, and interval to drive the simulation loop.

Supported candle intervals

The interval value controls how many minutes each candle represents. The full mapping, as defined in the persistence layer, is:
const INTERVAL_MINUTES: Record<CandleInterval, number> = {
  "1m": 1,
  "3m": 3,
  "5m": 5,
  "15m": 15,
  "30m": 30,
  "1h": 60,
  "2h": 120,
  "4h": 240,
  "6h": 360,
  "8h": 480,
  "1d": 1440,
};
Choose an interval that matches the resolution of the signals in assets/entry.jsonl. The default frame uses "1m" because alignToInterval aligns publishedAt timestamps to 1-minute boundaries when matching signals to candle ticks.
Always call warmCandles before Backtest.background to pre-populate MongoDB with the full OHLCV dataset for the frame period. Without pre-warmed candles, the simulation will attempt to fetch data on every tick and will either be slow or fail if the exchange rate-limits the connection.
await warmCandles({
  exchangeName: ExchangeName.CCXT,
  from: new Date("2026-01-01T00:00:00Z"),
  to: new Date("2026-01-31T23:59:59Z"),
  interval: "1m",
  symbol: "TRXUSDT",
});

Backtest.background("TRXUSDT", {
  exchangeName: ExchangeName.CCXT,
  frameName: FrameName.Jan2026Frame,
  strategyName: StrategyName.Jan2026Strategy,
});

Build docs developers (and LLMs) love