GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Ape108/cppTradingBot: A C++ backtesting engine to model a Simple Moving Average (SMA) crossover strategy as a probabilistic experiment. Calculates E[X] and Var(X) of trade returns.

BranchesTags
Open more actions menu

Latest commit

 

History

10 Commits
10 Commits

Folders and files

NameName
Last commit message
Last commit date
data
data
 
 
include
include
 
 
src
src
 
 
.gitignore
.gitignore
 
 
BTC_USD_Downloader.py
BTC_USD_Downloader.py
 
 
CMakeLists.txt
CMakeLists.txt
 
 
NVDA_Downloader.py
NVDA_Downloader.py
 
 
README.md
README.md
 
 

Repository files navigation

C++ Probabilistic Trading Backtester

This repository is a small C++ backtester for exploring a Simple Moving Average (SMA) crossover trading strategy as a probabilistic experiment. It is intended for research and learning — not for live trading.

The engine simulates trades on historical candlestick data and reports per-trade statistics such as expected value, variance, and win probability.

Notes about the current codebase

  • The CMake target is trading_bot (see CMakeLists.txt).
  • By default src/main.cpp loads data/NVDA.csv (NVIDIA historical prices). You can replace the CSV in data/ or edit main.cpp to point to a different file (for example data/BTC-USD.csv).
  • Two Python downloader scripts are included to fetch sample CSVs:
    • NVDA_Downloader.py — downloads data/NVDA.csv using yfinance.
    • BTC_USD_Downloader.py — downloads data/BTC-USD.csv using yfinance.

Project layout

  • include/ — public headers (backtester.hpp, strategy.hpp, etc.)
  • src/ — implementation (main.cpp, backtester.cpp, strategy.cpp)
  • data/ — sample CSVs (committed or generated by the downloaders)
  • BTC_USD_Downloader.py, NVDA_Downloader.py — convenience scripts to fetch CSVs using Python

Prerequisites

  • A C++17-compatible compiler (Clang/GCC on macOS/Linux, MSVC on Windows)
  • CMake (>= 3.15)
  • Internet access for CMake's FetchContent (it downloads cpr and nlohmann_json during configure)
  • Optional (for dataset downloading): Python 3 with pandas and yfinance if you want to use the included downloader scripts

Install the Python deps if you plan to use the scripts:

python3 -m pip install --user pandas yfinance

Build (recommended)

Generate build files and build the executable using CMake:

cmake -S . -B build
cmake --build build

The resulting executable is build/trading_bot (or build\\trading_bot.exe on Windows).

Run

By default main.cpp is configured to load data/NVDA.csv. To run the backtester:

./build/trading_bot

If you want to run the bot on Bitcoin data, either:

  1. Use the provided downloader to create data/BTC-USD.csv and edit src/main.cpp to point to data/BTC-USD.csv, or
  2. Replace data/NVDA.csv with your CSV named NVDA.csv (same format), or
  3. Modify main.cpp to accept a command-line path and recompile (recommended if you plan to run different datasets often).

CSV format expected by the loader

  • Header line (ignored by the loader)
  • Each subsequent line: Timestamp,Open,High,Low,Close

Example downloader usage (creates CSVs under data/):

python3 NVDA_Downloader.py
python3 BTC_USD_Downloader.py

Dependencies managed by CMake

The CMakeLists.txt uses FetchContent to download and make available:

  • cpr — a C++ HTTP client library (used if you add network code)
  • nlohmann_json — JSON handling library

These are fetched automatically during the CMake configure step.

License

See the repository root for licensing information.

About

A C++ backtesting engine to model a Simple Moving Average (SMA) crossover strategy as a probabilistic experiment. Calculates E[X] and Var(X) of trade returns.

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.