Skip to main content

Documentation Index

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

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

Backtest Kit offers four ways to get a project running, each suited to a different stage of development. Pick the one that matches your situation: the CLI init for a clean start with minimal files to maintain, Sidekick for full visibility into every piece of wiring, Docker for zero-downtime production deployment, or manual installation when you are integrating into an existing codebase.

Prerequisites

Before installing, make sure your environment meets these requirements:
  • Node.js 18+ — the engine relies on AsyncLocalStorage from the Node.js async_hooks module, which requires Node 18 or later.
  • TypeScript 5.0+ — required for the strict generic types used across signal schemas, risk validators, and broker adapters.

Installation Methods

The CLI Init method is the fastest way to start a new project. All bootstrap wiring — storage registration, notification setup, candle cache warming, graceful shutdown, and the runner harness — lives inside the @backtest-kit/cli package itself. Your project only contains strategy files.
npx @backtest-kit/cli --init --output backtest-kit-project
cd backtest-kit-project
npm install
npm start
You can override the output directory name with any value:
npx @backtest-kit/cli --init --output my-trading-bot
The generated structure looks like this:
backtest-kit-project/
├── package.json              # pre-configured with all backtest-kit dependencies
├── .gitignore
├── CLAUDE.md                 # AI-agent guide for writing strategies
├── content/
│   └── feb_2026.strategy.ts  # example strategy entry point
├── docs/
│   └── lib/                  # fetched automatically on init
├── math/
│   └── feb_2026.pine         # example PineScript indicator
├── modules/
│   ├── dump.module.ts
│   └── pine.module.ts
└── scripts/
    └── fetch_docs.mjs
After scaffolding, the CLI automatically fetches the latest README files for all bundled libraries into docs/lib/. You can refresh them at any time with npm run sync:lib.Once the project is set up, run a backtest with:
npx @backtest-kit/cli --backtest ./content/feb_2026.strategy.ts --symbol BTCUSDT
The CLI init scaffold is intentionally minimal — it is designed to scale from a solo quant’s first strategy all the way to a monorepo of dozens of strategies without any rewriting. The same npx @backtest-kit/cli command that runs your first backtest is the same one that drives a production desk.

Supported Entry Point Formats

The CLI automatically detects the format of your strategy file and loads it with the appropriate runtime — no flags or configuration required.
All three file formats are supported out of the box. TypeScript files are executed directly via tsx with no compilation step. ES Modules use native import(). CommonJS modules use require().
FormatExtensionRuntimeUse Case
TypeScript.tstsx via tsImport()TypeScript strategies with cross-format imports (ESM ↔ CJS)
ES Module.mjsNative import()Modern JavaScript with top-level await and ESM syntax
CommonJS.cjsNative require()Legacy or dual-package strategies

Build docs developers (and LLMs) love