A beginner-level C++ project demonstrating multi-threading concepts by simulating concurrent trade execution.
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.
- 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.
- Prerequisites: Install CMake and a C++ compiler (e.g., g++ via MinGW on Windows or GCC on Linux).
- Clone Repository:
git clone <your-repo-url>. - Build:
- Create build directory:
mkdir build && cd build. - Generate build files:
cmake ... - Compile:
cmake --build ..
- Create build directory:
- Run:
./trade_sim(ortrade_sim.exeon Windows). - Output: Watch interleaved trade logs followed by a summary (e.g., "Total trades: 15, Total quantity: 120").