Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 1.12 KB

File metadata and controls

24 lines (19 loc) · 1.12 KB

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