SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons
      1. 4.6.1 Utility and mean–variance preferencesConcept · 35 min
      2. 4.6.2 The tangency portfolio and the Sharpe ratioConcept · 30 min
      3. 4.6.3 The capital asset pricing modelConcept · 30 min
      4. 4.6.4 Practice set: portfolio theoryPractice set · 25 min
      5. 4.6.5 Case study: the tangency portfolio from dataCase study · 35 min

Level 4, Multivariable calculus and optimisation 4.6 Portfolio theory Lesson 2 of 5

ConceptLesson 4.6.2 in Level 4, Multivariable calculus and optimisation. About 30 minutes.

The tangency portfolio and the Sharpe ratio

A risk-free asset

A risk-free asset pays a return rfr_f known in advance, such as a government bill held to maturity (case study 1.2.4). Its volatility is 0, and it has no covariance with anything. Here rf=0.03r_f = 0.03 a year, a simple return like the assets' μ\boldsymbol{\mu}.

Take a risky portfolio P, with expected return μP\mu_P and volatility σP\sigma_P. Put a fraction tt of your money in P and the rest, 1−t1 - t, in the bill.

The expected return is the weighted average (1−t)rf+tμP(1 - t)r_f + t\mu_P. For the variance, add the bill to case study 3.2.5's covariance matrix as a row and column of zeros: w⊤Σw\mathbf{w}^\top\Sigma\mathbf{w} then leaves only t2σP2t^2\sigma_P^2.

Rule: Mixing with the risk-free asset

μ=rf+t (μP−rf)σ=∣t∣ σP\begin{gathered} \mu = r_f + t\,(\mu_P - r_f) \\[4pt] \sigma = \lvert t \rvert\,\sigma_P \end{gathered}

For t≥0t \ge 0 both are straight lines in tt, so the mixes lie on a straight line from the bill, at (0,rf)(0, r_f), through P. A tt above 1 means borrowing at rfr_f to hold more than 100% in P.

Take P to be asset C, with μC=0.11\mu_C = 0.11 and σC=0.25\sigma_C = 0.25:

tt−0.5-0.500.511.5
μ\mu−0.01-0.010.030.070.110.15
σ\sigma0.12500.1250.250.375

Half in C and half in the bill expects 7% with 12.5% volatility. With t=1.5t = 1.5 the investor borrows half their capital at 3%: leverage, more return and more risk.

With t=−0.5t = -0.5 they sell C short and put the proceeds in the bill. The volatility is 12.5% again, but the expected return is −1%-1\%: the line folds back downwards.

Try it

The loop is the table: the expected return and volatility of tt in C and 1−t1 - t in the bill. abs(t) keeps the volatility positive for a short position.

⌘/Ctrl + Enter runs the cell

The Sharpe ratio

The slope of that line is the extra expected return each unit of volatility brings. Funds report it widely.

Rule: Sharpe ratio

SP=μP−rfσPS_P = \frac{\mu_P - r_f}{\sigma_P}

The excess return μP−rf\mu_P - r_f, earned for taking risk, per unit of volatility. With annual μP\mu_P, rfr_f and σP\sigma_P it is an annual ratio of two returns, so it has no units.

With rf=0.03r_f = 0.03, asset A has S=0.030.12=0.25S = \frac{0.03}{0.12} = 0.25, B has 0.2778 and C has 0.32. Case study 3.2.5's 50/30/20 mix has 0.3852, and the minimum-variance portfolio of case study 4.5.5 has 0.3476.

  • Leverage does not change it. For t>0t > 0, every mix of P with the bill has P's Sharpe ratio. The excess return and the volatility both scale by tt; for t<0t < 0 the ratio flips sign.
  • Signs. SPS_P is negative when μP<rf\mu_P < r_f: the portfolio pays less than the bill and takes risk too. It is 0 when μP=rf\mu_P = r_f, and the bill itself, with σ=0\sigma = 0, has none.
  • The period matters. Over a month the mean is about 112\frac{1}{12} of the annual one and the volatility 112\frac{1}{\sqrt{12}} (case study 3.2.5). So a monthly Sharpe ratio is the annual one divided by 12\sqrt{12}: C's 0.32 a year is 0.0924 a month.

