insideout Get Pro

03 · Mean-variance

Free

Portfolio and Risk, lesson 3

Mean-variance

The best mix for a level of risk, by the numbers.

Diversification says mixing helps. This lesson finds the best mix, the one that earns the most above cash for each unit of risk, then works out how much of it to hold. You need the two-asset formula from Diversification and the Sharpe ratio from Risk and return.

By the end, you can:

  1. Find the mix of two assets with the highest Sharpe ratio.
  2. Compute the best weights from excess returns and variances.
  3. Size a position from its excess return, its variance and your risk aversion.

Part 1. The steepest line from cash

Find the mix of two assets with the highest Sharpe ratio.

Asset A averages 8% a year with 18% volatility. Asset B averages 4% with 6%. Their correlation is 0.2, and cash pays 2%. Every mix of A and B has a return and a volatility, so you can draw it as a point. Which mix should you hold?

Example 1.1

Four mixes of A and B

Work out the Sharpe ratio of four mixes: all in B, 25% in A, 50% in A, and all in A. Which is best?

  1. All in B(4% − 2%) / 6% = 0.33

    B on its own.

  2. 25% in A(5% − 2%) / 6.97% = 0.43

    The return is 0.25 × 8% + 0.75 × 4% = 5%. The two-asset formula gives a volatility of √0.00486 = 6.97%.

  3. 50% in A(6% − 2%) / 10.04% = 0.40

    More return, but the volatility grows faster.

  4. All in A(8% − 2%) / 18% = 0.33

    A on its own does no better than B.

Answer25% in A, with a Sharpe ratio of 0.43. Each asset alone manages only 0.33.

Why the Sharpe ratio? Put some money in cash and the rest in a mix, and you land on the line from cash to that mix. Borrow at the cash rate to hold more of it, and you go further along the line. Each line is a menu, and the steepest beats the others at every level of risk.

2%4%6%8%10%0%5%10%15%20%volatilityreturn0.33Sharpe 0.43all B50% Aall A25% Acashborrow to gopast the mix
Figure 1Every mix of A and B, with volatility across and return up. The steepest line from cash touches the curve at 25% in A. Points on that line, with cash or borrowing, beat the curve at every level of risk.

Tangency portfolio and capital allocation line

The mix of risky assets with the highest Sharpe ratio sits where a line from cash just touches the curve of mixes, so it's called the tangency portfolio. The line itself, that mix blended with cash or with borrowing, is the capital allocation line.

return = 2% + 0.43 × volatility

The line past the mix assumes you can borrow at the cash rate. Real borrowing usually costs more, so the line bends down beyond 100% in the mix. Notice too that the answer is a mix: A and B alone tie at 0.33, yet a quarter in A beats both.

Your turn

Cash pays 2%. Mix P of two assets returns 6% with 10% volatility. Mix Q of the same assets returns 5% with 7%. Which should you hold, using cash or borrowing to set the risk?

P: (6% − 2%) / 10% = 0.40. Q: (5% − 2%) / 7% = 0.43. Holding Q and borrowing up to 10% volatility returns 2% + 0.43 × 10% = 6.3%, more than P's 6%. 0.71 and 0.60 forget to take off the cash rate.

Part 2. A recipe for the weights

Compute the best weights from excess returns and variances.

Trying mixes works for two assets. For many, you want a recipe. When the assets are uncorrelated it's short: give each one its excess return divided by its variance, then scale the weights to add up to 1.

Example 2.1

Two uncorrelated assets

A earns 10% above cash with 20% volatility. B earns 5% above cash with 10% volatility. They're uncorrelated. What's the best mix, and its Sharpe ratio?

  1. Raw weight for A0.10 / 0.20² = 2.5

    Excess return over variance. A earns more, but it swings more.

  2. Raw weight for B0.05 / 0.10² = 5

    B's variance is a quarter of A's, so it gets twice A's raw weight.

  3. Scale to add up to 12.5 / 7.5 = ⅓ in A; 5 / 7.5 = ⅔ in B

    Only the proportions matter.

  4. Sharpe ratio of the mix6.67% / 9.43% = 0.707

    Excess return ⅓ × 10% + ⅔ × 5% = 6.67%. Variance (⅓)² × 0.04 + (⅔)² × 0.01 = 0.0089, so volatility 9.43%.

