Equity Clusters

I am putting together some portfolios to be auto-traded using a dynamic portfolio asset allocation algo.   I had put together a maximum spanning tree (shown in a previous posting) to observe relationships between securities.

In this iteration have gone further:

  1. Heatmap colors to indicate average volatility levels for a given security relative to others
  2. Maximum spanning tree clusters to reveal which diversification group a given asset belongs to
  3. Edge thickness indicates strength of relationship

I am interested in both the diversity and the volatility profile of the asset pool.   I will pick the majority of assets from the set with mid-range volatility (oranges), as opposed to low vol (reds), and high vol (yellows).    Classifying the asset set into clusters based on correlations provides an automated way of observing the diversification group the asset belongs to.

The algorithm is loosely as follows:

  1. calculate lower-triangular correlation matrix of returns for, say, s&p 500 stocks
  2. sort in descending order by correlation
  3. set up graph structure
  4. loop through correlations selecting pairs of assets
    1. if neither in graph add as new cluster pair
    2. if one in graph and other not, attach new to existing
    3. if both in graph but size of clusters < min cluster size, merge clusters
  5. repeat until all assets accounted for and all clusters have size >= min cluster size
  6. annotate & plot

Clusters (daily returns)
Here are the clusters the algorithm produced:

Of course this can be applied to any asset set.  Thought is a useful visualization, though there are many other dimensions of interest.



Filed under strategies

4 responses to “Equity Clusters

  1. Pingback: Regime Discovery « Quantivity

  2. Craig

    Was this done in R?

  3. tr8dr

    Partially. I did the rendering in R, but implemented the algorithm in Java.

  4. Pingback: Optimal number of clusters « Systematic Investor

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s