At any volatility, a steeper line from the bill reaches a higher expected return. So the best risky portfolio to mix with the bill is the one with the highest Sharpe ratio.

Each asset mixed with the bill traces a line from 3% through the asset, with its Sharpe ratio as slope. The steepest line that still reaches a portfolio touches the frontier at the tangency portfolio.

Try it

sharpe takes weights summing to 1. The cell prints the Sharpe ratios of A, B and C, the 50/30/20 mix and the minimum-variance portfolio.

Then C mixed with the bill at t=0.5t = 0.5 and t=2t = 2: the ratio stays 0.32. The last line is C's monthly ratio, worked out both ways.

⌘/Ctrl + Enter runs the cell

The tangency portfolio

Two assets: a table

Mix A and C, with a weight ww in C, and compute the Sharpe ratio of each mix:

ww00.20.40.60.81
Sharpe ratio0.250.35530.38780.37040.34350.32

The ratio climbs above both assets' and peaks near w=0.4w = 0.4. The excess return moves in a straight line between the two assets. The volatility of a mix stays below the straight line between theirs: diversification (case study 1.2.4).

The algebra: the best investor with a bill

Lesson 4.6.1's investor can now hold the bill too.

Write x\mathbf{x} for the amounts in the risky assets, as fractions of capital. They need not add up to 1, because the bill holds the rest, 1−x⊤11 - \mathbf{x}^\top\mathbf{1}. The expected return is rf+x⊤(μ−rf1)r_f + \mathbf{x}^\top(\boldsymbol{\mu} - r_f\mathbf{1}) and the variance x⊤Σx\mathbf{x}^\top\Sigma\mathbf{x}, so

U(x)=rf+x⊤(μ−rf1)−γ2 x⊤Σx\begin{aligned} U(\mathbf{x}) = {} & r_f + \mathbf{x}^\top(\boldsymbol{\mu} - r_f\mathbf{1}) \\ & - \frac{\gamma}{2}\,\mathbf{x}^\top\Sigma\mathbf{x} \end{aligned}

There is no constraint left. Maximising UU is minimising −U-U, which is lesson 4.4.1's quadratic 12x⊤Ax−b⊤x\frac{1}{2}\mathbf{x}^\top A\mathbf{x} - \mathbf{b}^\top\mathbf{x}, plus a constant, with A=γΣA = \gamma\Sigma and b=μ−rf1\mathbf{b} = \boldsymbol{\mu} - r_f\mathbf{1}.

Its minimum solves Ax=bA\mathbf{x} = \mathbf{b}, so x=1γΣ−1(μ−rf1)\mathbf{x} = \frac{1}{\gamma}\Sigma^{-1}(\boldsymbol{\mu} - r_f\mathbf{1}). It is the one best point, because Σ\Sigma is positive definite (lesson 3.7.1).

The direction Σ−1(μ−rf1)\Sigma^{-1}(\boldsymbol{\mu} - r_f\mathbf{1}) is the same for every γ\gamma: only the amount changes. Scaled so its entries add up to 1, it is a portfolio of risky assets alone.

Rule: Tangency portfolio

wT=Σ−1(μ−rf1)kk=1⊤Σ−1(μ−rf1)\begin{gathered} \mathbf{w}_T = \frac{\Sigma^{-1}(\boldsymbol{\mu} - r_f\mathbf{1})}{k} \\[4pt] k = \mathbf{1}^\top\Sigma^{-1}(\boldsymbol{\mu} - r_f\mathbf{1}) \end{gathered}

