Introduction To Computational Finance and Financial Econometrics
Introduction To Computational Finance and Financial Econometrics
Eric Zivot
Spring 2015
cov(Ri , Rj ) = σij
Portfolio “x”:
xA + xB + xC = 1
Portfolio return:
Rp,x = xA RA + xB RB + xC RC .
µC 0.0285
σAC σBC 2
σC 0.0011 0.0026 (0.1411)2
1
RA µA
R = RB , µ = µB , 1 = 1
RC µC 1
2
xA σA σAB σAC
x = xB , Σ = σAB σB2 σBC
xC σAC σBC 2
σC
Portfolio weights sum to 1:
1
x 0 1 = ( xA xB xC ) 1
= x1 + x2 + x3 = 1
RA
Rp,x = x0 R = ( xA xB xC ) RB
RC
= xA RA + xB RB + xC RC
µC
= x A µA + x B µB + x C µC
R formula:
t(x.vec)%*%mu.vec
crossprod(x.vec, mu.vec)
Excel formula:
MMULT(transpose(xvec),muvec)
<ctrl>-<shift>-<enter>
2
σp,x = x0 Σx
2
σA σAB σAC xA
= ( xA xB xC ) σAB σB2 σBC xB
σAC σBC 2
σC xC
= x2A σA
2
+ x2B σB
2
+ x2C σC
2
Portfolio distribution:
R formulas:
t(x.vec)%*%sigma.mat%*%x.vec
Excel formulas:
MMULT(TRANSPOSE(xvec),MMULT(sigma,xvec))
MMULT(MMULT(TRANSPOSE(xvec),sigma),xvec)
<ctrl>-<shift>-<enter>
xC yC
x0 1 = 1, y0 1 = 1
Portfolio returns:
Rp,x = x0 R
Rp,y = y0 R
Covariance:
cov(Rp,x , Rp,y ) = x0 Σy
= y0 Σx
Eric Zivot (Copyright © 2015) Portfolio Theory 11 / 54
Computational tools
R formula:
t(x.vec)%*%sigma.mat%*%y.vec
Excel formula:
MMULT(TRANSPOSE(xvec),MMULT(sigma,yvec))
MMULT(TRANSPOSE(yvec),MMULT(sigma,xvec))
<ctrl>-<shift>-<enter>
∂ 0
∂x1 x Ax
∂ 0
x Ax =
.. = 2Ax.
(2)
∂x .
n×1 ∂ 0
∂xn x Ax
min 2
σp,m = m0 Σm s.t. m0 1 = 1
mA ,mB ,mC
L(m, λ) = m0 Σm+λ(m0 1 − 1)
∂L(m, λ) ∂m0 Σm ∂
0 = = + λ(m0 1 − 1) = 2 · Σm+λ1
(3×1) ∂m ∂m ∂m
∂L(m, λ) ∂m0 Σm ∂
0 = = + λ(m0 1 − 1) = m0 1 − 1
(1×1) ∂λ ∂λ ∂λ
A m zm = b
where,
! ! !
2Σ 1 m 0
Am = , zm = and b = .
10 0 λ 1
zm = A−1
m b.
∂L(m, λ)
0 = = 2 · Σm+λ · 1,
(3×1) ∂m
∂L(m, λ)
0 = = m0 1 − 1.
(1×1) ∂λ
Next, multiply both sides by 10 and use second equation to solve for λ:
1
1 = 10 m = − · λ10 Σ−1 1
2
1
⇒ λ = −2 · .
10 Σ−1 1
Finally, substitute the value for λ in the equation for m:
1 1
m = − (−2) 0 −1 Σ−1 1
2 1Σ 1
Σ−1 1
= .
10 Σ−1 1
Problem 1: find portfolio x that has the highest expected return for a
given level of risk as measured by portfolio variance.
2
σp,x = x0 Σx = σp0 = target risk
x0 1 = 1
min 2
σp,x = x0 Σx s.t.
xA ,xB ,xC
x0 1 = 1
∂L(x, λ1 , λ2 )
0 = = x0 µ − µp,0 ,
(1×1) ∂λ1
∂L(x, λ1 , λ2 )
0 = = x0 1 − 1.
(1×1) ∂λ2
2Σ µ 1
x 0
=
0 0 λ1 µp,0
0
µ
10 0 0 λ2 1
or,
Ax zx = b0
where,
2Σ µ 1
x 0
Ax = µ 0 0 , zx = λ1 and b0 = µp,0
0
10 0 0 λ2 1
zx = A−1
x b0 .
µp,x = x0 µ = µM SF T = 0.0427
x0 1 = 1
For SBUX, we solve:
min σp,x
2
= y0 Σy s.t.
yA ,yB ,yC
y0 1 = 1
Eric Zivot (Copyright © 2015) Portfolio Theory 27 / 54
Example cont.
0.8275 0.5194
xmsf t ymsf t
x = xnord = −0.0908 , y = ynord = 0.2732
Also,
min σp,x
2
= x0 Σx s.t.
x
µp,x = x0 µ = µ0p
x0 1 = 1
min σp,y
2
= y0 Σy s.t.
y
y0 1 = 1
z = α · x + (1 − α) · y
= α2 σp,x
2
+ (1 − α)2 σp,y
2
+ 2α(1 − α)σx,y
z = α · x + (1 − α) · y
xA yA
= α · xB + (1 − α) yB
xC yC
αxA + (1 − α)yA
zA
= αxB + (1 − α)yB = zB
αxC + (1 − α)yC zC
Let x denote the efficient portfolio with the same mean as MSFT, y
denote the efficient portfolio with the same mean as SBUX, and let
α = 0.5. Then,
z = α · x + (1 − α) · y
0.82745 0.5194
0.26329 0.2075
! ! ! !
(0.5)(0.82745) (0.5)(0.5194) 0.6734 zA
= (0.5)(−0.09075) + (0.5)(0.2732) = 0.0912 = zB .
(0.5)(0.26329) (0.5)(0.2075) 0.2354 zC
0.0427
0.0285
= 0.00641
to solve for α:
0.05 − µp,y 0.05 − 0.0285
α= = = 1.514
µp,x − µp,y 0.0427 − 0.0285
z = α · x + (1 − α) · y
min σp,m
2
= m0 Σm s.t. m0 1 = 1
m
min σp,x
2
= x0 Σx s.t.
x
x0 1 = 1
z = α · m + (1 − α) · x
σm,x = m0 Σx
subject to,
t0 1 = 1
In matrix notation,
t0 µ − rf
Sharpe’s ratio =
(t0 Σt)1/2
∂L(t, λ) 1
0 = = µ(t0 Σt)− 2 − t0 µ − rf (t0 Σt)−3/2 Σt + λ1
(3×1) ∂t
∂L(t, λ)
0 = = t0 1 − 1 = 0
(1×1) ∂λ
After much tedious algebra, it can be shown that the solution for t is:
Σ−1 (µ − rf · 1)
t=
10 Σ−1 (µ − rf · 1)
If the risk free rate, rf , is less than the expected return on the
global minimum variance portfolio, µg min , then the tangency
portfolio has a positive Sharpe slope
If the risk free rate, rf , is equal to the expected return on the
global minimum variance portfolio, µg min , then the tangency
portfolio is not defined
If the risk free rate, rf , is greater than the expected return on the
global minimum variance portfolio, µg min , then the tangency
portfolio has a negative Sharpe slope
xt + xf = 1 ⇒ xf = 1 − xt
Example: Find efficient portfolio with target risk (SD) equal to 0.02
Solve,
0.02
⇒ xt = = 0.1792
0.1116
xf = 1 − xt = 0.8208
Also,
Also,
VaRα = W0 qαR
W0 = initial investment
α = loss probability
µp,x = x0 µ
1/2
σp,x = x0 Σx
µSBUX = 0.0285
µep = rf + xt (µp,t − rf )
rf = 0.005
Solve,
0.0285 − .005
xt = = 0.501
0.05186 − .005
xf = 1 − 0.501 = 0.499
Note:
SBUX
q.05 = µSBUX + σSBUX · (−1.645)
= −0.203
e
q.05 = µep + σpe · (−1.645)
− 0.063
Then,
VaRSBU
.05
X
= $100, 000 · q.05
SBUX
faculty.washington.edu/ezivot/