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

par=1000
coupon=50
N=10
r=c(4,4.25,4.5,4.78,5,5.25,5.45,5.62,5.75,5.92)/100
CashFlow=rep(coupon,10)
CashFlow[N]=CashFlow[N]+par
sigma=0.01
probability=0.01

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

price=t(CashFlow) %*% (1/(1+r)^{1:N})
sum(CashFlow / (1+r)^{1:N})
943.097907426935

We can make \(S\) simulated yield curves as

plot(r,
    type='l',
    ylim=c(0,0.1),
    lwd=2
)
S=5
set.seed(88)
for(i in 1:S){
    rs=r+rnorm(1,mean=0,sd=sigma)
    lines(rs,col="red")
    sim_price=t(CashFlow) %*% (1/(1+rs)^{1:N})
    cat(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

S=1000
sim_price=vector(length=S)
set.seed(88)
for(i in 1:S){
    rs=r+rnorm(1,mean=0,sd=sigma)
    sim_price[i]=t(CashFlow) %*% (1/(1+rs)^{1:N})
}
VaR=-(sort(sim_price)[S*probability]-price)
cat(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:

  1. Simulate one-day return: \(R_{t+1} \sim \mathcal{N}(0,\sigma^2)\)
  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:

  1. Simulate one-day return: \(y_{t+1} \sim \mathcal{N}(0,\sigma^2)\)
  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
p = 0.05
S = 1e5
P = 100
sigma = 0.01
ret = rnorm(S, 0, sigma^2)
Psim_simple = P*(1+ret)

# VaR 5%
Ps_simple = sort(Psim_simple - P)
Ps_simple[p*S]
-0.016411775818014
# Compound returns
r = 0.03   # Assuming risk free rate
Psim_comp = P*exp(r*(1/365))*exp(ret)*exp(-0.5*sigma^2)
# VaR 5%
Ps_comp = sort(Psim_comp - P)
Ps_comp[p*S]
-0.0131917275509181

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.

S=10000
sim_price=vector(length=S)
set.seed(88)
for(i in 1:S){
    rs=r+rnorm(10,mean=0,sd=sigma)
    sim_price[i]=t(CashFlow) %*% (1/(1+rs)^{1:N})
}
VaR=-(sort(sim_price)[S*probability]-price)
cat(price,mean(sim_price),VaR,"\n")
943.0979 1174.316 -70.66901