backtest-kit-redis-mongo-docker upgrades the default file-basedDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit-redis-mongo-docker/llms.txt
Use this file to discover all available pages before exploring further.
./dump/ storage in backtest-kit to a production-grade dual-store: MongoDB as the source of truth and Redis as an O(1) ID lookup cache. All 15 IPersist* adapter contracts are implemented, so your strategy code, runners, and CLI entrypoint stay completely unchanged — only the persistence layer is swapped.
Quickstart
Run a backtest or live strategy in minutes with the local dev setup.
Deployment
One-command full Docker deployment with MongoDB, Redis, and the runner container.
Architecture
Understand the dual-store persistence model and how the 15 adapters fit together.
Persist Adapters
Full reference for all 15 MongoDB-backed IPersist* adapter implementations.
What this project does
backtest-kit ships a pluggable persistence interface. By default it writes state to JSON files in./dump/. This repository replaces every adapter with a dual-store implementation:
- MongoDB stores every record durably.
findOneAndUpdatewithupsert: trueguarantees read-after-write consistency. - Redis caches compound context keys → MongoDB document IDs. Reads hit Redis first (O(1)); misses fall through to Mongo and backfill the cache automatically.
- Look-ahead bias protection — every write adapter accepts a
when: Dateargument, preventing future data from influencing historical backtest results.
15 Adapters
All IPersist* interfaces implemented over MongoDB + Redis
O(1) Reads
Redis ID cache eliminates repeated compound-key Mongo queries
One Command
docker-compose up deploys the full stack instantly
Run modes
The project supports three distinct run modes, each gated by a CLI flag:Backtest mode
Replays historical candle data from MongoDB. Candles are warmed from the exchange and stored once, then read repeatedly with zero latency.
Paper mode
Runs the live strategy against real market data without executing orders — ideal for forward-testing before going live.
Key sections
Environment Variables
Configure MongoDB connection strings, Redis host and credentials, and Docker env vars.
Writing a Strategy
Add frames, strategies, and signal logic backed by the MongoDB persistence layer.
Service Layer
MongooseService, RedisService, and the IoC container that wires all 33 services.
Atomicity & Guarantees
How read-after-write consistency and look-ahead bias protection are enforced.