Skip to content

Saurav756/Trading-Bot-Full-Functionality

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trading Bot Full Functionality

A high-performance, multi-threaded trading bot written in modern C++ (C++17) for stocks and futures. This project showcases the core components of a production-grade trading system: real-time market data ingestion, order management, risk controls, strategy execution, backtesting, and concurrency for low-latency performance.


Features

  • Modular Design
    • MarketDataHandler: Simulates live market data or replays historical CSV data for backtesting.
    • OrderManager: Places, logs, and tracks orders with an internal order history.
    • RiskManager: Enforces exposure limits and rejects orders that exceed risk thresholds.
    • StrategyEngine: Implements a moving average crossover strategy with configurable short/long windows.
    • Backtesting Engine: Runs strategies against historical data to validate performance.
    • Concurrency: Separates data feed, strategy logic, and order execution into distinct threads for realistic, low-latency operation.

Project Structure

Trading-Bot-Full-Functionality/
├── include/
│   ├── MarketDataHandler.h   # Market data interfaces
│   ├── OrderManager.h        # Order placement & tracking
│   ├── RiskManager.h         # Exposure and risk checks
│   └── StrategyEngine.h      # Trading logic (MA crossover)
├── src/
│   ├── MarketDataHandler.cpp
│   ├── OrderManager.cpp
│   ├── RiskManager.cpp
│   ├── StrategyEngine.cpp
│   └── main.cpp              # Entry point & orchestration
├── data/                     # Sample CSV data for backtesting
├── Makefile                  # Build automation
└── README.md                 # This document

Prerequisites

  • C++17-compatible compiler (GCC, Clang, MSVC)
  • make or cmake
  • [Optional] Python (for advanced analytics or plotting)

Installation & Build

  1. Clone the repository

    git clone https://github.com/Saurav756/Trading-Bot-Full-Functionality.git
    cd Trading-Bot-Full-Functionality
  2. Build with Make

    make
  3. Clean build artifacts

    make clean

▶Usage

Live Simulation Mode

By default, the bot runs in live-simulation mode:

./tradingbot
  • Spawns a market data thread that simulates price ticks.
  • Feeds each tick to the StrategyEngine.
  • Logs order placements and risk rejections to the console.

Backtesting Mode

To replay historical data, modify main.cpp:

// Replace live simulation
// mdh.simulateData();
// With CSV backtesting
mdh.loadFromCSV("data/data.csv");

Rebuild and run:

make && ./tradingbot

All CSV ticks are processed in sequence, and executed orders are logged for offline analysis.


Configuration

  • Risk Limit: Adjust the maximum exposure in main.cpp when constructing RiskManager.
  • Strategy Parameters: Tweak shortWindow and longWindow in StrategyEngine to refine signal sensitivity.
  • Subscribed Symbols: Add or remove symbols by calling mdh.subscribe("SYMBOL", callback) in main.cpp.

Extending the Bot

  • Add New Strategies: Create new strategy classes following the same callback pattern.
  • Live Market Integration: Replace simulateData() with a real API connector (FIX, WebSocket).
  • Persistent Storage: Integrate a database (SQLite, PostgreSQL) to archive trades and P&L.
  • Visualization: Use ImGui + ImPlot for real-time dashboards, or export logs for Python-based plotting.

Contributing

Contributions are welcome! Open issues or pull requests on GitHub to:

  • Report bugs
  • Propose new features
  • Improve documentation

License

Distributed under the MIT License. See LICENSE for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published