Portfolio Evaluation (Part 1)

As part of my latest project I have decided to use Python to evaluate the university investment society portfolio that I managed this year (see: cufic.co.uk).

The Relative Return Fund mandate was to invest £30,000 in UK equities over the 2012-13 academic year.  To perform the stage 1 research, we split the UK equity space into 5 key sectors:
  1. Telecommunications, Media and Technology
  2. Natural Resources
  3. Financial Institutions
  4. Consumer and Retails
  5. Healthcare and Industrials.
On top of this, the sector allocations (stage 2) were chosen using the Black-Litterman model (method to be uploaded).  The attached notebook evaluates the performance of the final portfolio relative to a 1/N portfolio and our FTSE 100 benchmark.  Sharpe-ratios and Maximum-drawdowns included.

Analysis of Shiller's CAPE

Today I have been looking at Robert Shiller's CAPE dataset.  For those who haven't heard of this series before, the prominent Yale economist created this extensive dataset (spanning back to 1871) for his book, Irrational Exuberance.  The dataset includes: S&P 500 index values, earnings, dividends, long-term interest rates, and more.  However, the most interesting contribution is his cyclically adjusted price-to-earnings (CAPE) data.  The theory behind it is that given that business cycles on average last 7-8 years or more, Shiller decided to smooth earnings over a 10 year period to cyclically adjust the P/E ratio.

As a predominantly value-oriented investor, my main interest is to look at the impact of the CAPE on the annually compounded returns for the following 10 years.  Intuitively, we expect to witness a negative relationship between the CAPE and future returns, as reported by Shiller.  Of course, this is the case.

However, in an effort to clarify the impact of 'value' (lower CAPE) on returns, I have broken down the 142 year dataset into shorter sub-periods and plotted their relationship, allowing for an interesting portrayal of how this value relationship has changed over time.  Please see below the links to the resultant dataset and IPython notebook.

As you can see from the plots, the results are very interesting.  It appears that the expected negative relationship is non-existent between 1881 and 1911, whilst over time it transforms into a clear negative and somewhat linear relationship.  I believe that the 1881-1911 results are the least revealing since the data in that period experienced the most amount of transformations and hence is less accurate (S&P 500 took over from S&P 90 in 1957), plus the fact that the propensity for markets to correct price inefficiencies was far lower than in later years.  Between 1987 and 2002 the plots show a very revealing depiction of how important 'starting conditions' are to an investors pursuit of generating returns.  Investing when the CAPE is over 20 seriously hinders an investors chances of high returns, whilst investing when the CAPE is over 40 virtually ensures you will experience negative annualised returns over the following 10 years.

Resultant dataset.

Ipython Notebook

Importing CSV Data

Our first post starts off assuming that the data you are looking to retrieve is stored in a CSV (comma-separated-value) file.  There are many other forms of storing data, however for the size of files we will initially be using, this will work fine.

In order to start using Python to analyse the data, we must upload the data into the Python workspace.  This is done very easily, via the methodology explained in the attached Ipython Notebook.  This method uses the Pandas library, which (again) is explained very well in the 'Python for Data Analysis' book.

IPython Notebook (CSV File Import)

CSV Data File

Introduction

Welcome to my first post, and I apologise in advance for what may seem a slow start.  First, I would just like to say that this blog is primarily here to document my research into investment strategies using the Python programming language.  I will upload tutorials as a way of formalising my progression, however after a while these will subside and be replaced with research report style posts.  Thus, I would like to think that eventually someone could follow this blog and replicate everything I do.

In addition to this, I am also in the process of developing a dynamic Black-Litterman asset allocation model, utilising quantitative 'investment views' derived through mean-reversion in investment risk premiums.  Results and developments of this will be posted online, but the program itself will be proprietary at least for the time being.  In the mean time, I will post strategies using momentum and mean-reversion tools, and univariate/multivariate data analysis.

As my 'about me' states, my background is in economics and econometrics, and I hope to utilise this knowledge to further improve the capabilities of Python as a great host language for developing quantitative investment strategies.  On a final note, my use of 'investment' denotes my preference of medium to long term strategies, and is thus primarily involved in determining optimal allocations.  However trading strategies are a very important part of learning Python and thus I will be writing a lot of these for the foreseeable future, until the point where I can backtest my asset allocation ideas.