mccaffers
backtesting-engine-cpp
C++

Prototype of a high-performance C++ backtesting engine designed to analyse financial data and evaluate multiple trading strategies at scale.

Last updated Aug 9, 2026
11
Stars
5
Forks
0
Issues
+11
Stars/day
Attention Score
54
Language breakdown
C++ 98.0%
Shell 1.1%
CMake 0.8%
โ–ธ Files click to expand
README

C++ Backtesting Engine

Active development!

Feel free to explore, but this code base is usable at the moment.

About The Project

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.

Build Bugs Code Smells Coverage

The engine is C++23 (modules, import std;) and one binary with eight subcommands:

  • ingest โ€” receives a UDP tick stream and writes it to QuestDB
  • load โ€” expands a strategy parameter sweep and queues it in Redis
  • run โ€” drains the queue, backtests against QuestDB ticks, reports results to Elasticsearch
  • experiments โ€” 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 required
  • analysis โ€” drains the experiment queue, counts pattern occurrences against QuestDB ticks, reports aggregate stats (rates, conditional completion, excursion quantiles) to Elasticsearch
  • live โ€” takes the winning backtests from Elasticsearch and trades them live via the IG REST API
  • tracking โ€” receives the IG account's deal/position updates over UDP, logs each one, archives closed deals in the Redis position book (PO# โ†’ PH#, pruning the PL# list), and ships a live-trades document to Elasticsearch per deal
  • positions โ€” 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.

alt text

Read more results on https://mccaffers.com/quantitativeanalysis/randomlytrading/

Documentation

| 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 |

Quick start

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 backtest

Contributing

This 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.

License

MIT

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท mccaffers/backtesting-engine-cpp ยท Updated daily from GitHub