A realistic high-frequency trading simulation game built in C++ where players compete to maximize profits using various algorithmic trading strategies.
- 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
- C++17 compatible compiler (GCC 7+, Clang 5+, or MSVC 2017+)
- CMake 3.16 or higher
- Git (for cloning dependencies)
# 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
mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -A x64
cmake --build . --config Release
- Training Mode: Learn trading strategies with slower market conditions
- Challenge Mode: Complete specific trading objectives
- Free Play: Unlimited trading with customizable market conditions
- Competition: Real-time trading against other players
- Tournament: Bracket-style competitions with elimination rounds
- Leaderboard: Global rankings based on risk-adjusted returns
The game includes several built-in algorithmic trading strategies:
- Market Making: Provide liquidity by placing bid/ask orders
- Statistical Arbitrage: Exploit price differences between correlated assets
- Momentum Trading: Follow price trends and breakouts
- Mean Reversion: Trade against extreme price movements
- High-Frequency Scalping: Capture small price movements with high volume
- 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
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 limitsstrategy_config.json
: Default parameters for trading algorithms
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
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-strategy
) - Commit your changes (
git commit -am 'Add new trading strategy'
) - Push to the branch (
git push origin feature/new-strategy
) - Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- 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
- 4GB RAM
- Dual-core CPU (2.0 GHz)
- 500MB disk space
- 8GB+ RAM
- Quad-core CPU (3.0+ GHz)
- SSD storage for optimal performance
- Dedicated graphics card (for advanced UI modes)