Skip to content

A realistic high-frequency trading simulation game built in C++ where players compete to maximize profits using various algorithmic trading strategies.

Notifications You must be signed in to change notification settings

kudosscience/trading-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

High-Frequency Stock Trading Game

A realistic high-frequency trading simulation game built in C++ where players compete to maximize profits using various algorithmic trading strategies.

Features

  • Real-time Market Simulation: Microsecond-precision order matching with realistic market behavior
  • Multiple Trading Strategies: Market making, arbitrage, momentum, and mean reversion algorithms
  • Performance Analytics: Comprehensive P&L tracking, risk metrics, and trade analytics
  • High Performance: Optimized for low-latency operations and high-frequency trading
  • Competitive Gameplay: Multi-player support with leaderboards and tournaments

Building the Project

Prerequisites

  • C++17 compatible compiler (GCC 7+, Clang 5+, or MSVC 2017+)
  • CMake 3.16 or higher
  • Git (for cloning dependencies)

Build Instructions

# Clone the repository
git clone <repository-url>
cd trading-game

# Create build directory
mkdir build
cd build

# Configure and build
cmake ..
cmake --build . --config Release

# Run the game
./bin/TradingGame

Windows (Visual Studio)

mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -A x64
cmake --build . --config Release

Game Modes

Single Player

  • Training Mode: Learn trading strategies with slower market conditions
  • Challenge Mode: Complete specific trading objectives
  • Free Play: Unlimited trading with customizable market conditions

Multi-player

  • Competition: Real-time trading against other players
  • Tournament: Bracket-style competitions with elimination rounds
  • Leaderboard: Global rankings based on risk-adjusted returns

Trading Strategies

The game includes several built-in algorithmic trading strategies:

  1. Market Making: Provide liquidity by placing bid/ask orders
  2. Statistical Arbitrage: Exploit price differences between correlated assets
  3. Momentum Trading: Follow price trends and breakouts
  4. Mean Reversion: Trade against extreme price movements
  5. High-Frequency Scalping: Capture small price movements with high volume

Performance Metrics

  • Total Return: Absolute profit/loss percentage
  • Sharpe Ratio: Risk-adjusted return measure
  • Maximum Drawdown: Largest peak-to-trough decline
  • Win Rate: Percentage of profitable trades
  • Average Trade Duration: Mean holding time per position
  • Latency Metrics: Order execution and market data processing times

Configuration

Game settings can be customized through JSON configuration files in the config/ directory:

  • market_config.json: Market parameters (volatility, liquidity, spreads)
  • game_config.json: Game rules, scoring weights, and time limits
  • strategy_config.json: Default parameters for trading algorithms

File Structure

trading-game/
├── src/
│   ├── core/           # Core data structures (Order, OrderBook, Stock)
│   ├── engine/         # Order matching and market engine
│   ├── strategies/     # Trading algorithm implementations
│   ├── interface/      # Player interface and controls
│   ├── analytics/      # Performance metrics and statistics
│   └── utils/          # Utility functions and helpers
├── include/            # Public header files
├── tests/              # Unit and integration tests
├── config/             # Configuration files
├── data/               # Market data and scenarios
└── build/              # Build output directory

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-strategy)
  3. Commit your changes (git commit -am 'Add new trading strategy')
  4. Push to the branch (git push origin feature/new-strategy)
  5. Create a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Performance Notes

  • The game is optimized for low-latency operations with microsecond precision
  • Lock-free data structures are used for order processing
  • Memory pools reduce allocation overhead
  • SIMD optimizations are applied where beneficial
  • Multi-threading allows concurrent market simulation and strategy execution

System Requirements

Minimum

  • 4GB RAM
  • Dual-core CPU (2.0 GHz)
  • 500MB disk space

Recommended

  • 8GB+ RAM
  • Quad-core CPU (3.0+ GHz)
  • SSD storage for optimal performance
  • Dedicated graphics card (for advanced UI modes)

About

A realistic high-frequency trading simulation game built in C++ where players compete to maximize profits using various algorithmic trading strategies.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published