diff options
Diffstat (limited to 'R/calibrate_tranches_BC.R')
| -rw-r--r-- | R/calibrate_tranches_BC.R | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/R/calibrate_tranches_BC.R b/R/calibrate_tranches_BC.R index bb38681d..ad54df73 100644 --- a/R/calibrate_tranches_BC.R +++ b/R/calibrate_tranches_BC.R @@ -19,6 +19,7 @@ Ngrid <- 201 alldates <- seq(as.Date("2014-01-01"), as.Date("2014-01-05"), by="1 day")
rhomat <- c()
deltasmat <- c()
+gammasmat <- c()
bus.dates <- as.Date(names(which(isBusinessDay(calendar="UnitedStates/GovernmentBond", alldates))))
for(i in seq_along(bus.dates)){
tradedate <- bus.dates[i]
@@ -41,8 +42,14 @@ for(i in seq_along(bus.dates)){ }
rhovec <- c(0, rhovec)
hy21$rho <- rhovec
- deltas <- BCtranche.delta(hy21, Z, w, Ngrid, tradedate)
- deltasmat <- rbind(deltasmat, deltas)
+ temp <- BCtranche.delta(hy21, Z, w, Ngrid, tradedate)
+ deltasmat <- rbind(deltasmat, temp$deltas)
+ gammasmat <- rbind(gammasmat, temp$gammas)
+ cl <- c()
+ for(j in 1:(length(hy21$K)-1)){
+ cl <- c(cl, BCtranche.pv(hy21, hy21$K[j], hy21$K[j+1], rhovec[j], rhovec[j+1], Z, w, Ngrid)$cl)
+ }
+ duration <- (cl - cdsAccrued(tradedate, hy21$tranche.data$Coupon))/hy21$tranche.data$Coupon
rhomat <- rbind(rhomat, rhovec)
cat(i, "\n")
}
|
