This repository contains a backtesting framework built in C++ for evaluating and testing trading strategies. It currently includes implementations for the Mean Reversion and Moving Average Crossover strategies and allows for easy setup of additional strategies.
- Clone the repository
git clone https://github.com/Oll-iver/CPP-Backtest.git cd CPP-Backtest```
- Install dependencies Make sure you have g++ (or any C++ compiler) and cmake installed. You may also need libgtest
- Build the project
Create a build directory and compile with CMake:
mkdir build cd build cmake ,. make```
- Install Google Test (optional, for testing)
If Google Test is not already anstalled you can install it with any package manager eg sudo apt install libgtest-dev - Run the program
./CPP-BacktestThis framework includes several strategies and you can add your own using the base SimpleStrategy class.
- Mean Reversion Strategy This strategy assumes that prices will revert to a mean over time. When the price is significantly below it buys, when the price is above it sells.
- Moving Average Crossover Strategy This strategy uses short and long moving averages to generate buy and sell signals. A buy signal occurs when the short moving average crosses above the long moving average, and a sell signal occurs when it crosses below.
- Other strategies Using the SimpleStrategy class as a base you can create additional strategies easily. Implement your strategy by inheriting from SimpleStrategy and defining initialize and execute methods.
- Compile the tests
cd build
make- Run tests
./AllTests.cppContributions such as fixes or other strategies are welcome
- Fork the repository
- Create a new branch
git checkout -b name- Commit changes
git commit -m "Message"- Push to your fork and submit a pull request.
git push origin name- Submit a pull request to main repository.