Eric Zivot
Monday, May 18, 2015
options(digits=3, width=70)
library(IntroCompFinR)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
##
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(PerformanceAnalytics)
##
## Attaching package: 'PerformanceAnalytics'
##
## The following object is masked from 'package:graphics':
##
## legend
Hypothetical asset return data. Asset A (Amazon) is a high return and high risk asset. Asset B (Boeing) is a low return and low risk asset. Data is calibrated to reflect a yearly investment horizon.
mu.A = 0.175
sig.A = 0.258
sig2.A = sig.A^2
mu.B = 0.055
sig.B = 0.115
sig2.B = sig.B^2
rho.AB = -0.164
sig.AB = rho.AB*sig.A*sig.B
x.A = 0.5
x.B = 0.5
mu.p1 = x.A*mu.A + x.B*mu.B
sig2.p1 = x.A^2 * sig2.A + x.B^2 * sig2.B + 2*x.A*x.B*sig.AB
sig.p1 = sqrt(sig2.p1)
mu.p1
## [1] 0.115
sig2.p1
## [1] 0.0175
sig.p1
## [1] 0.132
Portfolio mean return is half-way between asset mean returns, but portfolio volatility is less than half-way between asset volatilities.
Here, a short sale is selling an asset you don’t own (a type of leverage) and taking the proceeds and buying more of the other asset. The short-sold asset has a negative weight, and the other asset has a weight greater than one.
x.A = 1.5
x.B = -0.5
mu.p2 = x.A*mu.A + x.B*mu.B
sig2.p2 = x.A^2 * sig2.A + x.B^2 * sig2.B + 2*x.A*x.B*sig.AB
sig.p2 = sqrt(sig2.p2)
mu.p2
## [1] 0.235
sig2.p2
## [1] 0.16
sig.p2
## [1] 0.4
Notice that short selling (leverage) greatly increases the risk of the portfolio.
# equally weighted portfolio
x.A = 0.5
x.B = 0.5
mu.p1 = x.A*mu.A + x.B*mu.B
sig2.p1 = x.A^2 * sig2.A + x.B^2 * sig2.B + 2*x.A*x.B*sig.AB
sig.p1 = sqrt(sig2.p1)
# Asset VaR
w0 = 100000
VaR.A = (mu.A + sig.A*qnorm(0.05))*w0
VaR.A
## [1] -24937
VaR.B = (mu.B + sig.B*qnorm(0.05))*w0
VaR.B
## [1] -13416
# portfolio VaR
VaR.p1 = (mu.p1 + sig.p1*qnorm(0.05))*w0
VaR.p1
## [1] -10268
# note: portfolio VaR is not a weighted average of individual asset VaR
x.A*VaR.A + x.B*VaR.B
## [1] -19177
# create portfolios for frontier plot
x.A = seq(from=-0.4, to=1.4, by=0.1)
x.B = 1 - x.A
mu.p = x.A*mu.A + x.B*mu.B
sig2.p = x.A^2 * sig2.A + x.B^2 * sig2.B + 2*x.A*x.B*sig.AB
sig.p = sqrt(sig2.p)
# plot portfolio frontier
cex.val = 2
plot(sig.p, mu.p, type="b", pch=16, cex = cex.val,
ylim=c(0, max(mu.p)), xlim=c(0, max(sig.p)),
xlab=expression(sigma[p]), ylab=expression(mu[p]), cex.lab=cex.val,
col=c(rep("red", 6), "blue", rep("green", 12)))
text(x=sig.A, y=mu.A, labels="Asset A", pos=4, cex = cex.val)
text(x=sig.B, y=mu.B, labels="Asset B", pos=4, cex = cex.val)
text(x=sig.p.min, y=mu.p.min, labels="Global min", pos=2, cex = cex.val)
# compute mininimum variance portfolio weights
xA.min = (sig2.B - sig.AB)/(sig2.A + sig2.B - 2*sig.AB)
xB.min = 1 - xA.min
xA.min
## [1] 0.202
xB.min
## [1] 0.798
# compute expected return and volatility
mu.p.min = xA.min*mu.A + xB.min*mu.B
sig2.p.min = xA.min^2 * sig2.A + xB.min^2 * sig2.B + 2*xA.min*xB.min*sig.AB
sig.p.min = sqrt(sig2.p.min)
mu.p.min
## [1] 0.0793
sig.p.min
## [1] 0.0978
# Risk-free rate
r.f = 0.03
# T-bills + asset A
x.A = seq(from=0, to=1.4, by=0.1)
mu.p.A = r.f + x.A*(mu.A - r.f)
sig.p.A = x.A*sig.A
sharpe.A = (mu.A - r.f)/sig.A
sharpe.A
## [1] 0.562
# T-bills + asset B
x.B = seq(from=0, to=1.4, by=0.1)
mu.p.B = r.f + x.B*(mu.B - r.f)
sig.p.B = x.B*sig.B
sharpe.B = (mu.B - r.f)/sig.B
sharpe.B
## [1] 0.217
Q: Can you find the portfolio of assets A and B that has the highest Sharpe slope?