This project is a C++ toolkit that solves classic quant-trading interview puzzles using two distinct methods:
- Monte Carlo simulation: Numerically estimating the optimal strategy and expected value by simulating millions of trials.
- Closed-form analytical derivation: Deriving the exact answer mathematically and verifying it matches the simulation.
The project features an extensible, low-latency C++17 Monte Carlo engine capable of running millions of trials in milliseconds.
| Puzzle Name | Category | One-Line Takeaway |
|---|---|---|
| Kelly Criterion | Bankroll Management | Over-betting positive EV games increases variance and guarantees ruin. |
| Gambler's Ruin | Probability / Markov | Hitting a distant target before ruin scales unfavorably against small edges. |
| St. Petersburg Paradox | EV / Utility Theory | Infinite EV is meaningless if tails are too fat; you must use log utility. |
| Expected Value Auction | Game Theory | In a first-price auction, optimal bidding requires shading your bid below your true valuation. |
| Secretary Problem | Optimal Stopping | Skip the first 37% (1/e) to maximize your chances of picking the absolute best. |
| Guess 2/3 Average | Iterated Game Theory | Rational players iteratively scaling down expectations converge to 0 (Nash Equilibrium). |
| Bayesian Updating | Probability / Stats | Every noisy signal pulls your posterior mean toward the signal, weighted by relative precision. |
| Card Counting EV | Conditional Prob | True count linearly shifts the EV by altering the composition of remaining cards. |
| Iterated Prisoner's Dilemma | Repeated Games | Tit-For-Tat dominates random strategies by enforcing cooperation and punishing defection. |
| Market-Making Spread | Market Microstructure | Optimal spread perfectly balances capturing noise trader spread vs. adverse selection from informed flow. |
To compile and run the puzzles (Requires C++14 or newer):
mkdir build && cd build
cmake ..
cmake --build .
# Run a specific puzzle
.\puzzle_solver.exe market_making_spread 1000000(Alternatively, you can compile directly via g++ -std=c++14 -Iinclude src/main.cpp -o puzzle_solver)
To generate convergence plots, run the python script (requires pandas and matplotlib):
python scripts/plot_convergence.py