Skip to content

Latest commit

 

History

27 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📈 Algorithmic Trading Bot - C++

A high-performance algorithmic trading system for cryptocurrency markets, built in C++ with Binance integration.

✨ Features

Indicators

  • SMA - Simple Moving Average
  • EMA - Exponential Moving Average
  • RSI - Relative Strength Index
  • MACD - Moving Average Convergence Divergence
  • Bollinger Bands - Volatility bands with %B indicator

Strategies

  • MA Crossover - Golden/Death cross signals
  • RSI Strategy - Mean reversion (buy oversold, sell overbought)
  • MACD Strategy - Momentum crossover signals
  • Bollinger Strategy - Mean reversion and breakout modes
  • Confluence Strategy - Multi-indicator consensus (EMA + MACD + RSI)

Modes

  • Backtest - Test strategies on historical data
  • Paper Trading - Live data, simulated trades
  • Web Dashboard - Real-time monitoring UI

📊 Data Sources

Feature Data Source API Keys Required
Market Data Binance Mainnet (LIVE) ❌ No
Paper Trading Binance WebSocket (LIVE) ❌ No
Dashboard Real-time prices ❌ No
Live Trading Not implemented ✅ Yes (future)

Note: The bot uses real market data from Binance. All trades are simulated locally - no real money is involved.

🧠 Strategy Logic: Confluence

The Confluence Strategy is designed for high-probability signals by requiring agreement from three different indicators:

  1. Trend (EMA 50):

    • Price > EMA = Bullish Bias (Only look for buys)
    • Price < EMA = Bearish Bias (Only look for sells)
  2. Momentum (MACD):

    • MACD Line crosses above Signal Line = Buy Signal
    • MACD Line crosses below Signal Line = Sell Signal
  3. Validation (RSI):

    • RSI < 70 (Buy): Ensures we aren't buying at the top
    • RSI > 30 (Sell): Ensures we aren't selling at the bottom

Trade Entry: When ALL 3 conditions align. Trade Exit: When momentum reverses or RSI becomes extreme.


🚀 Quick Start

Prerequisites

# Ubuntu/Debian
sudo apt update
sudo apt install -y build-essential cmake libcurl4-openssl-dev libssl-dev libboost-all-dev

Build

git clone https://github.com/ersbos/algorithmic-trading-cpp.git
cd algorithmic-trading-cpp
mkdir build && cd build
cmake ..
make -j$(nproc)
cd ..

Run Dashboard

./build/trading_bot --dashboard
# Open http://localhost:8080 in your browser

Run Backtest

./build/trading_bot --backtest --strategy rsi --period 30

🖥️ Web Dashboard

The dashboard provides real-time trading visualization:

./build/trading_bot --dashboard

Then open http://localhost:8080 in your browser.

Dashboard Features

  • 📈 Live price chart
  • 🎛️ Strategy selector (MA, RSI, MACD, Bollinger, Confluence)
  • ▶️ Start/Stop controls
  • 📊 Indicator values (RSI, MACD, Bollinger Bands)
  • 📋 Trade history
  • 💰 P&L tracking

📖 Usage Examples

# Test API connectivity
./build/trading_bot --test-connection

# Test WebSocket streaming
./build/trading_bot --test-websocket

# Backtest with different strategies
./build/trading_bot --backtest --strategy ma --period 30
./build/trading_bot --backtest --strategy rsi --period 30
./build/trading_bot --backtest --strategy macd --period 30
./build/trading_bot --backtest --strategy bollinger --period 30
./build/trading_bot --backtest --strategy confluence --period 30

# Paper trading (live data, simulated orders)
./build/trading_bot --paper --strategy rsi

# Web dashboard
./build/trading_bot --dashboard

⚙️ Configuration

Edit config/config.json:

{
    "trading": {
        "symbol": "BTCUSDT",
        "timeframe": "1h"
    },
    "strategy": {
        "short_period": 9,
        "long_period": 21
    },
    "backtest": {
        "initial_capital": 10000.0
    }
}

🧪 Running Tests

cd build
ctest --output-on-failure

All 4 test suites: TestIndicators, TestStrategy, TestBacktest, TestNewIndicators


📁 Project Structure

algoritmic_trading/
├── include/
│   ├── api/            # REST API server
│   ├── core/           # Config, logging, types
│   ├── data/           # Binance REST & WebSocket clients
│   ├── indicators/     # SMA, EMA, RSI, MACD, Bollinger
│   ├── strategy/       # Trading strategies
│   ├── backtest/       # Backtesting engine
│   └── execution/      # Order management
├── src/                # Implementation
├── web/                # Dashboard frontend
├── tests/              # Unit tests
└── config/             # Configuration files

🗺️ Roadmap

✅ Completed

  • Core infrastructure (config, logging, types)
  • Technical indicators (SMA, EMA, RSI, MACD, Bollinger)
  • Strategies (MA Crossover, RSI, MACD, Bollinger, Confluence)
  • Backtesting engine with performance metrics
  • Binance REST client
  • WebSocket for real-time data
  • Paper trading mode
  • Web dashboard

🔜 Future

  • Live trading with real orders
  • Stop-loss / Take-profit automation
  • Multiple symbol support
  • Portfolio management
  • Machine learning signals

📜 License

MIT License

About

C++ Algorithmic Trading System for Binance with Moving Average Crossover Strategy, Backtesting Engine, and Performance Metrics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages