Prerequisites
Before installing CppBacktester, ensure you have the following prerequisites:
- CMake (version 3.12 or higher)
- C++ compiler with C++17 support
- Python 3.x with development headers (if building the Python module)
- NumPy (if building the Python module)
- vcpkg (for managing dependencies)
Build Options
CppBacktester supports two main build targets:
- C++ executable (
BUILD_EXECUTABLE=ON) - Python module (
BUILD_PYTHON_MODULE=ON)
Both targets are enabled by default. You can disable either target by setting the corresponding option to OFF during CMake configuration.
Building with CMake
Follow these steps to build CppBacktester using CMake:
Step 1: Clone the Repository
git clone https://github.com/your-username/CppBacktester.git
cd CppBacktester
Step 2: Create and Enter Build Directory
mkdir build
cd build
Step 3: Configure with CMake
cmake .. -G "Visual Studio 17 2022" -A x64
To customize the build, you can pass additional options:
cmake .. -G "Visual Studio 17 2022" -A x64 -DBUILD_EXECUTABLE=ON -DBUILD_PYTHON_MODULE=ON
Step 4: Build the Project
cmake --build . --config Release
Release with Debug.
Using the Helper Script
For convenience, you can use the provided batch script to clean and rebuild the project:
# On Windows
build.bat
This script will:
- Check for CMake installation
- Clean and create the build directory
- Run CMake configuration
- Build the project
Output Directory Structure
After building, the output files will be organized as follows:
build/
├── output/ # build output
│ ├── bin/
│ │ ├── backtest_executable.exe # C++ executable
│ │ └── .dlls # DLLs for the executable
│ └── lib/
│ ├── cppbacktester_py.cp312-win_amd64.pyd # Python extension module
│ └──
└── ... # Other build files
Python Dependencies
CppBacktester requires several Python packages when using the Python module or running the auxiliary scripts. You can install all required dependencies using pip:
Step 1: Navigate to the Project Directory
cd path/to/CppBacktester
Step 2: Install Requirements
pip install -r requirements.txt
This will install all the necessary Python packages listed in the requirements.txt file, including:
- NumPy - For numerical computations
- Pandas - For data manipulation
- Additional packages required by the HMM and ML strategies
Troubleshooting
CMake Not Found
If you encounter a "CMake not found" error, ensure that CMake is installed and added to your system PATH.
Python Development Headers Not Found
If CMake cannot find Python development headers, make sure you have installed the Python development package:
- On Windows: Install Python with the "Install development headers" option
- On Linux: Install the python3-dev package
- On macOS: Install Python via Homebrew which includes development headers
Build Errors
If you encounter build errors, check the following:
- Ensure your compiler supports C++17
- Check that all dependencies are properly installed
- Verify that the build configuration matches your system architecture