Answer⅓ in A and ⅔ in B, with a Sharpe ratio of 0.707. Each asset alone has 0.5.

Why divide by variance and not volatility? Risk costs in squares: doubling a position doubles its excess return but quadruples its variance. So an asset's weight grows with what it earns and shrinks with its variance. And uncorrelated swings partly cancel, which is why the mix beats both of its parts.

Mean-variance weights

Choosing a portfolio by its expected return and variance alone is mean-variance optimisation. For uncorrelated assets, the best weights are in proportion to excess return over variance. With correlations, the same recipe uses the covariance matrix Σ: weights in proportion to Σ⁻¹(μ − r), read "the inverse of the covariance matrix times the excess returns".

w ∝ (μ − r) / σ²

The Sharpe ratios of uncorrelated assets combine as the square root of the sum of their squares: √(0.5² + 0.5²) = 0.707. So a weaker strategy still helps, as long as its Sharpe ratio is above zero and it's uncorrelated with the rest. Dropping it because it's worse is a common mistake.

Your turn

Two uncorrelated strategies both have 10% volatility. One has a Sharpe ratio of 1.0, the other 0.5. How should you split the money, and what Sharpe ratio does the mix reach?

The excess returns are 10% and 5% and the variances are equal, so the raw weights are 10 and 5: ⅔ and ⅓. The mix's Sharpe ratio is √(1.0² + 0.5²) = 1.118. 1.5 adds the ratios instead of their squares, and 0.75 averages them.

Part 3. How much to hold

Size a position from its excess return, its variance and your risk aversion.

The tangency mix says what to hold. How much depends on you. One way to say how much you dislike risk is a number γ, read "gamma". You score a portfolio as its excess return minus γ / 2 times its variance, and hold the one with the highest score.

Example 3.1

Three sizes of one position

Say the best mix earns 6% above cash, with 20% volatility, and your γ is 3. Score holding 25%, 50% and 75% of your money in it, with the rest in cash. Which is best?

  1. Write the scorew × 0.06 − (3 / 2) × w² × 0.20²

    w is the share in the mix. More w adds return in a straight line, and variance in squares.

  2. Score 25%0.015 − 1.5 × 0.0625 × 0.04 = 0.01125

    An excess return of 1.5%, minus a small penalty.

  3. Score 50%0.030 − 1.5 × 0.25 × 0.04 = 0.015

    The highest of the three.

  4. Score 75%0.045 − 1.5 × 0.5625 × 0.04 = 0.01125

    The penalty now grows faster than the return.

Answer50%, with a score of 0.015. 25% and 75% both score 0.01125.

The return grows in a straight line with w, and the penalty grows with w². So the score rises, peaks and falls. Its top sits where one more slice of the mix adds as much penalty as return: at excess return over γσ², 0.06 / (3 × 0.04) = 50%.

0.0050.0100.01500%25%50%75%100%share of your money in the risky mixscore: return − (γ / 2) × varianceγ = 3: best at 50%γ = 6: best at 25%
Figure 2The score for each share of your money in the mix. With γ = 3 the top is at 50%. Twice as risk-averse, at γ = 6, the top is at 25%: half as much.

Risk aversion and two-fund separation

Risk aversion, γ, is how much variance costs you. The best share in the risky mix is excess return over γ times variance. Everyone holds the same tangency mix, and only the amount differs, with the rest in cash or borrowed. That's two-fund separation: the two funds are the tangency portfolio and cash.

w = (μ − r) / (γσ²) = 0.06 / (3 × 0.04) = 50%

Nothing caps w at 100%. With γ = 1 it comes to 150%: borrow half your money again to hold more of the mix. A common slip is to divide by volatility instead of variance, which gives 10% here. Doubling γ halves the position, but it never changes the mix.

