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.

backtest-kit Redis+MongoDB Docker replaces the default file-based ./dump/ persistence layer of backtest-kit with MongoDB for durable storage and Redis for sub-millisecond context-key lookups. Fifteen custom IPersist* adapters implement the full backtest-kit persistence contract — strategy code, runners, and the CLI entrypoint stay completely unchanged.

Quickstart

Spin up MongoDB, Redis, and run your first backtest in under five minutes.

Architecture

Understand the two-layer persistence model, atomicity guarantees, and the Redis cache strategy.

Deployment

One-command docker-compose deploys for local development and production.

Persist Adapters

Reference for all 15 MongoDB+Redis persist adapters and their collection schemas.

Why MongoDB + Redis?

The default backtest-kit persistence writes plain files under ./dump/. This works well for single-machine runs but breaks down in production: no concurrent access safety, no horizontal scale, and O(n) reads for large datasets. This integration solves each issue:

Atomic Upserts

Every write uses findOneAndUpdate with upsert: true on a compound unique index — eliminating E11000 duplicate key races entirely.

O(1) Reads

Redis stores context-key → MongoDB _id mappings. Steady-state reads cost one Redis GET plus one MongoDB findById — both O(1).

Look-Ahead Safe

Signal-affecting adapters store a when: Date column so backtest-kit’s look-ahead bias filter can verify temporal correctness.

Running Modes

The project supports three execution modes switchable via CLI flags or container environment variables:
ModeCLI flagMODE envDescription
Backtest--backtestbacktestReplays historical OHLCV data through your strategy
Paper--paperpaperSimulates live trading with real market data, no orders
Live--liveliveConnects to a real exchange and submits orders
1

Start infrastructure

Launch MongoDB and Redis containers with docker-compose.
2

Configure environment

Copy .env.example to .env and set your connection strings.
3

Build and run

Run npm run start -- --entry --backtest --ui ./build/index.cjs or use the full docker-compose stack.
4

View results

Open the backtest-kit web UI at http://localhost:60050 to inspect signals, logs, and performance metrics.

Build docs developers (and LLMs) love