aboutsummaryrefslogtreecommitdiffstats
path: root/R/plot_deltas.R
blob: bac548aece85b7d82455e07cdd554e6666fe6508 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
indexpv <- c()
for(i in 1:length(dealweight)){
    indexpv <- c(indexpv, funded.tranche.pv(scenariosl[i,], scenariosr[i,], cs, 0, 1))
}
K <- c(0, 0.15, 0.25, 0.35, 1)
tranchespv <- matrix(0, 100, 4)
for(i in 1:length(dealweight)){
    for(j in 1:4) {
        tranchespv[i,j] <- funded.tranche.pv(scenariosl[i,], scenariosr[i,], cs, K[j], K[j+1], TRUE)
    }
}
tranchespv <- scale(tranchespv, scale=FALSE)

deltas <- rep(0, 4)
for(i in 1:4){
    deltas[i] <- lm(cusippv~tranchespv[,i], weights=dealweight)$coef[2]
}

x <- cusippv-0.9975
col1 <- rgb(0, 70, 127,  max=255)
col2 <- rgb(0, 157, 220, max=255)
col3 <- rgb(0, 113, 173,  max=255)

matplot(cbind(100*x, 100*(x-1.36*(indexpv-mean(indexpv))),100*(x-deltas[3]*tranchespv[,3]) ), xlab = "percentile", ylab="pnl in points",type="l", lwd=2,col=c(col1, col2, col3))
legend(2,-20,c("unhedged","hedged with HY19 index","hedged with HY19 25-35"), lty=c(1,2,3),col=c(col1, col2, col3),lwd=c(2,2,2))