Skip to content
All projects
Tools & Dashboards

Geometric Brownian Motion Monte Carlo Price Simulator

monte-carlo-stock-simulator

A Streamlit dashboard running 5,000 vectorized GBM simulation paths in about 15ms across the 333-stock NSE/BSE master universe.

Renders a fan chart (historical price with 1%–99% percentile bands), a return-distribution histogram with VaR and CVaR markers, and a rolling-window backtester that checks how well past simulated forecasts actually covered the realized outcome.

Verified correct

The core GBM formula — correct Itô −0.5σ² drift correction, correctly annualized and dt-consistent mu and sigma, correct percentile axis, correct VaR/CVaR tail ordering — was verified with standalone sanity tests: mu = 0 and sigma = 0 produces exactly zero variance, and empirical mean and standard deviation of simulated terminal log-prices converge to theoretical values as path count grows. Verified live end-to-end against real Reliance Industries data.

Fixed in review

  • The backtester compared each rolling window's forecast against the actual price one trading day past where the simulated horizon actually landed — every coverage and accuracy metric was silently scored against the wrong future date.
  • A related off-by-one in the loop bound was silently dropping the single most recent, most relevant calibration window.
  • The "Refresh Price Data" button only cleared Streamlit's in-memory cache, never the disk-backed cache's 6-hour TTL, so clicking refresh could still serve stale data.
  • One dead code block with a Python chained-comparison bug — harmless since unused, removed.
Monte CarloGBMVaR / CVaRStreamlit
Next projectglobal-financial-news-sentiment-dashboard