Active development!
Feel free to explore, but this code base is usable at the moment.
I'm developing a high-performance C++ backtesting engine designed to analyze financial data and evaluate multiple trading strategies at scale — and to take the winners live.
The engine is C++23 (modules, import std;) and one binary with eight subcommands:
ingest— receives a UDP tick stream and writes it to QuestDBload— expands a strategy parameter sweep and queues it in Redisrun— drains the queue, backtests against QuestDB ticks, reports results to Elasticsearchexperiments— expands a parameter sweep of occurrence-rate questions ("price drops 1% in 10m, then recovers 0.5% in 10m — how often?") and queues it in Redis, no strategy requiredanalysis— drains the experiment queue, counts pattern occurrences against QuestDB ticks, reports aggregate stats (rates, conditional completion, excursion quantiles) to Elasticsearchlive— takes the winning backtests from Elasticsearch and trades them live via the IG REST APItracking— receives the IG account's deal/position updates over UDP, logs each one, archives closed deals in the Redis position book (PO#→PH#, pruning thePL#list), and ships alive-tradesdocument to Elasticsearch per dealpositions— mirrors the IG account's open positions into Redis every minute (the position book, strategy lists, and cluster-exposure sets the live engine reads)
I'm extracting results and creating various graphs for trend analyses using SciPy for calculations and Plotly for visualization.
Read more results on https://mccaffers.com/quantitative_analysis/randomly_trading/
| Document | Contents |
|---|---|
| QUICKSTART.md | Building the engine and using each subcommand |
| ARCHITECTURE.md | How it fits together — data flow, queue design, live order path (Mermaid diagrams) |
| ENVIRONMENT.md | Every environment variable, per command, with defaults |
| REQUIREMENTS.md | Toolchain, system libraries, vendored dependencies, runtime services |
git clone --recurse-submodules https://github.com/mccaffers/backtesting-engine-cpp
cd backtesting-engine-cpp
bash ./scripts/build.sh # CMake + Ninja + Clang/libc++ (see REQUIREMENTS.md for the toolchain)
bash ./scripts/test.sh # Catch2 tests via ctest
# with Redis, QuestDB, and Elasticsearch running (see QUICKSTART.md):
./build/BacktestingEngine load random # queue a sweep
./build/BacktestingEngine run localhost # drain and backtestThis is an active solo experiment, so I'm not accepting pull requests right now, but please fork freely and use GitHub Issues for bugs, questions, and ideas. See CONTRIBUTING.md for details.