Live Correlation plot, shiny improvement.

Open CPU is a great project. Few months back, I wrote a function for plotting a moving window of the market average correlation. Jeroen C.L. Ooms was nice enough to upload it to their server. Something is now changed. Quotes now return as a character class, as oppose to numeric. This messes up the function and the plot does not renders. I don’t wish to disturb Jeroen C.L. Ooms again with the correction for the code (despite his kind replies in the past). This problem creates the opportunity to look at the glistening “Shiny” package. I used it to (quickly..) build an app for the plot. You can now view a live correlation plot with the moving window of your choice. Live, as the app requests current market data. The width of the window for correlation calculation is given as an input parameter.

You can find the plot here.

The code, (let’s be honest.. this is the most interesting part..), is as follows:



You still here?
Few more comments:

The app itself is located on the RStudio server. Yes, they are cool like that, just apply and get an email back with clear instructions an ape can follow. (Not to bad mouth any apes out there.. each with its own set of skills.)
A bit on the actual plot:
It is a time series. Every point represents the average correlation between 10 ETF’s that cover different major market sectors. (more here).
As you increase the width of the window, you will observe the series become smoother. This is natural. I also note that even when the width is 12 weeks, the series still fluctuate between 0.6 and 0.9. Also, it is said that correlation increases with market draw-downs. I think this is most easily seen for “Number of weeks for moving window calculation: 4”. Remember the calculation of correlation is done over the most recent 4 weeks and is not forward looking, so account for this lag when you look at SPY price level in the bottom panel.

Leave a Reply

Your email address will not be published. Required fields are marked *