aboutsummaryrefslogtreecommitdiffstats
path: root/R
diff options
context:
space:
mode:
Diffstat (limited to 'R')
-rw-r--r--R/plot_deltas.R25
1 files changed, 25 insertions, 0 deletions
diff --git a/R/plot_deltas.R b/R/plot_deltas.R
new file mode 100644
index 00000000..bac548ae
--- /dev/null
+++ b/R/plot_deltas.R
@@ -0,0 +1,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))