# Efficient Frontier & Portfolio Optimization with Python [Part 2/2]

In the first part of this series, we looked at the underpinnings of Modern Portfolio Theory and generated an Efficient Frontier with the help of Monte Carlo Simulation. This post concludes the series by looking at the concept of portfolio optimization.

50,000 portfolios with different combinations of weights generated different expected returns and expected volatility. Each point lying on the line represents an optimal combination of stocks (CenterPoint Energy, Facebook, Walmart, General Electric, Tesla in this case) that maximises the expected return for the given level of risk. If all points on the Efficient Frontier curve are optimal combinations, what is the optimal portfolio among the various optimal combinations? What would even the criteria for choosing this “best of the best” combinations?

William F. Sharpe, another Nobel Prize laureate extended Markowitz’s work which resulted in the infamous Capital Asset Pricing Model (CAPM). This post will not delve into this model now. However, we will utilize one of his contributions (the Sharpe Ratio) as criteria for choosing this “best combination”.

Sharpe ratio is simply as a measure of the performance of an investment’s returns given its risk. This ratio adjusts the returns of an investment which makes it possible to compare different investments on a scale that incorporates risk. Without this scale of comparison, it would be virtually impossible to compare different investments with different combinations and their accompanying risks and returns.

**NB**: For simplicity's sake a risk free rate of 0% was assumed for this post

We will take advantage of the code we used in generating the efficient frontier in the last post with some minor adjustments. We already have expected returns and returns of our simulated portfolios. We are simply going to calculate their risk-adjusted returns (with the help of the Sharpe Ratio), and make a colour bar of the plots using the Sharpe Ratio as the colour map:

Let’s see what we get. A nice efficient frontier coloured by the Sharpe Ratio of each portfolio’s risks and returns.

Next up, let’s try to locate the optimal portfolio and another portfolio with the minimum volatility for the most risk-averse investor out there:

There we have it. An Efficient Frontier with a highlight of the optimal (as per the risk-adjusted return metric) portfolio and a portfolio with the minimum volatility.

To get specific details of these two special portfolios, let’s print their values out:

The most risk-averse investor would construct the minimum variance portfolio which has an expected return of

with an accompanying expected volatility of **4.58%**

. Investors seeking the maximum risk-adjusted return would opt for portfolio that with the maximum Sharpe Ratio which has an expected return of **13.86%**

with expected volatility pegged at **11.61%****17.50%**

There are mathematical optimization techniques that would have resulted in the same result. However, I chose to use a Monte Carlo Simulation (sort of manual way) to explain the whole concept of Efficient Frontier and optimal portfolios. I will cover the mathematical technique in a future post (I promise!). Until the next post, happy coding!

As usual, you can grab the source code on the blog’s GitHub page.