Technical Articles and Newsletters |

By Bob Taylor, MathWorks

*Portfolio optimization* *was first developed in the 1950s, but a number of practical and theoretical problems have limited its use by investment managers. For example, it is often difficult to obtain sufficient high-quality historical data for thorough analysis. In addition, the efficient frontier where optimal portfolios lie tends to shift over time, quickly making these portfolios suboptimal.*

*Modern data analysis tools, such as MATLAB and Financial Toolbox, can overcome these challenges.*

Using the Dow Jones Industrial Average as a benchmark, we will implement a portfolio optimization methodology based on capital asset pricing and mean-variance analysis. Our goals are to use consistent, repeatable steps and to construct realistic, optimal portfolios that are stable over time.

The mean and covariance of asset returns are primary inputs for portfolio optimization. Estimating these moments involves three tasks: acquiring data, dealing with missing data, and setting up a suitable benchmark.

**Acquiring Data**

We use MATLAB and Datafeed Toolbox to obtain return data for stocks and market indexes. In our example we acquire monthly total return data on 44 blue-chip stocks and the Dow Jones Industrial Average (DJIA) from Yahoo! Finance.

**Dealing with Missing Data**

Unfortunately, historical financial data is often messy and incomplete. We use the Financial Toolbox function ecmnmle to deal with data sets that have missing values (represented as NaNs in MATLAB). This function uses all available data to obtain best estimates for asset return moments in the presence of NaNs—a nice alternative to the usual ad hoc approaches.

**Setting up a Benchmark**

We use a market index as our benchmark, since market return is the main driver of asset returns in capital asset pricing. By removing market returns from the data we can focus on non-market returns and risks. In our example we subtract the return of the DJIA from individual asset returns.

In mean-variance analysis, expected return is plotted against risk (the standard deviation of asset returns) for a given portfolio. We generate random combinations of portfolio weights to produce a scatter plot of the expected return and risk for each portfolio (Figure 1).

Each red dot represents the mean and standard deviation of a portfolio. The blue line is the efficient frontier. Portfolios on the efficient frontier have maximum return for a given level of risk or, alternatively, minimum risk for a given level of return. Clearly, a rational investor will select a portfolio on the efficient frontier.

The `portopt`

function in Financial Toolbox lets us determine directly which portfolios of assets lie along the efficient frontier given the means and covariances of individual asset returns.

Because the efficient frontier shifts over time, a once-efficient portfolio may be not be on the efficient frontier in subsequent time periods. In addition, it is not clear which portfolio to select on the efficient frontier.

One solution is to study the time evolution of efficient frontiers and identify a sequence of portfolios that remain relatively stable from one efficient frontier to the next. We can use MATLAB to visualize this stable region.

Figure 2 shows efficient frontiers plotted as a function of time. MATLAB has calculated efficient frontiers with 40 portfolios on each frontier at one-month intervals and plotted the results. Figure 2 underscores the value of taking the market out of the data: We can identify sequences of portfolios—those in the deep blue region—with little variation of return or risk and with consistently positive expected returns relative to the market.

Now that we have identified a set of portfolios that are both efficient and stable, we can perform an *ex post* analysis, examining turnover, drawdown, and realized average return to see how these portfolios actually performed.

**Turnover **

Turnover refers to the change in portfolio holdings over time due to trading. A portfolio with annual turnover of 25% will replace a quarter of its assets over a one-year period. Since trading is costly, low turnover is a desirable feature of a portfolio strategy.

Figure 3 shows the annual turnover for the portfolio sequences on our efficient frontiers, with the blue line representing the results of the analysis after removing market returns. Note that in the stable region, with the first eight portfolio sequences, the annual turnover remains at 25% or less.

**Drawdown**

Evaluating the maximum drawdown of a portfolio is a good way to measure *ex post* risk. Maximum drawdown refers to the amount a portfolio declines in value relative to its peak value. It represents the worst possible performance over any time period.

In Figure 4, the green line represents the maximum drawdown of the DJIA over our back-test period—roughly 20%. The flat part of the blue line represents the maximum drawdown for the portfolio sequences through the stable region and closely mirrors the maximum drawdown of the DJIA. Since our goal is to assemble portfolios with risk and return characteristics similar to the Dow Jones Average, this is a good result—it shows that the risk of these portfolio sequences is comparable to our benchmark.

**Average Return**

One of the simplest performance measurements is to determine a portfolio’s average mean and standard deviation of returns. We have already determined that the portfolio sequences in the stable region have reasonable levels of risk compared to the benchmark. But do those same portfolios deliver superior returns?

We plot the average of *ex post* returns versus risk of a portfolio or index. In Figure 5, the red star represents the return and risk of the DJIA benchmark over our backtest period. Each blue circle corresponds to a portfolio sequence. The circles closest to he star are portfolio sequences in the stable region—those with the lowest risk and the highest annualized returns. In fact, some portfolios outperformed the DJIA by about 150 basis points with comparable risk and less than 25% turnover per year.

By enabling analysts to acquire data, estimate asset return moments, form optimized portfolios, visualize concepts, and backtest results, MATLAB provides a platform that facilitates financial analysis.

The approach described here is a good starting point for a portfolio optimization model. An institutional investor using this model would probably want to incorporate transaction costs and trading constraints into the model. Nevertheless, the potential to beat the market by an average 150 basis points with low turnover is an encouraging first step.

**Basis Point.** A measure of return. One basis point = 1/100 %.

**Capital Asset Pricing Model (CAPM)****.** A model in which the return for any security or portfolio of securities equals the riskless rate plus a risk premium that is proportional to the excess market return (market return minus the riskless rate).

**Efficient frontier.** The combination of all efficient portfolios (those that deliver the highest possible return for a given level of risk).

**Ex ante analysis.** An analysis performed before any action is taken.

**Ex post****analysis.** An analysis performed after action is taken and results have been realized. An historical ex post analysis of investment performance is called a backtest.

**Maximum drawdown.** The maximum decline in total equity from peak to subsequent trough.

**Mean-variance analysis.** A method to select optimal portfolios based on the mean and covariance of asset returns.

**Risk.** The standard deviation of asset total returns.

**Turnover.** A measure of how much the holdings in a portfolio change over a specific time period.

Published 2006 - 91427v00

Haugen, Robert and Nardin Baker,

"Dedicated Stock Portfolios," *Journal of Portfolio Management*, Summer 1990, pp. 17-22.

———, "The Efficient Market Inefficiency of Capitalization-Weighted Stock Portfolios,"*Journal of Portfolio Management*, Spring 1991, pp. 35-40.

Markowitz, Harry, Portfolio Selection:*Efficient Diversification of Investments*, John Wiley & Sons, Inc., 1959.