Live rolling correlation - most recent 3 years

Using the 10 ETF's: 'XLY','XLP','XLE','XLF','XLV','XLI','XLB','XLK','XLU','SPY', the black line corresponds to the average of the pairwise correlation calculated based on daily returns (close to close). In green, the SPY ETF which tracks the S&P 500.

You can change the number of weeks you wish to use as a rolling window in the box above. A lower number will give a more 'choppy' line, but more up-to-date, a high number will result in a smooth line, but calculation is then based on data further in the past.

The function to generate to plot is available under the code section in this blog