A modular algorithmic trading backtesting system written in C++ that simulates trading strategies on historical price data and evaluates their performance using financial metrics.
This project demonstrates how quantitative trading strategies can be tested before deploying them in real markets.
FinTrade Engine reads historical market price data, applies a trading strategy, executes simulated trades, tracks portfolio performance, and produces analytics such as profit, win rate, drawdown, and equity curves.
The system replicates the typical research pipeline used in algorithmic trading and quantitative finance.
- Historical market data ingestion
- Moving Average Crossover trading strategy
- Simulated portfolio and trade execution
- Backtesting framework
- Strategy performance analytics
- Maximum drawdown calculation
- Equity curve tracking
- Export of performance data to CSV
- Equity curve visualization using Python
Historical Price Data
↓
Trading Strategy Evaluation
↓
Buy / Sell Signal Generation
↓
Trade Execution Simulation
↓
Portfolio Update
↓
Performance Analytics
↓
Equity Curve Generation
This project implements a Moving Average Crossover Strategy.
Short MA > Long MA → BUY
Short MA < Long MA → SELL
Short MA = Long MA → HOLD
Where:
- Short MA = Moving average of the last 3 prices
- Long MA = Moving average of the last 5 prices
The crossover of these averages helps detect market trends.
BUY EXECUTED
TEST x 5 @ ₹187
SELL EXECUTED
TEST x 5 @ ₹200
Final Trade Profit: ₹65
------ Portfolio ------
Balance: ₹100065
Positions:
TEST : 0 shares
-----------------------
------ Strategy Report ------
Total Trades : 1
Total Profit : ₹65
Win Rate : 100%
Avg Profit : ₹65
Max Drawdown : ₹10
-----------------------------
The system evaluates strategies using several metrics:
| Metric | Description |
|---|---|
| Total Trades | Number of completed trades |
| Total Profit | Overall strategy profit |
| Win Rate | Percentage of profitable trades |
| Average Profit | Mean profit per trade |
| Max Drawdown | Largest drop from peak equity |
These metrics help assess strategy profitability and risk.
The system tracks portfolio value over time and exports it to:
equity_curve.csv
Example:
Step,Equity
1,100000
2,100000
3,100000
4,100000
5,100000
6,100015
7,100005
8,100020
9,100040
10,100065
This data can be visualized to analyze strategy performance over time.
A Python script is included to plot the equity curve.
pip3 install pandas matplotlib
python3 scripts/plot_equity.py
This generates a performance chart of the trading strategy.
FinTrade Engine
│
├── BacktestEngine
│ Loads historical price data
│
├── TradingEngine
│ Generates buy/sell signals using strategy logic
│
├── PortfolioManager
│ Simulates portfolio trades and tracks balance
│
├── AnalyticsEngine
│ Calculates performance metrics and equity curves
│
└── Main Program
Orchestrates the full workflow
FinTrade-Engine
│
|__ Screenshots
| Includes demo screenshots
|
├── src
│ ├── main.cpp
│ ├── MarketDataEngine.cpp
│ ├── TradingEngine.cpp
│ ├── PortfolioManager.cpp
│ ├── BacktestEngine.cpp
│ └── AnalyticsEngine.cpp
│
├── include
│ ├── MarketDataEngine.h
│ ├── TradingEngine.h
│ ├── PortfolioManager.h
│ ├── BacktestEngine.h
│ └── AnalyticsEngine.h
│
├── scripts
│ └── plot_equity.py
│
├── prices.csv
├── equity_curve.csv
└── README.md
Compile the project:
g++ -std=c++17 src/*.cpp -o fintrade -lcurl -pthread
Run the program:
./fintrade
- C++17
- Standard Template Library (STL)
- File I/O for historical data processing
- Python (Matplotlib & Pandas) for visualization
Possible extensions of the project include:
- Sharpe ratio calculation
- Support for multiple trading strategies
- Real-time market data integration
- Strategy parameter optimization
- Strategy comparison framework
- GUI-based visualization
- Machine learning based trading signals
This project demonstrates:
- System design in C++
- Algorithmic trading concepts
- Financial data analysis
- Backtesting framework development
- Portfolio simulation
- Risk and performance evaluation
Ashutosh Upreti
Computer Science Student Interested in C++, system design, and quantitative trading systems.


