A streamlined trading simulation engine. This bot uses Python for data management and visualization, while offloading strategy execution to C++ for high-speed, event-driven processing.
Hybrid Power: Python's flexibility + C++'s execution speed.
Dual Strategies: Side-by-side comparison of Trend-Following vs. Mean-Reversion.
No Look-Ahead Bias: Event-driven C++ processes prices one-by-one.
External Analysis: Exports equity curves to .mat for Matlab integration.
This bot was tested across two distinct assets to compare strategy performance:
- Apple - Trending Asset: The
SMA Crossoverperforms better here. Because Apple tends to have long momentum runs, the trend-following logic captures the majority of the upside. - Gold - Mean-Reverting Asset: The
Z-Score ±2σstrategy excels here. Gold often trades in ranges; by buying at -2σ and selling at +2σ, the bot profits from price "snap-backs" to the average.
| Strategy | Best For | Logic Style |
|---|---|---|
SMA 20/50 |
Trending Markets | Momentum |
Z-Score |
Sideways Markets | Statistical Arbitrage |
Python 3.11+
G++ Compiler
git clone https://github.com/parthh1415/Algo-Trading-Bot.git
cd Algo-Trading-Bot
pip install -r requirements.txt
You must compile the C++ logic before running the bot:
g++ -O3 -shared -fPIC strategy.cpp -o libz.so
g++ -O3 -shared -fPIC smastrat.cpp -o libsma.so