Comparing portfolio performance to a benchmark
A benchmark is just a well-established point of reference. In the world of investments, that is usually the S&P 500 Index, which is reflected in the SPY ETF. So, let’s find out how our portfolio compares.
If we pick up the previously useful yfinance
module, we can retrieve some price history on SPY with just one line of code.
benchmarkTicker = "SPY" data = yf.download(benchmarkTicker, group_by="Ticker", period="5y") data
You’ll get an output that looks similar to this:
Open High Low Close Adj Close Volume Date 2017-12-01 264.760010 265.309998 260.760010 264.459991 242.683990 164390900 2017-12-04 266.309998 266.799988 264.079987 264.140015 242.390366 94040600 2017-12-05 263.190002 ...