Stock market visualization: Minimum Spanning Trees

One of the most useful ways to visualize the stock market is with Minimum Spanning Trees (MST). These are network graphs in which each vertex represents a stock symbol and where strongly related stocks are connected by edges.

One popular way to do this is by using correlation matrices. In the past, we have constructed MSTs by transforming the price correlation matrix for a group of stocks into a distance matrix using a metric function.

Suppose we have a function d(i,j) which returns the distance between two points: i and j. We can call d() a metric if:

  1. d(i, j) >= 0 (non-negativity)
  2. d(i, j) = 0 if and only if i = j
  3. d(i, j) = d(j, i)
  4. d(i, j) <= d(i, k) + d(k, j)

We first discovered MSTs by reading Networks of Equities in Financial Markets by Bonanno et al, where they use the following transformation function to convert the correlation matrix into a distance matrix:

distance[i, j] = sqrt(2.0 * ( 1 – correlation[i, j] ) )

This function is interesting because it separates positive and negative correlations. Consider this pair of correlations, 0.8 and -0.8. This function turns 0.8 into 0.632 and -0.8 into 1.89. This means negative correlations are represented as farther away than their positive counterparts.

While the concept of an MST to visualize correlation was revelatory, on an intuitive level this metric strikes us as strange. We can arbitrarily turn a negatively correlated asset into a positive asset by short selling. Moreover, in many quantitative trading applications we are looking for absolute strength of the relationship, positive or negative. Thus positive and negative correlations should be treated as essentially the same measure, implying a transformation function like:

distance[i, j] = 1 – abs( correlation[i, j] )

If your correlation matrix consists largely of positive values, then it won’t really make much of a difference; the MSTs produced from both metrics will retain similar overall clustering patterns. We produced the following MSTs from the price correlation matrices for a sample of Nasdaq 100 stocks, where most pair-wise correlations are positive (they are identical in structure as far as we can tell):

mst1amst1b

With other correlation structures, which metric you choose can make a difference. We also wanted to look at the correlation structures for social data like search volumes from Google, which have a more more diverse correlation matrix than the stock price matrix:

mst2a mst2b


To explore Minimum Spanning Trees and Filtered Correlation Networks for the S&P 400, S&P 500, S&P 600 and NASDAQ 100 indexes, visit our SliceMatrix information page to request a demo or contact us.

Network Graph from SliceMatrix

Network Graph from SliceMatrix


11 replies »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s