Markowitz’s Mean-Variance Optimisation (MVO) model

Rozina Myoya · October 3, 2022

Are you someone who has zero financial background and has no idea what the Markowitz mean variance optimization model is all about? Don’t worry, you’re in the right place! This model might sound intimidating and complex, but it’s actually a pretty simple concept.

So, what is it all about? In a nutshell, the Markowitz mean variance optimization model is a way to help people make smart decisions about how to invest their money. When you invest your money, you’re basically taking a risk in the hopes that you’ll make a profit. The model helps you understand how much risk you’re taking and whether or not it’s worth it. The more formal definition states that The Markowitz’s Mean-Variance Optimisation (MVO) model provides a method of selecting the optimal portfolio composition of investment assets by making a trade off between the expected returns and the risk of the potential portfolios (Luenberger, 1997).

Now, let’s say you have a bunch of different investments that you can choose from, like stocks, bonds, and mutual funds. Each of these investments has a different level of risk and a different expected return (how much money you might make from it). The Markowitz mean variance optimization model helps you figure out which investments to choose by looking at the mean (average) return and the variance (how spread out the returns are) for each investment.

Here’s where it gets a little more complicated: the model also takes into account how each of your investments affects the others. For example, if you have two stocks that both tend to go up and down at the same time, they might be riskier together than they are on their own. The model helps you figure out how to balance your investments so that you’re not taking on too much risk.

So, how do you use the Markowitz mean variance optimization model? Well, first you need to decide how much risk you’re comfortable with. This is called your “risk tolerance.” Once you know your risk tolerance, you can use the model to figure out which investments are right for you. The model will show you the mean (average) return and the variance (how spread out the returns are) for each investment, and it will help you find the balance that works best for you.

Let’s take the example of choosing a few stocks from the JSE that would form your portfolio. For example I chose 10 stocks listed below (downloaded from Investing.com):

  1. Anglo American PLC (AGLJ)
  2. Aveng Ltd (AEGL)
  3. Exxaro Resources Ltd (EXXJ)
  4. Kumba Iron Ore Ltd (KIOJ)
  5. Mr Price Group Ltd (MRPJ)
  6. MTN Group Ltd (MTNJ)
  7. RMB Holdings Ltd (RMHJ)
  8. Santam (SNTJ)
  9. Sasol Ltd (SOLJ)
  10. Shoprite Holdings Ltd (SHPJ)

I just chose the top 10 performing stocks on that particular day. The historical data timeline was 07 Sept 2016 to 07 Sept 2022 (on a daily basis). The time series of the “Total Returns” of the the assets was calculated using the equations below:

Calulating the rates of return of each stock

\(r_{it} = \frac{I_{i,t} - I_{i,t-1}}{I_{i,t-1}}\)

Where $I_{it}$ denotes the “Total Return” (Close price) for stocks $i=[1,10]$ and $t = 0,…,T$ where $t=0$ corresponds to the start date and $t=T$ to the end date. For each stock $i$, the raw data $I_{it}$ for $t=0,…,T$ can be converted to rates of return $r_{it}$ with $t = 1,…,T$

returns = (stocks/stocks.shift(1))

returns

Log returns

\(log \ r_{it} = log \frac{I_{i,t} - I_{i,t-1}}{I_{i,t-1}}\)

The log returns were computed to deal with the disparity in orders of magnitude between the rates of return of the different stocks

# Log returns
log_returns = np.log(returns)

log_returns

Thereafter MVO was used to determine the efficient frontier and thus the optimum portfolio given my choice of stocks.

Robust Optimisation approach

We will generate all possible portfolios. This method is recommended by Michaud (1998) to mitigate the fundamental weakness of the Markowitz model, namely, the solution found from the model is extremely sensitive to small changes in the data. Only a small change in one $\mu_{i}$ may result in a completely different portfolio $w$. Therefore, a robust optimisation approach provides an alternative approach to mitigating the model’s sensitivity

Efficient Markowitz Frontier

With the mean and covariance known, the efficient frontier can be determined by finding the solution $w$ where:

\(\begin{align*} min_{w} \ \  & w^{T} \sum w \\ subject \ to \ \ & \mu^{t}w \geq R_{min} \\ & w \geq 0 \\ & 1^{T} w = 1 \end{align*}\)

# Efficient Markowitz Frontier
target_returns = np.linspace(0, 0.15, 50
volatility_opt = []
E = df_returns.mean()

def minimize_Vol(w):
    w = np.array(
    V = np.sqrt(np.dot(w.T, np.dot(Cov_log,w)))
    return V

def get_Return(w):
    w = np.array(w)
    R = np.sum(E*w)
	return R


def checkSumToOne(w):
    return np.sum(w)-1

w0 = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]
bounds = ((0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1))

for ret in target_returns:
    #find the point with opt volatility
    constraints = ({'type':'eq', 'fun':checkSumToOne},
                   {'type':'eq', 'fun': lambda w: get_Return(w) - ret})
    opt = minimize(minimize_Vol, w0,method='SLSQP',bounds=bounds, 
                   constraints=constraints)
    #save optimal volatility values
    volatility_opt.append(opt['fun'])

Now, it’s important to remember that no investment is risk-free. Even if you use the Markowitz mean variance optimization model to make smart investment decisions, you could still lose money. But by understanding how much risk you’re taking and why, you can make informed decisions that can help you reach your financial goals.

So, there you have it! The Markowitz mean variance optimization model might sound intimidating, but it’s actually a pretty simple way to help you make smart investment decisions. By understanding how much risk you’re comfortable with and how your investments affect each other, you can find the balance that works best for you. Happy investing!

Further reading:

  • Incorporating the Sharpe Ratio into the optimisation
  • Using PCA to cater for collinearity between investments
  • Factor modeling

References:

Twitter, Facebook