A Gentle Introduction to Modern Portfolio Theory (MPT)
A Mathematical take on: “Don’t Put All Your Eggs in One Basket”
You probably heard your grandma saying:
Don’t put all your eggs in one basket.
It sounded like a good advice, but let’s be honest, will you base your investment strategy on a saying?
Why split your bets on Apples and Oranges, if clearly the price of the Apples stock is skyrocketing?
The key is to think in terms of both risks and returns. It’s easy to focus solely on returns. Returns is the obvious one we all know here.
I look at a stock’s price, notice it’s up by 10% from last year, and think, “Cool, I made 10%!” But then, what about the risk? What’s that all about?
The missing piece here is how certain are you that this stock will continue to go up by another 10% next year? What about the next five years?
This level of certainty, or rather the lack thereof, is what we call risk.
In this post, I’ll break down the Modern Portfolio Theory and detail a simple formula for analyzing risk and returns, to show you — in mathematical terms — why diversification can lower your investment risk.
Whether you are an investor or not, understanding this can help you make smarter choices and build a stronger plan for your money and the bets you take in your life in general.
Let’s define Risk and Return
You have $ 1000, you put $ 500 to buy one stock (Asset A) and the other $ 500 to buy another stock (Asset B).
Let’s check how much their values are after 5 years:
The $ 500 you put in Asset A became $ 521 on 2029, while the $ 500 you put in Asset B became $ 463.
Let’s check how much their value is after 10 years:
The $ 500 you put in Asset A became $ 554 on 2034, while the $ 500 you put in Asset B became $ 646.
As you can see Asset A was better than Asset B on the short run (5 years), however Asset B was better on the long run (10 years).
This brings us to our first question
How do we quantify how profitable one asset is?
Return is calculated via this simple formula:
Thus, the return for Asset A after 5 years is R = (521 — 500) / 500 = 4.2%
, and after 10 years it is 10.8%
.
Similarly for Asset B is -7.4%
, notice the negative sign, it means you lost money on this asset on the short run, but after 10 years you make more money than Asset A; the return of Asset B on the long run is 29.2%
.
Nevertheless, if you look at the table, you will notice that the value of Asset A never went below its original value, unlike Asset B which sometimes went below its original $ 500.
In other words, Asset A is less risky, while Asset B is more risk. But what do we actually mean by risk?
This brings us to our second question
How do we quantify how risky one asset is?
Let’s plot the yearly return. Each year, we subtract its value from the previous year’s value and divide by the previous year’s value. We will then get the following:
Notice the dotted lines represents the average value of the yearly returns.
Or, if you put your statistician’s hat on, you might rather call it the Expected Value, instead of average. Yes, you’re a fancy statistician reading my blog now!
One thing to notice is that the Expected Value of Asset B (2.6%) is higher than that of Asset A (0.9%). We already expected that, given that Asset B grew more over the 10-year period we examined.
But the second thing to notice: Asset B fluctuates more than Asset A.
See how the blue line is more stable over time, while the red line keeps swinging up and down. These swings are what made it hard to predict its return. Too many ups and downs are what we call risk in our day-to-day life. And one obvious way to measure swings is our old friend Variance, or its evil cousin, Standard Deviation.
Our data confirms this too: The standard deviation of the risky asset (0.085) is higher than that of none risky one (0.014).
In an ideal world, we would love to have assets with high returns and low risk. The return tells us how much our money will grow, and the risk tells us how certain we are of this growth.
This brings us to our third question
How do we combine assets to reduce their overall risk?
Excuse my Python, but Python is the new Math, and ChatGPT is the new Python.
So let’s create two assets with equal return and equal risk, combine them, and see what will happen:
import numpy as np
stock_1 = np.random.normal(loc=0.10, scale=0.5, size=10000)
stock_2 = np.random.normal(loc=0.10, scale=0.5, size=10000)
Here we have two assets, we monitor their return over 10,000 years. For the sake of argument, let’s pretend that caveman had stock exchange. The return for both assets have Expected Value of 10% and a Standard Deviation of 50%.
Now let’s combine them both in one portfolio with equal weights, and measure the return and risk of this portfolio:
def stats(*stock1):
portfolio = np.array(stock1).sum(axis=0) / len(stock1)
print(f"Expected Value: {portfolio.mean():.1%}, Standard Deviation: {portfolio.std():.1%}")
stats(stock_1, stock_2)
# This will give us the following result:
# Expected Value: 10%, Standard Deviation: 35%
Tada! The Expected Value of the portfolio is the same as that of the individual assets, 10%. Expected!
But the Standard Deviation of the portfolio is 35%, compared to the 50% of the individual assets.
Magic! What about 100 stocks then?
stats(*[
np.random.normal(loc=0.10, scale=0.5, size=10000)
for _ in range(100)
])
# This will give us the following result:
# Expected Value: 10%, Standard Deviation: 5%
Just by making a portfolio of multiple assets, you kept the same return while significantly reducing your risk (measured in standard deviation).
I said Python is the new Math, but Python will only take us so far if we don’t pay attention to the math. I will keep the math simple, I promise!
Don’t skip the math, trust me
You need to get the math for two reason:
- You need to estimate the reduction in risk you’ll get
- You need to know when this magic stops working
The first one is easy, you can even approximate it with code.
Run for multiple portfolio sizes, plot the results and try to come up with the relation between the number of stocks in a portfolio and risk.
But the second reason is the one that might hurt you if you don’t pay attention to the math.
Let’s skip the derivations, but this is the formula for the portfolio’s standard deviation in relation to that of the individuals assets:
In the above equation, the weights of the two assets in the portfolio are w1 and w2, the standard deviation of the individual assets are σ1 and σ2. And ρ12 is the correlation coefficient between the returns of asset 1 and asset 2.
To simplify, we assumed the same weight of 50% for both assets, and the same standard deviation (σ).
This gives us the following equation:
Of all the terms in this equation, you need to pay special attention to the correlation coefficient (ρ12).
When the two assets are perfectly correlated, ρ12 will be 1, and when they are yin-yang, ρ12 will be -1, and when uncorrelated it will be zero.
Here is the effect of ρ12 on the portfolio’s standard deviation.
When we our example assets, because they were random, they were not correlated at all, i.e. ρ12 = 0.
Then for the two assets, with standard deviation of 50%, the portfolio’s standard deviation was the square root of 2 divided by 4, i.e. 35%.
Uncorrelated assets are good.
But how about positively or negatively correlated assets?
As you can see from the table above, your best case scenario is when your assets are negatively correlated, with ρ12 = -1, your risk is zero!
However, when they are positively correlated, with ρ12 = 1 your portfolio’s risk will be the same as that of its individual assets.
This brings us to the obvious conclusion:
Diversification works, and the math proves it.
However, diversification only works if your portfolio is really diverse.
If you buy stocks that moves together, your diversification is just a pseudo-diversification.
Have you enjoyed reading this post?
Maybe you will also enjoy the following ones: