CryptoQuantEngine is a high-performance C++ framework for backtesting high-frequency trading (HFT) strategies on Level 2 crypto market data.
-
Full Depth-of-Book Simulation
Accurately reconstructs and simulates the entire order book from Level 2 market data, supporting market-by-price feeds. -
Realistic Latency Modeling
Simulates order entry, order response, and market data feed latencies for robust evaluation of latency-sensitive strategies. -
Queue Position Tracking
Estimates queue position for passive orders, enabling realistic fill probability and execution modeling. -
Flexible Order Matching Engine
Provides configurable and extensible order matching logic for both market-making and liquidity-taking strategies. -
Modular Strategy Framework
Easily implement custom strategies by inheriting from the abstract strategy class and accessing market/order management APIs. -
Comprehensive Performance Analytics
Reports key metrics such as Sharpe ratio, Sortino ratio, max drawdown, and detailed trading statistics after each backtest run. -
Automated Visualization
Generates CSV outputs and Python-based plots for equity curves and position tracking. -
Robust Unit Testing
Includes a suite of unit tests to ensure reliability and correctness of core components.
- C++20-compatible compiler
- CMake version 3.12 or later
- Python 3.7+ (for plotting)
- Python packages:
matplotlib,pandas
Clone the repository
git clone https://github.com/caped-doshi/cryptoquantlab.gitCreate and enter build directory
mkdir build && cd buildConfigure the project with CMake
cmake -DCMAKE_BUILD_TYPE=Release ..Compile the engine
cmake --build .Run unit tests
ctest --output-on-failureRun the backtest engine
./backtestThis will:
- Load configuration files
- Run the backtest engine for the specified number of iterations
- Print final equity, performance metrics, and trading statistics
- Generate plots of equity and position (requires Python)
See Usage Guide for more details.
A sample grid trading strategy is included.
See Examples for implementation, configuration, and usage.
To implement your own strategy:
- Inherit from the abstract
Strategyclass - Implement
initialize()andon_elapse() - Use the
BacktestEnginefor market data and order management
See Strategies Guide for instructions.
After each run, the engine reports:
- Sharpe Ratio — risk-adjusted return
- Sortino Ratio — downside risk-adjusted return
- Max Drawdown — largest peak-to-trough loss
- Trading statistics — number of trades, volume, value
Plots are generated as CSV and visualized using Python.
MIT License. See LICENSE for details.