CppBacktester

Installation Guide

Prerequisites

Before installing CppBacktester, ensure you have the following prerequisites:

Build Options

CppBacktester supports two main build targets:

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
Note: You can also build in Debug mode by replacing 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:

  1. Check for CMake installation
  2. Clean and create the build directory
  3. Run CMake configuration
  4. 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:

Note: It's recommended to use a virtual environment to avoid conflicts with other Python packages.

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:

Build Errors

If you encounter build errors, check the following: