Back to projects

Portfolio Risk & Backtesting Engine

2026
Visit the live siteComing soon
riskcalculatorv1.vercel.app

The question

A portfolio may look diversified, but where does its risk actually come from?

The experiment

An investment analysis tool that breaks portfolio risk down to the individual position level.

Instead of reporting a single portfolio volatility number, the platform backtests historical performance, compares returns against the S&P 500, and decomposes total portfolio risk into each holding’s contribution. The result is a clearer picture of how each position shapes the portfolio’s overall risk profile.

Features

  1. 01Historical portfolio backtesting using five years of daily market data
  2. 02Portfolio volatility, Sharpe ratio, maximum drawdown, and beta analysis
  3. 03Position level risk decomposition using covariance and correlation matrices
  4. 04Marginal, absolute, and percentage contribution to risk calculations
  5. 05Benchmark comparison against the S&P 500
  6. 06Flask web interface for portfolio analysis

What I learned

  1. 01Diversification is about reducing risk exposure, not simply increasing the number of holdings. Companies in the same or closely related industries often move together, limiting the benefits of diversification.
  2. 02Portfolio volatility becomes much more meaningful when investors understand which positions are driving their overall risk profile.
  3. 03Building financial software reinforced the importance of mathematical correctness. Every insight is only as reliable as the assumptions and calculations behind it.

What's next

  1. 01Factor based risk decomposition across sectors and investment styles
  2. 02Support for additional benchmarks beyond the S&P 500
  3. 03Portfolio rebalancing and scenario analysis