Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Principle Component Analysis of the Energy Sector

Hi everybody,
I threw together an algo that uses PCA to get the component that explains the most variance in the energy sector. It assumes the principle component is a unit portfolio and buys 500 units of the portfolio.

It is really basic, but could be the baseline for more work. Here are a couple references on the idea.
PCA analysis in an Ipython notebook

Stat Arb in the US Equities Market

This is not a duplication of either, but an overly simplified version of the idea. It uses prices instead of returns, and rebalances on a 5 day schedule. I need to do more work to wrap my head around the math, but it looks like there's a strategy in there somewhere.

David

5 responses

The best part of Avellaneda's paper is the s-score. Dr. Liew extended the idea using the Black-Litterman model: http://battleofthequants.net/wp-content/uploads/2013/03/2010-10-12_US_Equity_Mean_Reversion.pdf

Thanks for sharing this algo! An interesting extension would be to build a market-neutral portfolio using the "eigen-portfolios." The first principal component is highly correlated with the market (indeed one could consider the variance of this component as representing the market effect on all firms). Perhaps a more compelling strategy would be to trade based on non-market wide correlations between firms.

Just a quick thought.....Would a simple correlation analysis of the individual stock returns vs. the DJ index returns indicate a similar pattern as your loadings graph ?

I tried so hard. If you enter different amounts you get varying amount of leverage .

I tried so hard. If you enter different amounts you get varying amount of leverage