Excel Link    

Example 4: Calculating and Plotting the Efficient Frontier of Financial Portfolios

MATLAB and the Financial Toolbox provide functions that compute and graph risks, variances, rates of return, and the efficient frontier of portfolios. Efficient portfolios have the lowest aggregate variance, or risk, for a given return. Excel and Excel Link let you set up data, execute financial functions and MATLAB graphics, and display numeric results.

This example analyzes three portfolios, using rates of return for six time periods. In actual practice, these functions can analyze many portfolios over many time periods, limited only by the amount of computer memory available.

Click the Sheet5 tab on ExliSamp.xls to try this example.

Make A15 the active cell. Press F2, then Enter to execute the Excel Link function that transfers the labels describing the outputs to be computed by MATLAB. Then make A16 the active cell to copy the actual portfolio return data to MATLAB. Execute the functions in A19 and A20 to compute the MATLAB Financial Toolbox efficient frontier function for 20 points along the frontier. Execute the Excel Link functions in A23, A24, and A25 to copy the output data to Excel.

The worksheet looks like this.

The data describes the efficient frontier for these three portfolios: that set of points representing the highest rate of return (ROR) for a given risk. For each of the 20 points along the frontier, the weighted investment in each portfolio (Weights) would achieve that rate of return.

Now move to A28 and press F2, then Enter to execute the Financial Toolbox function that plots the efficient frontier for the same portfolio data.

MATLAB displays a figure.

The light blue line shows the efficient frontier. Note the change in slope above a 6.8% return because the Corporate Bond portfolio no longer contributes to the efficient frontier.

To try different data, close the figure window and change the data in cells B4:D9 . Then re-execute all the Excel Link functions. The worksheet then shows the new frontier data, and MATLAB displays a new efficient frontier graph.


  Example 3: Pricing a Stock Option with the Binomial Model Example 5: Bond Cash Flow and Time Mapping