Skip to content

sharpsalt/StochasticEdge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StochasticEdge - Monte Carlo + Analytical Engine

This project is a C++ toolkit that solves classic quant-trading interview puzzles using two distinct methods:

  1. Monte Carlo simulation: Numerically estimating the optimal strategy and expected value by simulating millions of trials.
  2. 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 Modules

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.

Build and Run

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

About

Built a C++17 Monte Carlo engine solving 10+ classic mathematical puzzles(Kelly Criterion,Gambler's Ruin,Secretary Problem,Bayesian Updating,Market-Making Spread),validating each estimate against closed-form analytical solutions with under 1.2% error across 1M+ trials,with plots

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors