backtest-kit Redis+MongoDB Docker replaces the default file-basedDocumentation 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.
./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:| Mode | CLI flag | MODE env | Description |
|---|---|---|---|
| Backtest | --backtest | backtest | Replays historical OHLCV data through your strategy |
| Paper | --paper | paper | Simulates live trading with real market data, no orders |
| Live | --live | live | Connects to a real exchange and submits orders |
Build and run
Run
npm run start -- --entry --backtest --ui ./build/index.cjs or use the full docker-compose stack.