Stock Market Risk Analysis

20 years of AAPL, MSFT, GOOGL & AMZN data — CAPM, Sharpe/Sortino ratios, Markowitz optimisation, and technical analysis, in a notebook and a live Streamlit dashboard

Overview

A quantitative finance project analysing 20 years of stock data (January 2004 – December 2024) for four major technology companies, deliberately spanning the 2008 Global Financial Crisis, the 2020 COVID crash and recovery, and the 2022 rate-hike-driven tech sell-off.

The analysis covers nine statistical performance metrics per stock, CAPM beta/alpha regression against the S&P 500, Sharpe and Sortino ratio risk-adjusted performance, Markowitz mean-variance portfolio optimisation via PyPortfolioOpt, and a technical-analysis layer (SMA, Bollinger Bands, RSI, MACD) — delivered through both a research-grade Jupyter notebook and an interactive Streamlit dashboard.

Key Results

51,204%
AAPL cumulative return, 2004–2024 — best of the four stocks
2,468.60%
Markowitz-optimised portfolio return vs. 327.42% for the S&P 500
1.24
Optimised portfolio Sharpe Ratio vs. 0.79 for the S&P 500
-32.86%
Optimised portfolio max drawdown vs. -56.8% for the S&P 500

Tech Stack & Skills Demonstrated

Quantitative Finance

  • CAPM beta/alpha via linear regression
  • Sharpe & Sortino ratio analysis
  • Markowitz mean-variance optimisation (PyPortfolioOpt / cvxpy)

Statistical Analysis

  • Return distribution profiling — skewness, kurtosis
  • Leptokurtic tail-risk detection

Technical Analysis

  • SMA crossovers, Bollinger Bands
  • RSI and MACD momentum indicators

Interactive Dashboard

  • Streamlit app with 5 analysis tabs
  • Deployable to Streamlit Cloud, no server config

Explore the Code

Full methodology, limitations, and references are on GitHub.

GitHub ↗ Visual Write-up on Notion ↗ ← Back to Portfolio