The risky portfolio with the highest Sharpe ratio, where the line from the bill touches the frontier. Its Sharpe ratio STS_T has ST2=(μ−rf1)⊤Σ−1(μ−rf1)S_T^2 = (\boldsymbol{\mu} - r_f\mathbf{1})^\top\Sigma^{-1}(\boldsymbol{\mu} - r_f\mathbf{1}). It needs k>0k > 0.

For A and C, Σ−1(μ−rf1)=(1.835,1.1919)\Sigma^{-1}(\boldsymbol{\mu} - r_f\mathbf{1}) = (1.835, 1.1919), which adds up to 3.0269. So wT=(0.6062,0.3938)\mathbf{w}_T = (0.6062, 0.3938): 39.38% in C, with a Sharpe ratio of 0.3878, the peak of the table.

For all three assets, Σ−1(μ−rf1)=(1.6428,0.5074,1.0185)\Sigma^{-1}(\boldsymbol{\mu} - r_f\mathbf{1}) = (1.6428, 0.5074, 1.0185) and k=3.1687k = 3.1687:

wT=(0.5185,0.1601,0.3214)\mathbf{w}_T = (0.5185, 0.1601, 0.3214)

It expects 7.93% with a volatility of 12.47%, a Sharpe ratio of 0.3951, and (μ−rf1)⊤Σ−1(μ−rf1)\sqrt{(\boldsymbol{\mu} - r_f\mathbf{1})^\top\Sigma^{-1}(\boldsymbol{\mu} - r_f\mathbf{1})} gives the same 0.3951. Among 100,000 random portfolios, none does better.

Try it

The first loop is the table for A and C. Then the formula for two assets, np.linalg.solve(S2, mu2 - rf), which is Σ−1(μ−rf1)\Sigma^{-1}(\boldsymbol{\mu} - r_f\mathbf{1}).

⌘/Ctrl + Enter runs the cell

Try it

The same for the three assets. The second line prints μT\mu_T, σT\sigma_T, STS_T and the square root of (μ−rf1)⊤Σ−1(μ−rf1)(\boldsymbol{\mu} - r_f\mathbf{1})^\top\Sigma^{-1}(\boldsymbol{\mu} - r_f\mathbf{1}).

The last lines draw 100,000 random portfolios, short sales allowed, with weights adding up to 1. The best of their Sharpe ratios is compared with STS_T.

⌘/Ctrl + Enter runs the cell

When there is no tangency portfolio

The scaling divides by kk. In case study 4.5.5's letters, k=k2−rfk1=k1(μmv−rf)k = k_2 - r_fk_1 = k_1(\mu_{\text{mv}} - r_f).

Here k1=1⊤Σ−11=83.0812k_1 = \mathbf{1}^\top\Sigma^{-1}\mathbf{1} = 83.0812, and μmv=k2k1=6.81%\mu_{\text{mv}} = \frac{k_2}{k_1} = 6.81\% is the minimum-variance portfolio's expected return. So k>0k > 0 exactly when the risk-free rate is below μmv\mu_{\text{mv}}.

rfr_fkkwT\mathbf{w}_TμT\mu_TσT\sigma_TSTS_T
05.6611(0.6189,0.1562,0.225)(0.6189, 0.1562, 0.225)0.07440.11460.6489
0.023.9995(0.5658,0.1582,0.2759)(0.5658, 0.1582, 0.2759)0.0770.11930.4773
0.033.1687(0.5185,0.1601,0.3214)(0.5185, 0.1601, 0.3214)0.07930.12470.3951
0.051.5071(0.267,0.17,0.563)(0.267, 0.17, 0.563)0.09150.1660.2502
0.060.6763(−0.3222,0.1933,1.1289)(-0.3222, 0.1933, 1.1289)0.12030.29860.202
0.07−0.1546-0.1546(5.4225,−0.0335,−4.389)(5.4225, -0.0335, -4.389)−0.1601-0.16011.2202−0.1886-0.1886

