Skip to content

Enmilo-dev/TradeSim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Threaded Trade Simulator

A beginner-level C++ project demonstrating multi-threading concepts by simulating concurrent trade execution.

Description

This program simulates 3 traders, each executing 5 buy or sell trades concurrently. Trades are logged to a shared vector with thread-safe synchronization using a mutex. The program outputs each trade in real-time and provides a summary of total trades and quantity.

Features

  • Multi-threaded trade simulation with 3 traders.
  • Thread-safe logging using std::mutex.
  • Random trade generation (price: $100-$119, quantity: 1-15).
  • Summary of total trades and quantity.

How to Build and Run

  1. Prerequisites: Install CMake and a C++ compiler (e.g., g++ via MinGW on Windows or GCC on Linux).
  2. Clone Repository: git clone <your-repo-url>.
  3. Build:
    • Create build directory: mkdir build && cd build.
    • Generate build files: cmake ...
    • Compile: cmake --build ..
  4. Run: ./trade_sim (or trade_sim.exe on Windows).
  5. Output: Watch interleaved trade logs followed by a summary (e.g., "Total trades: 15, Total quantity: 120").

Sample Output

About

Market exchange simulator with order book matching logic and latency analysis for backtesting trading strategies against historical tick data.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors