# The risk of a portfolio – Calculator and formula

We often say that risk and return are two sides of the same coin. You can’t discuss one without the other. In the previous post, we showed you how to calculate the return on a portfolio of assets. In this post, we explain the formula for portfolio risk. We also offer an easy-to-use portfolio risk calculator.

Learning objectives

• Understand why covariance matters when considering the risk of a portfolio.
• Calculate portfolio risk.

## The formula for portfolio risk

In the previous post, we explained that the portfolio return is simply a weighted average of the returns of assets that constitute the portfolio. And, the weights are simply the investment weights (i.e., the proportions invested in each asset). This led us to the formula for portfolio return RP:

RP = ∑wi Ri

where wi is the investment weight for asset i and Ri is the realized return for asset i. Moreover, we discussed that the variance of returns on a single asset (let’s denote that as σi2 for asset i) is a measure of risk in an earlier post. Could we then calculate the variance of returns on a portfolio σP2 as a weighted average of the variance of assets in that portfolio? In other words, would the following equation be the correct formula for the variance of portfolio returns?

σP2 = ∑wi σi2

The answer is no. When calculating σP2, we need to consider not only the variance of each asset but also the covariance between each pair of assets. Why? It is because the interactions between assets affect σP2. Imagine a portfolio with two assets only. Suppose that when the price of one asset goes up, the price of the other tends to go down. These opposite movements would partially cancel out each other within the portfolio, and, thus, would reduce the volatility of portfolio returns. So, the correct formula for the variance of portfolio returns is

σP2 = ∑wi wj σij

where wi is the investment weight for asset iwj is the investment weight for asset j, and σij is the covariance between assets i and j.

### Important properties of covariance

We need to discuss important properties of covariance before we can give more specific examples of calculating portfolio risk. First, an asset’s covariance with itself is equal to its variance:

σii = σi2

Second, the covariance between asset i and asset j is the same as the covariance between asset j and asset i:

σij = σji

Finally, covariance can take any value between minus infinity and plus infinity. Researchers sometimes use correlation as an alternative way of measuring the strength of the relationship between returns of two assets. It’s because, by definition, correlation takes values between −1 and +1 only. The relation between the correlation coefficient ρij and the covariance is defined as follows:

ρij = σij / (σi σj)

where σi and σj are the standard deviation of returns (i.e., return volatility) of asset i and asset j, respectively. This means that the variance of portfolio returns can also be written as:

σP2 = ∑wi wj ρij σi σj

### A portfolio with two assets

We can now discuss portfolio risk with more specific examples. Let us first consider a portfolio with two assets only. In this case, we have

σP2 = ∑wi wj σij = w1 w1 σ11 + w1 w2 σ12 + w2 w1 σ21 + w2 w2 σ22

This simplifies into:

σP2 = w12 σ12 + w22 σ22 + 2 w1 w2 σ12

Why? It’s because σii = σi2 and σij = σji as we discussed above. So, in a two asset portfolio, σP2 depends on:

• The variance of returns for each asset (σ12 and σ22).
• The covariance between the returns of asset 1 and asset 2 (σ12).
• And, the investment weights (w1 and w2).

Here’s a numerical example. Suppose you invest 20% of your funds in an asset that has a variance of 36 and the remaining 80% in another asset that has a variance of 121. Moreover, the covariance between the returns of these two assets is −33. Then, the variance of returns for your portfolio would be:

σP2 = 0.22 * 362 + 0.82 * 1212 + 2 * 0.2 * 0.8 * (−33) = 68.32

And, the standard deviation of portfolio returns would be:

σP = √(68.32) = 8.27

### A portfolio with three assets

How about the risk of a portfolio with three assets? If we again use the portfolio variance formula, we will get:

σP2 = w12 σ12 + w22 σ22 + w32 σ32 + 2 w1 w2 σ12 + 2 w1 w3 σ13 + 2 w2 w3 σ23

Then, with three assets, σP2 depends on:

• The variance of returns for each asset (σ12, σ22, and σ32).
• The covariance between each pair of assets (σ12, σ13, and σ23).
• And, the investment weights (w1, w2, and w3).

This general structure applies to portfolios with any number of assets. In other words, you always need the variance of returns for each asset, the covariance between each pair of assets, and the investment weights.

## Portfolio risk calculator

##### Instructions

You can use the portfolio risk calculator below to calculate the variance and standard deviation of portfolio returns for portfolios containing up to three assets. Please note the following instructions:

• The calculator allows for both positive investment weights and negative investment weights (i.e., short selling).
• Make sure that investment weights add up to 100% (see the “sum of weights (%)” in the last row of the calculator).
• For Asset 1, enter the variance of Asset 1 (σ12), the covariance between Asset 1 and Asset 2 (σ12), and the covariance between Asset 1 and Asset 3 (σ13).
• For Asset 2, enter the variance of Asset 2 (σ22) and the covariance between Asset 2 and Asset 3 (σ23).
• Finally, for Asset 3, enter the variance of Asset 3 (σ32) only.
• If your portfolio consists of 2 assets only, you can of course still use the calculator by leaving 0s in the fields that you don’t need.

### Wrapping up

While portfolio return is a weighted average of each asset’s return, the variance of portfolio returns is not a weighted average of each asset’s variance of returns. This is because the interactions between pairs of assets, captured by covariances, affect portfolio risk as well. This was recognized by the celebrated economist Harry Markowitz. His pioneering work on the modern portfolio theory led to a share of a Nobel prize in 1990.

##### What is next?

This post is part of our free course on investments. We will make a distinction between efficient portfolios and inefficient portfolios in our next post. This will lead to the concept of an efficient frontier. In the previous post, we explained how to calculate portfolio returns and offered an online calculator.

If you found this post helpful, feel free to share it on social media. Also, if you have any questions or suggestions, you are more than welcome to leave a comment below.