Skip to main content

Documentation Index

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

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

Backtest Kit is a production-grade TypeScript framework for building, testing, and deploying trading strategies across crypto, forex, and decentralized exchanges. Write your strategy once — the same code runs in both historical backtest and live real-time modes, with automatic crash recovery, signal validation, and a streaming execution engine designed for large datasets.

Quickstart

Get from zero to a running backtest in under five minutes

Core Concepts

Understand schemas, signals, the execution engine, and modes

API Reference

Full reference for Backtest, Live, Cron, Broker, and all functions

Ecosystem

CLI runner, UI dashboard, MongoDB persistence, Pine Script support, and more

Why Backtest Kit?

Backtest Kit treats your strategy as a time execution engine — not a data processing script. The framework streams through historical candles or real-time ticks using the same async generator pipeline, so the exact same strategy code works in both modes without any modification.

Crash-Safe

Atomic persistence recovers live bots from crashes with no duplicate trades or lost positions

Signal Validation

Built-in checks for TP/SL direction, R/R ratio, whipsaw protection, and portfolio limits

AI-Ready

LLM strategy generation via Ollama, OpenAI, Claude, DeepSeek, and 10+ providers

Realistic PNL

VWAP-based pricing with configurable slippage and fee calculations

Multi-Symbol

Run parallel backtests across many symbols with coordinated Cron scheduling

Full Reports

Auto-generated Markdown reports with Sharpe, Sortino, Calmar, win rate, and drawdown

Get Started in Minutes

1

Install the package

The fastest path is the CLI scaffold — zero boilerplate in your project files:
npx @backtest-kit/cli --init --output my-strategy
cd my-strategy && npm install && npm start
Or install the core library directly for full control:
npm install backtest-kit ccxt
2

Register your schemas

Define your exchange, time frame, risk rules, and strategy:
import { addExchangeSchema, addFrameSchema, addRiskSchema, addStrategySchema } from 'backtest-kit';

addExchangeSchema({ exchangeName: 'binance', getCandles: async (...) => [...] });
addFrameSchema({ frameName: '1d-test', interval: '1m', startDate: new Date('2025-01-01'), endDate: new Date('2025-01-02') });
addRiskSchema({ riskName: 'default', validations: [] });
addStrategySchema({ strategyName: 'my-strategy', interval: '5m', riskName: 'default', getSignal: async (symbol) => null });
3

Run your backtest

Use the event-driven API or pull results with an async iterator:
import { Backtest, listenDoneBacktest } from 'backtest-kit';

Backtest.background('BTCUSDT', { strategyName: 'my-strategy', exchangeName: 'binance', frameName: '1d-test' });

listenDoneBacktest(async (event) => {
  await Backtest.dump(event.symbol, event.strategyName);
});
4

Switch to live trading

Replace Backtest with Live — no other changes needed:
import { Live } from 'backtest-kit';

Live.background('BTCUSDT', { strategyName: 'my-strategy', exchangeName: 'binance' });

Explore the Documentation

Schema Registration

Learn how to register exchange adapters, strategies, frames, and risk profiles

Signal Lifecycle

Understand how signals move through idle → opened → active → closed states

Broker Adapter

Connect to a real exchange with transactional safety and automatic retry

Cron Scheduler

Schedule jobs in virtual time across parallel backtests without double-firing

Ecosystem Packages

CLI runner, UI dashboard, MongoDB/Redis persistence, Pine Script, and AI inference

Strategy Examples

Real strategy implementations: neural networks, Pine Script, LLM sentiment, DCA ladders

Build docs developers (and LLMs) love