Your turn

An asset earns 4% above cash with 10% volatility. Your risk aversion γ is 5. What share of your money goes in it?

w = 0.04 / (5 × 0.10²) = 0.04 / 0.05 = 80%. 8% divides by the volatility instead of the variance. 400% leaves out γ, and 160% uses γ / 2.

Where you'll meet it

In interviews

"Combine two uncorrelated strategies with Sharpe ratios a and b" comes up in quant research interviews, and the answer is √(a² + b²). So do "why borrow rather than buy the riskier asset?" and the size of a position, excess return over γσ². Work out the weights as excess return over variance before you reach for a matrix.

On the job

Harry Markowitz set out choosing a portfolio by its expected return and variance in "Portfolio Selection" (Journal of Finance, 1952). The recipe is only as good as its inputs, and the expected returns are the hard part. The next lesson is about what happens when they're estimated.

The best mix and how much to hold, in Python
import numpy as np

def best_mix(mu, vol, corr, cash):
    """The risky mix with the highest Sharpe ratio: inverse covariance times excess returns, scaled to add to 1."""
    mu, vol = np.array(mu), np.array(vol)
    cov = np.outer(vol, vol) * np.array(corr)
    raw = np.linalg.solve(cov, mu - cash)
    w = raw / raw.sum()
    return w, (w @ mu - cash) / np.sqrt(w @ cov @ w)

w, sharpe = best_mix([0.08, 0.04], [0.18, 0.06], [[1, 0.2], [0.2, 1]], 0.02)
print(f"A 8% and B 4%, correlation 0.2: A {w[0]:.0%}, B {w[1]:.0%}, Sharpe {sharpe:.2f}")
w, sharpe = best_mix([0.10, 0.05], [0.20, 0.10], np.eye(2), 0.0)
print(f"uncorrelated: A {w[0]:.1%}, B {w[1]:.1%}, Sharpe {sharpe:.3f}")

for gamma in [1, 3, 6]:
    print(f"risk aversion {gamma}: hold {0.06 / (gamma * 0.20**2):.0%} of your money in the mix")

# Output:
# A 8% and B 4%, correlation 0.2: A 25%, B 75%, Sharpe 0.43
# uncorrelated: A 33.3%, B 66.7%, Sharpe 0.707
# risk aversion 1: hold 150% of your money in the mix
# risk aversion 3: hold 50% of your money in the mix
# risk aversion 6: hold 25% of your money in the mix

Check yourself

Three questions from across the lesson. Try each one before you look back.

1

You hold the tangency mix and want more return, accepting more risk. What's the best way to get it?

Borrowing moves you up the steepest line, which beats every point on the curve at the same risk. Shifting towards A moves you along the curve, which is flatter. This assumes you can borrow at the cash rate; when borrowing costs more, the line bends down past 100%.

2

Three uncorrelated strategies each have a Sharpe ratio of 0.5. What's the best Sharpe ratio you can reach by combining them?

Uncorrelated Sharpe ratios combine as the square root of the sum of their squares: √(3 × 0.5²) = 0.866. More independent ideas raise the Sharpe ratio, but only with the square root of how many you have.

3

Two people use the same forecasts. One is twice as risk-averse as the other. How do their portfolios differ?

Both pick the tangency mix, because it's the best risky mix whatever your taste for risk. The amount held is excess return over γσ², so doubling γ halves it, and the rest goes to cash.

What to remember

  1. 1The steepest line from cash

    The best mix of risky assets has the steepest line from cash, the highest Sharpe ratio: 25% in A gives 0.43, where A or B alone gives 0.33.

  2. 2A recipe for the weights

    For uncorrelated assets, weights go in proportion to excess return over variance, and Sharpe ratios combine as √(0.5² + 0.5²) = 0.707.

  3. 3How much to hold

    How much of the mix to hold is excess return over γσ²: 0.06 / (3 × 0.04) = 50%, and twice the risk aversion holds half as much.

Portfolio and Risk overviewSpotted a mistake? Tell us.