As rfr_f rises towards 6.81%, the tangency portfolio climbs the frontier and runs away, with ever larger positions.

Above it, no line from the bill touches the upper half of the frontier. The formula still returns weights, but they sit on the lower half and have a negative Sharpe ratio: the worst line, not the best. Code must check k>0k > 0.

At rf=0.02r_f = 0.02 the tangency portfolio is almost lesson 4.6.1's best portfolio for γ=4\gamma = 4, (0.5659,0.1582,0.2759)(0.5659, 0.1582, 0.2759). That portfolio's multiplier was λ=0.02\lambda = 0.02 to four places, and with rf=λr_f = \lambda exactly the two coincide. Every portfolio on the upper frontier is the tangency portfolio for some risk-free rate.

Try it

The loop is the table. The last line is k1=1⊤Σ−11k_1 = \mathbf{1}^\top\Sigma^{-1}\mathbf{1} and μmv\mu_{\text{mv}}, the rate at which kk reaches 0.

⌘/Ctrl + Enter runs the cell

The capital market line and two-fund separation

The line from the bill through the tangency portfolio is the capital market line. Every point on it mixes wT\mathbf{w}_T with the bill. Away from T, each point beats every frontier portfolio of the same volatility.

Rule: Capital market line

μ=rf+ST σt=μT−rfγ σT2\begin{gathered} \mu = r_f + S_T\,\sigma \\[4pt] t = \frac{\mu_T - r_f}{\gamma\,\sigma_T^2} \end{gathered}

The best portfolios when a risk-free asset exists. An investor with risk aversion γ\gamma puts the fraction tt in the tangency portfolio and 1−t1 - t in the bill. Also t=kγt = \frac{k}{\gamma}, the sum of the entries of x\mathbf{x}.

Here μ=0.03+0.3951 σ\mu = 0.03 + 0.3951\,\sigma, and three investors split their money like this:

γ\gammain wT\mathbf{w}_Tin the billμ\muσ\sigmaUU
21.5843−0.5843-0.58430.10810.19760.069
40.79220.20780.0690.09880.0495
80.39610.60390.04950.04940.0398

The investor with γ=2\gamma = 2 borrows 58.43% of their capital at 3%. The one with γ=4\gamma = 4 scored 4.85% in lesson 4.6.1 without a bill, and scores 4.95% with it. Cutting risk with the bill costs less than moving down the frontier.

Two-fund separation: every investor holds the same two funds, the bill and wT\mathbf{w}_T. Only the split depends on γ\gamma. Case study 4.5.5's two-fund theorem built the frontier from two risky portfolios; with a risk-free asset, one of the two funds is the bill.

Try it below. Move the risk-free rate from 0 to 6% and watch the tangency portfolio climb the frontier while its Sharpe ratio falls.

Push it past 6.81%, the minimum-variance return, and the tangency portfolio disappears. The explorer finds it with short sales allowed, as the formula does.

Explore

Every mix of the three assets is a point: its volatility across, its expected return up. Move the target return and read the cheapest mix in risk that earns it. Turn on a risk-free rate to add the tangency portfolio.

0%5%10%15%20%25%30%5%10%ABC

Grey dots are the assets, the open circle the minimum-variance portfolio, the square the tangency portfolio and the dashed line the capital market line.

Frontier portfolio
A 29.9%, B 16.9%, C 53.2%
Return and risk
expected return 9%, volatility 15.99%
Minimum variance
A 74.7%, B 15.1%, C 10.2%: return 6.81%, volatility 10.97%
Tangency portfolio
A 51.8%, B 16%, C 32.1%: return 7.93%, volatility 12.47%, Sharpe ratio 0.395

In practice, borrowing costs more than lending. Then lenders use the tangency portfolio for the lending rate, and borrowers a riskier one, further up the frontier, for the higher borrowing rate. Investors in between hold frontier portfolios and neither lend nor borrow.

Try it

