Skip to content

A C++ backtesting framework for evaluating trading strategies on historical market data.

Notifications You must be signed in to change notification settings

Oll-iver/CPP-Backtest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CPP-backtest

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.

Installation

  1. Clone the repository
    git clone https://github.com/Oll-iver/CPP-Backtest.git
    cd CPP-Backtest```
  2. Install dependencies Make sure you have g++ (or any C++ compiler) and cmake installed. You may also need libgtest
  3. Build the project Create a build directory and compile with CMake:
    mkdir build
    cd build
    cmake ,.
    make```  
  4. 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
  5. Run the program
./CPP-Backtest

Usage

This framework includes several strategies and you can add your own using the base SimpleStrategy class.

  1. 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.
  2. 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.
  3. 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.

Testing

  1. Compile the tests
cd build
make
  1. Run tests
./AllTests.cpp

Contributing

Contributions such as fixes or other strategies are welcome

  1. Fork the repository
  2. Create a new branch
git checkout -b name
  1. Commit changes
git commit -m "Message"
  1. Push to your fork and submit a pull request.
git push origin name
  1. Submit a pull request to main repository.

About

A C++ backtesting framework for evaluating trading strategies on historical market data.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published