Skip to main content

Documentation Index

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

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

backtest-monorepo-parallel is a production-ready TypeScript monorepo template built on top of backtest-kit. It runs 9 crypto symbols concurrently in a single Node.js process, reaching ~6,300× real-time aggregate replay speed on commodity developer hardware — no server required.

Quick Start

Spin up MongoDB, Redis, build the packages, and run your first parallel backtest in minutes.

Architecture

Understand the DI runtime, package layout, and how strategy files access services without imports.

Writing Strategies

Learn the anatomy of a strategy file, exchange schema, frame schema, and event hooks.

API Reference

Explore BaseCRUD, BaseMap, the IoC container, CLI flags, and all data models.

Why backtest-monorepo-parallel?

Traditional backtesting frameworks spin up one process per symbol or rely on Python multiprocessing. This template takes a different approach: all 9 Backtest.background() calls share one event loop, one MongoDB connection pool, and one Redis pool. The result is near-zero IPC overhead and a hot loop that processes ~103 events/second on a mid-range laptop.

6 300× Speed

Aggregate replay across 9 symbols — 34 min of history replayed in ~2.9 s of wall time.

Zero-Import DI

Strategy files call core.candleDbService without a single import — globalThis.core is wired at startup.

Atomic Writes

Every persist call is a single findOneAndUpdate upsert — no read-modify-write, no retry loops.

Key Concepts

1

Infrastructure

Launch MongoDB and Redis via the bundled docker-compose files. The template connects to both on localhost by default.
2

Build

Run npm run build to compile every workspace package with Rollup. Each package emits a CJS bundle and a rolled-up .d.ts file consumed by the root tsconfig.json.
3

Write a Strategy

Drop a .strategy.ts file under ./content/<name>.strategy/. Call addStrategySchema, addExchangeSchema, and addFrameSchema to register your logic with the runner.
4

Run

Execute npm run start -- --backtest --entry --cache ./content/<name>.strategy/<name>.strategy.ts to kick off a parallel 9-symbol backtest with candle pre-warming.

Measured Performance

MetricValue
Wall-clock span (297 events, 9 symbols)~2.9 s
Historical time replayed per symbol34 minutes
Per-symbol replay speed≈ 703× real-time
Aggregate replay speed (9 symbols)≈ 6 326× real-time
Event throughput≈ 103 events/sec
Test benchHP Victus 15, i5-13420H, 16 GB DDR4-3200
Performance numbers were captured with a hot Mongo + Redis cache on a single developer laptop. First-run candle fetches add network latency — use the --cache flag to pre-warm before benchmarking.

Build docs developers (and LLMs) love