For each γ\gamma, the cell computes x=1γΣ−1(μ−rf1)\mathbf{x} = \frac{1}{\gamma}\Sigma^{-1}(\boldsymbol{\mu} - r_f\mathbf{1}). It prints the amount in risky assets, the bill, the expected return, the volatility and UU, then tt from the formula.

⌘/Ctrl + Enter runs the cell

Lesson 4.6.3 asks what happens if every investor does this: the tangency portfolio becomes the market, and expected returns line up with beta.

Common mistakes

  1. Subtract the risk-free rate. C's Sharpe ratio is 0.11−0.030.25=0.32\frac{0.11 - 0.03}{0.25} = 0.32, not 0.110.25=0.44\frac{0.11}{0.25} = 0.44.
  2. Keep the periods together. Divide an annual Sharpe ratio by 12\sqrt{12} for a monthly one. A monthly mean minus an annual rfr_f is meaningless.
  3. Leverage does not raise the Sharpe ratio. It moves along the line; only a better risky mix makes the line steeper.
  4. Check k>0k > 0 before scaling. With rfr_f above the minimum-variance return, the formula returns the worst portfolio, not the best.
  5. Use the whole matrix. The tangency weights are Σ−1(μ−rf1)\Sigma^{-1}(\boldsymbol{\mu} - r_f\mathbf{1}), scaled. Ranking assets by their own Sharpe ratios ignores the correlations: A has the lowest ratio, 0.25, yet the largest weight, 51.85%.
  6. A negative amount in the bill is borrowing, and a negative weight in an asset is a short sale.

The tangency portfolio and the Sharpe ratio

0 of 12 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
  8. 8.
  9. 9.
  10. 10.
  11. 11.
  12. 12.
How to type answers
  • Powers with ^: x^7, 2^(1/3), a^-2.
  • Multiply with * or by writing side by side: 3x^2, 2(x+1).
  • ln(x) is the natural log, log(x, 2) is log base 2, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for sin²x.
  • Your first answer to each question is saved: it counts towards your score and brings the question back for review.
  • Exact answers like ln(20)/ln(3) are best. Decimals need about 4 significant figures.

Summary card

  • Mixing a risky portfolio with a risk-free asset gives μ=rf+t(μP−rf)\mu = r_f + t(\mu_P - r_f) and σ=∣t∣σP\sigma = \lvert t \rvert\sigma_P: a straight line from (0,rf)(0, r_f). t>1t > 1 is borrowing.
  • The Sharpe ratio μP−rfσP\frac{\mu_P - r_f}{\sigma_P} is that line's slope. Leverage does not change it; a monthly ratio is the annual one over 12\sqrt{12}.
  • The tangency portfolio wT=Σ−1(μ−rf1)k\mathbf{w}_T = \frac{\Sigma^{-1}(\boldsymbol{\mu} - r_f\mathbf{1})}{k} has the highest Sharpe ratio, with ST2=(μ−rf1)⊤Σ−1(μ−rf1)S_T^2 = (\boldsymbol{\mu} - r_f\mathbf{1})^\top\Sigma^{-1}(\boldsymbol{\mu} - r_f\mathbf{1}). It exists only if k>0k > 0, that is rf<μmvr_f < \mu_{\text{mv}}.
  • For the three assets with rf=3%r_f = 3\%: wT=(0.5185,0.1601,0.3214)\mathbf{w}_T = (0.5185, 0.1601, 0.3214), μT=7.93%\mu_T = 7.93\%, σT=12.47%\sigma_T = 12.47\%, ST=0.3951S_T = 0.3951.
  • The capital market line is μ=rf+STσ\mu = r_f + S_T\sigma. Every investor holds the bill and wT\mathbf{w}_T, with t=μT−rfγσT2t = \frac{\mu_T - r_f}{\gamma\sigma_T^2} in wT\mathbf{w}_T: two-fund separation.

Free further reading

Optional. This lesson covers what you need; these add more examples and practice. All are free to read.