04 / 09, 2025
Monte Carlo
Portfolio risk simulation that turns historical market data into probabilistic outcomes.
Role
Solo engineer, FastAPI simulation backend, React dashboard, risk analytics
Stack
FastAPI · NumPy · Pandas · SciPy · Polygon.io · React 18 · Plotly.js · Axios
Links
The Problem
The README frames Monte Carlo simulation as an antidote to single point portfolio estimates. Investors need distributions of possible outcomes, not one expected return number.
The tool helps users build a portfolio, configure horizon and simulation count, then understand upside, downside, volatility, VaR, and Sharpe ratio through interactive charts.
The Architecture
01Portfolio configuration UI
React supports up to 10 stocks, slider and percentage weight controls, auto balancing to 100%, validation, and a simulation setup spanning one month to five years.
02Market data simulation backend
FastAPI receives portfolio, days, and simulation count inputs, pulls historical market data through Polygon.io, calculates means and covariance, and runs multivariate random return simulations with NumPy and SciPy.
03Plotly result exploration
The UI renders final value distributions, simulation paths, risk return scatter views, expected return, annual volatility, 95% VaR, and Sharpe ratio.
Decisions that mattered
Model correlations between assets
The simulator uses covariance aware multivariate modeling instead of independent asset paths, which better matches portfolio risk where assets move together during stress.
Make simulation scale configurable
Users can run from 100 to 10,000 paths, trading speed for accuracy while keeping the simulation understandable.
Surface setup constraints
The README documents API key setup, rate limits, health checks, CORS configuration, and Polygon free tier constraints so the application is usable beyond a demo screen.
The Numbers
10
max portfolio stocks
10K
simulation paths
95%
VaR confidence
5y
max horizon
What it taught me
Portfolio analysis becomes more useful when users can see the full distribution of outcomes instead of a single average path.
README level operational details such as API limits and health checks matter because finance tools depend on external data reliability.