Main Content

Plot Efficient Frontier of Financial Portfolios

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

For details about the efficient frontier of financial portfolios, see Analyzing Portfolios (Financial Toolbox). To learn about portfolio optimization theory, see Portfolio Optimization Theory (Financial Toolbox).

The example organizes and displays the input and output data in a Microsoft® Excel® worksheet. Spreadsheet Link functions copy data to a MATLAB matrix, perform calculations using Financial Toolbox™ functions, and return data to the worksheet.

Open the ExliSamp.xls file and select the Sheet5 worksheet. For help finding the ExliSamp.xls file, see Installation.

This worksheet contains rates of return for three different portfolios: Global, Corporate Bond, and Small Cap.

Worksheet cells B4 through B9 contain rates of return for Global, cells C4 through C9 for Corporate Bond, and cells D4 through D9 for Small Cap. Spreadsheet Link functions are in column A starting with cell A15. Cells F4 through F23 are empty for risk, cells G4 through G23 are empty for ROR, and cells H4 through J23 are empty for the three portfolios.

Note

This example requires Financial Toolbox, Statistics and Machine Learning Toolbox™, and Optimization Toolbox™.

  1. Execute the Spreadsheet Link function that transfers the plot labels for the x-axis and y-axis to the MATLAB workspace by double-clicking the cell A15 and pressing Enter.

  2. Copy the portfolio return data to the MATLAB workspace by executing the function in the cell A16.

  3. Generate efficient frontier data for 20 points along the frontier by executing the Financial Toolbox functions in A19 and A20.

  4. Copy the output data to the Excel worksheet by executing the Spreadsheet Link functions in A23, A24, and A25.

    The output data contains the highest rate of return ROR for a given risk. The output data also contains the weighted investment in each portfolio Weights that achieves that rate of return.

    Cells F4 through F23 contain the risk, cells G4 through G23 contain the ROR, and cells H4 through J23 contain the weighted investment for the three portfolios.

  5. Plot the efficient frontier for the same portfolio data by executing the Financial Toolbox functions in cell A28.

    Plot contains the efficient frontier showing the ROR (y-axis) against the Risk (x-axis).

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

To generate different efficient frontier data, close the figure and change the data in cells B4:D9. Then, execute all the Spreadsheet Link functions again. The worksheet updates with new frontier data and MATLAB generates a new efficient frontier plot.

See Also

| | | (Financial Toolbox) | (Financial Toolbox)

Related Topics