=1000
par=50
coupon=10
N=c(4,4.25,4.5,4.78,5,5.25,5.45,5.62,5.75,5.92)/100
r=rep(coupon,10)
CashFlow=CashFlow[N]+par
CashFlow[N]=0.01
sigma=0.01 probability
17 Simulated VaR
17.1 Bonds
Consider a 10 year bond, with par value $1,000, coupon is annual and is $50 and has just been payed. The current yield curve, is \((4,4.25,4.5,4.78,5,5.25,5.45,5.62,5.75,5.92)/100\).
We assume yield curve can only shift up or down, and that the amount of the shift, \(dr\), is distributed as \[ dr\sim N(0,\sigma^2) \] where \(\sigma=0.01\)
The VaR probability is 1%
We can set this up in R as
The price of the bond is given by \[ \sum_{t=1}^N \frac{CashFlow_t}{(1+r)^t} \] Two ways to do this in R
=t(CashFlow) %*% (1/(1+r)^{1:N})
pricesum(CashFlow / (1+r)^{1:N})
We can make \(S\) simulated yield curves as
plot(r,
type='l',
ylim=c(0,0.1),
lwd=2
)=5
Sset.seed(88)
for(i in 1:S){
=r+rnorm(1,mean=0,sd=sigma)
rslines(rs,col="red")
=t(CashFlow) %*% (1/(1+rs)^{1:N})
sim_pricecat(i,price,sim_price,"\n")
}
1 943.0979 959.3902
2 943.0979 898.4358
3 943.0979 793.2705
4 943.0979 1087.002
5 943.0979 911.063
Suppose we own one bond, then our portfolio value is price. Suppose we do \(S=1,000\) simulations.
First, we show you the most obvious way to do the VaR
=1000
S=vector(length=S)
sim_priceset.seed(88)
for(i in 1:S){
=r+rnorm(1,mean=0,sd=sigma)
rs=t(CashFlow) %*% (1/(1+rs)^{1:N})
sim_price[i]
}=-(sort(sim_price)[S*probability]-price)
VaRcat(price,mean(sim_price),VaR,"\n")
943.0979 946.9831 157.4171
so the VaR is 157.4171.
17.2 Simulated VaR with simple and continuous returns
When working with simulations, we can choose if we want to use simple or continuous returns to simulate future prices.
17.2.1 Simple returns
If we want to work with simple returns, we calculate one-day future prices in the following way:
- Simulate one-day return: \(R_{t+1} \sim \mathcal{N}(0,\sigma^2)\)
- Calculate one-day future price: \(P_{t+1} = P_t \times (1+R_{t+1})\)
17.2.2 Continuous returns
If we want to work with continuous returns, we calculate one-day future prices in the following way:
- Simulate one-day return: \(y_{t+1} \sim \mathcal{N}(0,\sigma^2)\)
- Calculate one-day future price: \(P_{t+1} = P_t e^{r(1/365)} \times e^{y_{t+1}} \times e^{-0.5\sigma^2}\)
17.2.3 Comparison for VaR 5%
# Simple returns
= 0.05
p = 1e5
S = 100
P = 0.01
sigma = rnorm(S, 0, sigma^2)
ret = P*(1+ret)
Psim_simple
# VaR 5%
= sort(Psim_simple - P)
Ps_simple *S] Ps_simple[p
# Compound returns
= 0.03 # Assuming risk free rate
r = P*exp(r*(1/365))*exp(ret)*exp(-0.5*sigma^2)
Psim_comp # VaR 5%
= sort(Psim_comp - P)
Ps_comp *S] Ps_comp[p
17.3 Exercise
In section 15.1 we assume the shift in yield curve is parallel. Now suppose the changes in yield curve are different across time. Assume the amount of change follows a normal distribution with mean 0 and \(\sigma=0.01\), generate 10000 simulations to compute the bond price and VaR.
=10000
S=vector(length=S)
sim_priceset.seed(88)
for(i in 1:S){
=r+rnorm(10,mean=0,sd=sigma)
rs=t(CashFlow) %*% (1/(1+rs)^{1:N})
sim_price[i]
}=-(sort(sim_price)[S*probability]-price)
VaRcat(price,mean(sim_price),VaR,"\n")
943.0979 1174.316 -70.66901