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 1 of 5

ConceptLesson 4.6.1 in Level 4, Multivariable calculus and optimisation. About 35 minutes.

Utility and mean–variance preferences

Risk aversion as a number

Case study 2.4.5 gave an investor with $100,000 the utility u(w)=ln⁡wu(w) = \ln w, a concave curve that scores each level of wealth ww. A fair coin flip of $20,000 either way was worth $97,979.59 to them for sure: its certainty equivalent.

The gap to $100,000, $2,020.41, is the risk premium. It was close to 12A(w)s2\frac{1}{2}A(w)s^2, which is $2,000 here. The stake is ss, and A(w)=−u′′(w)u′(w)A(w) = -\frac{u''(w)}{u'(w)} is the Arrow–Pratt coefficient.

Portfolios are measured in returns, not dollars. The flip is a return of +20% or −20%: an expected return μ=0\mu = 0 and a volatility σ=0.2\sigma = 0.2. Its certainty-equivalent return is 97,979.59100,000−1=−2.02%\frac{97{,}979.59}{100{,}000} - 1 = -2.02\%, a sure loss just as good as the flip.

Divided by wealth, the premium 12A(w)s2\frac{1}{2}A(w)s^2 becomes 12γσ2\frac{1}{2}\gamma\sigma^2, with σ=sw\sigma = \frac{s}{w} and γ=wA(w)\gamma = wA(w). The number γ\gamma (gamma) is the investor's relative risk aversion. It has no units.

  • For u(w)=ln⁡wu(w) = \ln w, A(w)=1wA(w) = \frac{1}{w}, so γ=1\gamma = 1 at every level of wealth.
  • The power utilities u(w)=w1−γ1−γu(w) = \frac{w^{1-\gamma}}{1-\gamma} give any other γ\gamma, the same at every wealth. The formula divides by 0 at γ=1\gamma = 1, where ln⁡w\ln w takes its place.

The larger γ\gamma, the more risk hurts. γ=0\gamma = 0 gives the straight line u=wu = w, which ignores risk, and γ=−1\gamma = -1 gives w22\frac{w^2}{2}, the convex, risk-seeking curve of case study 2.4.5. Models of investors often use values from 1 to 10.

Rule: Certainty-equivalent return

rCE≈μ−γ2 σ2r_{\text{CE}} \approx \mu - \frac{\gamma}{2}\,\sigma^2

To an investor with relative risk aversion γ\gamma, a risky investment with expected return μ\mu and volatility σ\sigma is worth about the sure return rCEr_{\text{CE}}. The returns and σ2\sigma^2 are over the same period, here a year.

Where it comes from

The rule is lesson 2.7.1's quadratic Taylor copy of uu. Take the flip of ±s\pm s on wealth ww, and call the premium π\pi.

  1. 1

    u(w±s)≈u(w)±u′(w) s+12u′′(w) s2u(w \pm s) \approx u(w) \pm u'(w)\,s + \frac{1}{2}u''(w)\,s^2

  2. 2

    Expected utility ≈u(w)+12u′′(w) s2\approx u(w) + \frac{1}{2}u''(w)\,s^2

  3. 3

    u(w−π)≈u(w)−u′(w) πu(w - \pi) \approx u(w) - u'(w)\,\pi

  4. 4

    π≈12A(w) s2\pi \approx \frac{1}{2}A(w)\,s^2, so πw≈γ2 σ2\frac{\pi}{w} \approx \frac{\gamma}{2}\,\sigma^2

The same cancellation works for any outcomes: the first-order terms average to 0, and the squares average to the variance. If every outcome rises by μ\mu, the certainty equivalent rises by about μ\mu as well, which gives the rule.

How good the copy is

For fair flips of ±σ\pm\sigma, so that μ=0\mu = 0, the exact certainty-equivalent returns and the rule compare like this:

swing σ\sigma0.050.10.20.5
γ=1\gamma = 1, exact−0.001251-0.001251−0.005013-0.005013−0.020204-0.020204−0.133975-0.133975
γ=1\gamma = 1, rule−0.00125-0.00125−0.005-0.005−0.02-0.02−0.125-0.125
γ=4\gamma = 4, exact−0.004981-0.004981−0.019707-0.019707−0.075589-0.075589−0.37763-0.37763
γ=4\gamma = 4, rule−0.005-0.005−0.02-0.02−0.08-0.08−0.5-0.5

Up to swings of about 20% the rule is close. At ±50%\pm 50\% it is far off, because the powers of the step that the copy leaves out are no longer small (lesson 2.7.1).

The other signs of γ\gamma behave as expected. The ±20% flip is worth exactly 0 at γ=0\gamma = 0, and +1.98% to a risk seeker with γ=−1\gamma = -1, against the rule's +2%.

Try it

ce_return averages the power utilities of the outcomes, from wealth 1, and turns the result back into a return with inverse.

The first line is case study 2.4.5's certainty equivalent, the second the ±20% flip for γ=−1\gamma = -1, 0, 1 and 4. The loop is the table.

⌘/Ctrl + Enter runs the cell

Mean–variance utility

Scoring every portfolio by the rule gives the score portfolio theory works with.

Rule: Mean–variance utility

U=μ−γ2 σ2U = \mu - \frac{\gamma}{2}\,\sigma^2

The approximate certainty-equivalent return of a portfolio with expected return μ\mu and volatility σ\sigma: higher is better. It needs only two numbers per portfolio.

Score Level 3's three assets (case study 3.2.5). Their expected returns are μ=(0.06,0.08,0.11)\boldsymbol{\mu} = (0.06, 0.08, 0.11) and their volatilities (0.12,0.18,0.25)(0.12, 0.18, 0.25), in annual decimals.

γ\gammaABCbest
00.060.080.11C
20.04560.04760.0475B
40.03120.0152−0.015-0.015A

At γ=0\gamma = 0 only the expected return counts, so C wins. At γ=4\gamma = 4, C's variance costs 2×0.0625=0.1252 \times 0.0625 = 0.125, more than its whole 11% return.

A and B score the same when B's extra return, 0.02, just pays for its extra variance, 0.0324−0.0144=0.0180.0324 - 0.0144 = 0.018. That is where γ2×0.018=0.02\frac{\gamma}{2} \times 0.018 = 0.02, at γ≈2.2222\gamma \approx 2.2222.

  • γ>0\gamma > 0, risk averse: variance lowers the score.
  • γ=0\gamma = 0, risk neutral: only μ\mu counts.
  • γ<0\gamma < 0, risk seeking: variance raises the score.
  • Large γ\gamma: the variance term dominates, so the least risky choice wins.

What it leaves out

Mean–variance utility sees only μ\mu and σ\sigma. Here are three bets, each with μ=0\mu = 0 and σ=0.2\sigma = 0.2, so each scores −0.02-0.02 for γ=1\gamma = 1 and −0.08-0.08 for γ=4\gamma = 4. Their certainty-equivalent returns differ:

betlog utilityγ=4\gamma = 4
a fair flip: +20% or −20%−0.0202-0.0202−0.0756-0.0756
a rare big gain: +40% with chance 0.2, else −10%−0.0169-0.0169−0.0511-0.0511
a rare big loss: −40% with chance 0.2, else +10%−0.0256-0.0256−0.1316-0.1316

A concave utility minds the rare big loss most. Mean–variance utility treats all three alike, so for lopsided bets, such as selling options, work with the utility itself.

Try it

The loop scores the three assets and names the best; the next line is the γ\gamma at which A and B tie.

Each bet's line prints its mean, volatility and two certainty-equivalent returns. Adding 0.0 turns a -0.0 into 0.0.

⌘/Ctrl + Enter runs the cell

Indifference curves

Every portfolio with the same score U=cU = c lies on one curve, μ=c+γ2σ2\mu = c + \frac{\gamma}{2}\sigma^2. It is called an indifference curve: the investor does not mind which point on it they get. With volatility across and expected return up, it is half a parabola that starts at height cc where σ=0\sigma = 0.

Rule: Indifference curve

μ=c+γ2 σ2\mu = c + \frac{\gamma}{2}\,\sigma^2

The portfolios with mean–variance utility cc. The height at σ=0\sigma = 0 is cc, the certainty-equivalent return, and the slope is γσ\gamma\sigma. A higher curve is better.

Indifference curves for γ=4\gamma = 4 through the three assets, and the best portfolios for γ=4\gamma = 4 and γ=2\gamma = 2. Each best portfolio is where the highest reachable indifference curve touches the frontier.

For γ=4\gamma = 4, A scores c=0.0312c = 0.0312. To be as good as A, an asset with B's volatility of 18% would need μ=0.0312+2×0.182=0.096\mu = 0.0312 + 2 \times 0.18^2 = 0.096, and B offers only 0.08. With C's 25% it would need 0.1562, against C's 0.11.

The slope γσ\gamma\sigma is the extra expected return that makes one more unit of volatility acceptable. At σ=0\sigma = 0 it is 0: a little risk costs almost nothing, because the cost grows like σ2\sigma^2. At σ=0.18\sigma = 0.18 it is 0.72 for γ=4\gamma = 4, so each extra point of volatility must bring 0.72 points of expected return.

A larger γ\gamma gives steeper curves; for γ=0\gamma = 0 they are flat lines.

Try it

A's score for γ=4\gamma = 4 fixes cc. Each line prints a volatility, the expected return the curve asks for there, and the slope γσ\gamma\sigma.

⌘/Ctrl + Enter runs the cell

The best portfolio for a risk aversion γ\gamma

Two assets: a vertex

Put a weight ww in C and 1−w1 - w in A. The expected return μp(w)=0.06+0.05w\mu_p(w) = 0.06 + 0.05w is a straight line in ww. The variance σp2(w)\sigma_p^2(w) is case study 1.2.4's parabola, with σA=0.12\sigma_A = 0.12, σC=0.25\sigma_C = 0.25 and covariance ΣAC=0.1×0.12×0.25=0.003\Sigma_{AC} = 0.1 \times 0.12 \times 0.25 = 0.003.

So U(w)=μp(w)−γ2σp2(w)U(w) = \mu_p(w) - \frac{\gamma}{2}\sigma_p^2(w) is a line minus a parabola that opens upwards: a parabola that opens downwards. For γ=4\gamma = 4:

ww00.250.50.751
μp\mu_p0.060.07250.0850.09750.11
σp2\sigma_p^20.01440.0131310.0207250.0371810.0625
UU0.03120.0462370.043550.023138−0.015-0.015

The top lies between 0.25 and 0.5. For the algebra, multiply out the variance as σp2(w)=aw2−2bw+σA2\sigma_p^2(w) = aw^2 - 2bw + \sigma_A^2, with a=σA2+σC2−2ΣAC=0.0709a = \sigma_A^2 + \sigma_C^2 - 2\Sigma_{AC} = 0.0709 and b=σA2−ΣAC=0.0114b = \sigma_A^2 - \Sigma_{AC} = 0.0114. The slope is U′(w)=(μC−μA)−γ(aw−b)U'(w) = (\mu_C - \mu_A) - \gamma(aw - b), and setting it to 0 (lesson 2.4.1) gives the best weight.

Rule: Best weight, two assets

w∗=ba+μC−μAγ aw^* = \frac{b}{a} + \frac{\mu_C - \mu_A}{\gamma\,a}

The first term is the minimum-variance weight of case study 1.2.4. The second tilts the mix towards the asset with the higher expected return, and less so the more risk averse the investor.

Here ba=0.1608\frac{b}{a} = 0.1608 and the tilt is 0.054×0.0709=0.1763\frac{0.05}{4 \times 0.0709} = 0.1763, so w∗=0.3371w^* = 0.3371: about a third in C. Its score, 0.047313, is well above A's 0.0312 alone. At γ=2\gamma = 2 the tilt doubles and w∗=0.5134w^* = 0.5134; at γ=8\gamma = 8 it halves and w∗=0.2489w^* = 0.2489.

Try it

score returns μp\mu_p, σp2\sigma_p^2 and UU for a weight ww in C. The loop is the table; the next line is aa, bb, ba\frac{b}{a}, the tilt, w∗w^* and its score.

A search over 10,001 weights finds the same top, and the last line is w∗w^* for γ=2\gamma = 2 and 8.

⌘/Ctrl + Enter runs the cell

Three assets: a Lagrange multiplier

With three assets, maximise U(w)=w⊤μ−γ2w⊤ΣwU(\mathbf{w}) = \mathbf{w}^\top\boldsymbol{\mu} - \frac{\gamma}{2}\mathbf{w}^\top\Sigma\mathbf{w} over the weights w\mathbf{w}, fully invested: w⊤1=1\mathbf{w}^\top\mathbf{1} = 1. Lesson 4.5.1's condition is ∇U=λ∇(w⊤1)\nabla U = \lambda\nabla(\mathbf{w}^\top\mathbf{1}). The gradient of w⊤Σw\mathbf{w}^\top\Sigma\mathbf{w} is 2Σw2\Sigma\mathbf{w}, as in case study 4.5.5, so the condition reads

μ−γ Σw=λ 1\boldsymbol{\mu} - \gamma\,\Sigma\mathbf{w} = \lambda\,\mathbf{1}

Entry ii says μi−γ(Σw)i=λ\mu_i - \gamma(\Sigma\mathbf{w})_i = \lambda, and case study 3.2.5 showed that (Σw)i(\Sigma\mathbf{w})_i is asset ii's covariance with the portfolio. So at the best portfolio, every asset's expected return minus γ\gamma times its covariance with the portfolio is the same number λ\lambda. Otherwise moving a little money into the asset with the higher value would raise UU.

With the budget w⊤1=1\mathbf{w}^\top\mathbf{1} = 1, this is a linear system of four equations in w\mathbf{w} and λ\lambda (lesson 3.3.1):

(γΣ11⊤0)(wλ)=(μ1)\begin{pmatrix} \gamma\Sigma & \mathbf{1} \\ \mathbf{1}^\top & 0 \end{pmatrix} \begin{pmatrix} \mathbf{w} \\ \lambda \end{pmatrix} = \begin{pmatrix} \boldsymbol{\mu} \\ 1 \end{pmatrix}

For γ=4\gamma = 4 the solution is w=(0.5659,0.1582,0.2759)\mathbf{w} = (0.5659, 0.1582, 0.2759) with λ=0.02\lambda = 0.02. The portfolio expects 7.7% with a volatility of 11.93%, a score of 4.85%. Case study 3.2.5's 50/30/20 mix has almost the same volatility, 11.94%, but expects only 7.6%.

The best portfolio lies on the frontier of case study 4.5.5: no fully invested portfolio with the same expected return has less risk. In the second picture of the figure above, it is where the highest indifference curve touches the frontier.

Try it

best builds the 4×44 \times 4 system and solves it. The first line prints w\mathbf{w}, λ\lambda and μ−4Σw\boldsymbol{\mu} - 4\Sigma\mathbf{w}, whose three entries all equal λ\lambda.

The last line gives the expected return, the volatility and the score.

⌘/Ctrl + Enter runs the cell

The answer for every γ\gamma

Solving the system with letters in place of numbers gives one formula for every investor.

Rule: Best fully invested portfolio

w(γ)=wmv+1γ zz=Σ−1μ−(1⊤Σ−1μ) wmv\begin{gathered} \mathbf{w}(\gamma) = \mathbf{w}_{\text{mv}} + \frac{1}{\gamma}\,\mathbf{z} \\[4pt] \mathbf{z} = \Sigma^{-1}\boldsymbol{\mu} - (\mathbf{1}^\top\Sigma^{-1}\boldsymbol{\mu})\,\mathbf{w}_{\text{mv}} \end{gathered}

wmv=Σ−111⊤Σ−11\mathbf{w}_{\text{mv}} = \frac{\Sigma^{-1}\mathbf{1}}{\mathbf{1}^\top\Sigma^{-1}\mathbf{1}} is the minimum-variance portfolio of case study 4.5.5. The entries of the tilt z\mathbf{z} add up to 0, so it only moves money between assets, by an amount proportional to 1γ\frac{1}{\gamma}.

It is the two-asset rule again: the minimum-variance portfolio plus a tilt towards return. Here wmv=(0.7465,0.1511,0.1023)\mathbf{w}_{\text{mv}} = (0.7465, 0.1511, 0.1023) and z=(−0.7227,0.0285,0.6942)\mathbf{z} = (-0.7227, 0.0285, 0.6942), so the tilt moves money from A to C.

γ\gammawAw_AwBw_BwCw_Cμp\mu_pσp\sigma_p
20.38520.16540.44940.08580.1444
40.56590.15820.27590.0770.1193
80.65620.15470.18910.07250.1122

As γ\gamma grows the tilt vanishes, and the best portfolio slides down the frontier to the minimum-variance portfolio. A small γ\gamma means a large tilt: below γ≈0.9681\gamma \approx 0.9681 the weight in A turns negative, a short sale.

Lesson 4.6.2 adds a risk-free asset. The budget constraint then disappears, and every investor holds the same mix of risky assets.

Try it

np.linalg.solve(Sigma, ones) is Σ−11\Sigma^{-1}\mathbf{1}, found without forming the inverse. The loop solves the system for three values of γ\gamma and checks the formula; the last line is the γ\gamma at which wAw_A reaches 0.

⌘/Ctrl + Enter runs the cell

Common mistakes

  1. γ\gamma multiplies the variance, not the volatility. For B with γ=4\gamma = 4, U=0.08−2×0.182=0.0152U = 0.08 - 2 \times 0.18^2 = 0.0152, not 0.08−2×0.180.08 - 2 \times 0.18.
  2. Keep one unit and one period. In percent, B would score 8−2×182=−6408 - 2 \times 18^2 = -640, because σ2\sigma^2 is then in squared percent. Use annual decimals for μ\mu and σ\sigma alike.
  3. The rule copies small risks. For swings of 50%, or for lopsided bets, the certainty equivalent can be far from μ−γ2σ2\mu - \frac{\gamma}{2}\sigma^2.
  4. Mind the sign of γ\gamma. Positive is risk averse, zero ignores risk, negative seeks it.
  5. Higher curves are better. An indifference curve's height at σ=0\sigma = 0 is its certainty-equivalent return.
  6. The best portfolio depends on γ\gamma. The minimum-variance portfolio is best only as γ\gamma grows without limit. At γ=4\gamma = 4 the best mix holds 27.59% in C, not 10.23%.

Utility and mean–variance preferences

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

  • Relative risk aversion γ=wA(w)=−w u′′(w)u′(w)\gamma = wA(w) = -\frac{w\,u''(w)}{u'(w)} has no units: 1 for ln⁡w\ln w, and γ\gamma for the power utility w1−γ1−γ\frac{w^{1-\gamma}}{1-\gamma}. Zero is risk neutral, negative is risk seeking.
  • The certainty-equivalent return is about μ−γ2σ2\mu - \frac{\gamma}{2}\sigma^2, from the quadratic Taylor copy of uu. It is close for small swings and poor for large or lopsided ones.
  • Mean–variance utility U=μ−γ2σ2U = \mu - \frac{\gamma}{2}\sigma^2 ranks portfolios by μ\mu and σ\sigma alone; the ranking depends on γ\gamma.
  • Indifference curves μ=c+γ2σ2\mu = c + \frac{\gamma}{2}\sigma^2 start at the certainty-equivalent return cc and have slope γσ\gamma\sigma.
  • Two assets: w∗=ba+μC−μAγaw^* = \frac{b}{a} + \frac{\mu_C - \mu_A}{\gamma a}. Three or more: μ−γΣw=λ1\boldsymbol{\mu} - \gamma\Sigma\mathbf{w} = \lambda\mathbf{1}, solved as a linear system, giving w(γ)=wmv+1γz\mathbf{w}(\gamma) = \mathbf{w}_{\text{mv}} + \frac{1}{\gamma}\mathbf{z} on the frontier.

Free further reading

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