🧠 Overview

This project analyzes the performance of S&P 500 sectors using sector ETFs (like XLK for tech, XLE for energy, etc.) from 2015 to July 2025.
📥 Data is pulled from Yahoo Finance using R packages quantmod and PerformanceAnalytics.

🔍 We’ll explore:

  • 📈 Monthly returns
  • 📉 Cumulative performance
  • 🔁 Rolling volatility

🧰 Tools Used

  • 🧮 quantmod: Download stock data
  • 📉 PerformanceAnalytics: Metrics & visualizations
  • 📊 tidyverse: Clean and manipulate data
  • ➡️ View Python Dashboard

📈 Monthly Performance Chart

Sector tickers

 [1] "XLK"  "XLE"  "XLF"  "XLV"  "XLY"  "XLU"  "XLI"  "XLB"  "XLRE" "XLC" 
[11] "XLP" 

Load prices from Yahoo

 [1] "XLK"  "XLE"  "XLF"  "XLV"  "XLY"  "XLU"  "XLI"  "XLB"  "XLRE" "XLC" 
[11] "XLP" 
           XLK.Adjusted XLE.Adjusted XLF.Adjusted XLV.Adjusted XLY.Adjusted
2025-08-06       263.05        84.72        51.95       130.51       223.46
2025-08-07       263.29        84.39        51.37       129.01       223.39
2025-08-08       265.92        84.93        51.85       130.16       223.78
2025-08-11       264.12        84.25        51.83       130.29       224.36
2025-08-12       268.21        84.66        52.46       131.19       226.74
2025-08-13       268.31        85.64        52.76       133.29       229.85
           XLU.Adjusted XLI.Adjusted XLB.Adjusted XLRE.Adjusted XLC.Adjusted
2025-08-06        85.62       150.93        87.53         41.43       107.73
2025-08-07        86.55       150.71        87.91         41.59       107.27
2025-08-08        86.18       150.83        88.35         41.25       107.63
2025-08-11        85.91       150.34        88.15         41.01       108.18
2025-08-12        86.28       151.90        89.30         41.08       110.25
2025-08-13        86.47       152.48        90.98         41.35       111.11
           XLP.Adjusted
2025-08-06        81.62
2025-08-07        82.24
2025-08-08        82.48
2025-08-11        82.41
2025-08-12        82.63
2025-08-13        82.63
[1] "2025-08-13"

Adjusted close prices

           XLK.Adjusted XLE.Adjusted XLF.Adjusted XLV.Adjusted XLY.Adjusted
2025-08-06       263.05        84.72        51.95       130.51       223.46
2025-08-07       263.29        84.39        51.37       129.01       223.39
2025-08-08       265.92        84.93        51.85       130.16       223.78
2025-08-11       264.12        84.25        51.83       130.29       224.36
2025-08-12       268.21        84.66        52.46       131.19       226.74
2025-08-13       268.31        85.64        52.76       133.29       229.85
           XLU.Adjusted XLI.Adjusted XLB.Adjusted XLRE.Adjusted XLC.Adjusted
2025-08-06        85.62       150.93        87.53         41.43       107.73
2025-08-07        86.55       150.71        87.91         41.59       107.27
2025-08-08        86.18       150.83        88.35         41.25       107.63
2025-08-11        85.91       150.34        88.15         41.01       108.18
2025-08-12        86.28       151.90        89.30         41.08       110.25
2025-08-13        86.47       152.48        90.98         41.35       111.11
           XLP.Adjusted
2025-08-06        81.62
2025-08-07        82.24
2025-08-08        82.48
2025-08-11        82.41
2025-08-12        82.63
2025-08-13        82.63
[1] "2025-08-13"
📅 **Data last updated on:** August 13, 2025

Extract Adjusted Close Prices:

           XLK.Adjusted XLE.Adjusted XLF.Adjusted XLV.Adjusted XLY.Adjusted
2025-08-06       263.05        84.72        51.95       130.51       223.46
2025-08-07       263.29        84.39        51.37       129.01       223.39
2025-08-08       265.92        84.93        51.85       130.16       223.78
2025-08-11       264.12        84.25        51.83       130.29       224.36
2025-08-12       268.21        84.66        52.46       131.19       226.74
2025-08-13       268.31        85.64        52.76       133.29       229.85
           XLU.Adjusted XLI.Adjusted XLB.Adjusted XLRE.Adjusted XLC.Adjusted
2025-08-06        85.62       150.93        87.53         41.43       107.73
2025-08-07        86.55       150.71        87.91         41.59       107.27
2025-08-08        86.18       150.83        88.35         41.25       107.63
2025-08-11        85.91       150.34        88.15         41.01       108.18
2025-08-12        86.28       151.90        89.30         41.08       110.25
2025-08-13        86.47       152.48        90.98         41.35       111.11
           XLP.Adjusted
2025-08-06        81.62
2025-08-07        82.24
2025-08-08        82.48
2025-08-11        82.41
2025-08-12        82.63
2025-08-13        82.63
[1] "2025-08-13"

Calculate Returns & Charts:

📋 Price Table Preview