Correlation Index at the Top of the SPY

An effective, risk-adjusted portfolio requires diversification of the risk. The most common method of measuring the level of diversification of a portfolio is by analyzing the correlation in the return series of the held assets. As in the past decades (not always), bonds and stocks have been negatively correlated; it is typical to recommend a balanced stocks-bonds portfolio. There are times, the worst of times, when the markets crash that all or almost all investment vehicles move together, in correlation, so that our diversification becomes ineffective. Our equity takes one of those hits that erases the relative benefits of active management when compared to passive investing. In these dire times, diversification requires, in general, a move to cash when investment market health is low.


Does the correlation of assets in the same category tell us anything about the overall market health? About its future direction? According to this article in Bloomberg, it does. The article looks at the 3-month realized correlation in the SPY index (R1); low values of 3-month correlation may forecast a general market drop. Let us replicate that index using Quantconnect research environment; we will start with the required symbols. We are manually selecting the top 15 companies by market capitalization and removing the Google duplicate, which is a minor inconvenience:

self = QuantBook()
tickers = ['AAPL', 'MSFT', 'AMZN', 'FB', 'GOOGL',
           'BRK.B', 'TSLA', 'JPM', 'JNJ', 'V', 'NVDA', 'UNH',
            'HD', 'MA', 'DIS']

symbols = [self.AddEquity(t).Symbol for t in tickers]
start = datetime(2020, 1, 1)
end = datetime(2021, 1, 1)

We call a first 2020 to 2021 history to check the behavior in returns for these companies. We will rename the columns to the ticker usual 3-letter code. The pandas dataframe seems to get stuck in the old column names, so we recast it as a dataframe again. This unexpected behavior has been with us for a while; we cannot find where the problem is:

spy_history = self.History(symbols, start, end, Resolution.Daily).unstack(level=0)['close']
spy_history.rename(columns=lambda x: x.split(" ")[0], inplace=True)
# Dataframe retains old column names somewhere, resetting it corrects the error.
spy_history = pd.DataFrame(spy_history)

This yields the following, normal, returns chart and returns correlation heatmap:

Recent correlation for highly capitalized SPY companies.

The correlations seem relatively high for this period, with some high volatility names as Tesla (TSLA) creating spikes. The number we are looking for is the mean correlation value for the mean of each company, so:

corr_v = spy_history.corr().mean().mean()

The correlation was 0.71 from 2020 to 2021. Almost one, wherever the market was going (it was finally up), all of the top players moved almost together. Now, what happened for these other periods?

start_2 = datetime(2019, 1, 1)
end_2 = datetime(2020, 1, 1)
start_3 = datetime(2021, 1, 1)
end_3 = datetime(2021, 5, 1)

We will look at 2019 to 2020 and starting 2021 to the start of May. For 2019 the situation was:

With a mean value of 0.6. The lockstep movement at the top was lower for 2019. The end of 2019 preluded the COVID crisis, was there information already present in the markets at the end of 2019? Was a volatile 2020 predicted by the reduced consensus in moves at the top? We cannot say yet.


For our third period, starting 2021 to now, we obtain these results:


The mean correlation is 0.4. Lower than for the previous periods. We will have to check whether this means anything to the market, whether this mean correlation at the top contains predictive information regarding the future behavior of the market. We will use this mean correlation value in our next installment to obtain a backtest of various market positions using this "mean correlation at the top" indicator.


Information in ostirion.net does not constitute financial advice; we do not hold positions in any of the companies or assets that we mention in our posts at the time of posting. If you require quantitative model development, deployment, verification, or validation, do not hesitate and contact us. We will also be glad to help you with your machine learning or artificial intelligence challenges when applied to asset management, trading, or risk evaluations.



8 views0 comments

Recent Posts

See All