Markowitz style portfolio optimization

Top 

       

"The singular contribution that Markowitz made to finance was his recognition that the risk in the investment has to be measured as the risk it adds to a portfolio rather than the risk of it standing alone. In effect, his work is a statistical proof that diversification eliminates a significant portion of risk in investments."         -Aswath Damodaran, HedgeTracker.com

Background

Harry Markowitz' 1950s era portfolio work yielded a Nobel Prize and more importantly an almost unimaginable amount of further academic research. Sixty years later his idea of rolling up the correlations for every pair combination of asset returns into a single portfolio risk number is the basis for almost all risk analysis work in the financial world today. Mechanica incorporates and adds to Markowitz' work by providing a method of dynamic portfolio selection (asset allocation).

Markowitz developed the concept of the efficient frontier. The efficient frontier is expressed as a curved line on a risk reward graph. Each point on the curved line represents the result of an asset mix that yields the best return for that point's level of risk. Mechanica wades into these waters by asking the question: at what point on this graph do I find the best risk adjusted return? We think Sharpe ratio is a good measure of best risk adjusted return. So, what portfolio assets should I hold in the future to get the best risk adjusted return as it is measured today? And how much capital should I allocate to each asset to implement this?

Dynamic asset allocation

Heretofore one point on this risk reward curve was selected by an investor and that portfolio (combination of assets including their weighs) was held, with possible rebalancing, forever. That is a static model. Mechanica improves upon that model by allowing periodic recalculation to find the best Sharpe ratio portfolio at each periodic interval. That 'best' Sharpe ratio portfolio is then held until the next periodic recalculation and the sequence repeats.

Implementation

Markowitz and Sharpe pioneered the idea of owning the market. i.e holding The Market Portfolio. The Market Portfolio consists of 8 or 10 sectors which are believed to be representative of the major sectors in the world economy. Today one could implement this idea by owning ETFs or mutual funds for each of the major sectors. How do we decide how much of each to purchase? Enter the other main part of Markowitz' algorithm, mean variance optimization (MVO).

MVO seeks to arrive at the best asset mix for a given level of risk. That is, the mix that provides the highest return for a given risk. Mechanica uses MVO to arrive at the mix yielding the highest Sharpe Ratio. Depending upon user interest, future versions could provide tools allowing the user to select other points along the efficient frontier for portfolio optimization. Those points would offer portfolios exhibiting more or less risk (and different return profiles) than the optimum Sharpe ratio portfolio while providing the best return for the selected level of risk.

Unlike the static nature of the original Markowitz model, Mechanica's adaptation uses a moving window approach much like that incorporated by most technical analysis procedures such as moving averages. The length of the window or look back period is set by the user in the usual fashion. Typical look back periods could be, say, 90 days to several years in length. The optimum portfolio is calculated using data from the first period, then that portfolio is held until the next period when the optimization is again carried out. The example program, launched with \Sample Rules\Signal Rules\MVO Batch funds.SIG re-optimizes once per month. The re-optimization or re-allocation interval is user definable.

MVO Batch funds.SIG makes heavy use of a GBL file and of the Grid for holding calculated data. First a fresh GBL file is initialized and interest rate data (used later by the Sharpe ratio calc) is saved to GBL[1]. Next, daily returns are calculated and saved to other GBL slots, one column or GBL slot per symbol.  This example program uses Fidelity Select Sector funds as its candidate portfolio assets. 44 is about the maximum number of symbols that can be processed using the current adaptation. 44 symbols will populate about 1000 columns in the Grid. The next SIG file posts the saved returns to the Grid and calculates the correlation values for each pair of symbols. This is done each day until the end of the data is reached. Along the way, these correlation values are transformed into the required covariance values and those covariance values are saved to GBL slots. Doing these calculations each day for a program that only re-optimizes once per month is overkill for sure and the process could be speeded up considerably by placing a JUMPTO in the code so that calculations were performed only once per month. Next, the SIZ file reads the covariance information previously saved in the GBL file and performs the periodic optimizations making the required portfolio adjustments as it moves forward in time.

The example SIG and SIZ code is heavily commented and if there is interest we would welcome further discussion on the Mechanica forums. This simulation cries out for a go flat filter and we've coded one that is effective. In the interest of keeping the example as simple as possible, the filter it is not included in the example. Also, the 'trades' are simply BUYCLOSE and are executed in Returns_to_GBL.SIG.

Diagnostic Tools

Create a plain text file in notepad named Markowitz.mec and put it in your new default/support folder \My Documents\Mechanica\Markowitz.mec to get a diagnostic dump. Enter a date of interest in this .mec file to see a report for that specific date. For instance, if you wanted to have a closer look at MVO activities for 20100430 (reallocations take place on the last day of month in the demo) just add 20100430 to the file named Markowitz.mec and save it. After the run, look for an MS Excel loadable file named "20100430 Rebalance.CSV" in the default folder. In that same folder you'll also find a new file named "Diagnostic.CSV".