aboutsummaryrefslogtreecommitdiffstats
path: root/R/calibrate_tranches_BC.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/calibrate_tranches_BC.R')
-rw-r--r--R/calibrate_tranches_BC.R12
1 files changed, 6 insertions, 6 deletions
diff --git a/R/calibrate_tranches_BC.R b/R/calibrate_tranches_BC.R
index cd0d85fc..e0e358d0 100644
--- a/R/calibrate_tranches_BC.R
+++ b/R/calibrate_tranches_BC.R
@@ -16,7 +16,7 @@ n.int <- 250
attach(GHquad(n.int))
Ngrid <- 201
-alldates <- seq(as.Date("2014-01-01"), as.Date("2014-05-05"), by="1 day")
+alldates <- seq(as.Date("2014-01-01"), as.Date("2014-05-30"), by="1 day")
rhomat <- c()
deltasmat <- c()
bus.dates <- as.Date(names(which(isBusinessDay(calendar="UnitedStates/GovernmentBond", alldates))))
@@ -35,9 +35,8 @@ for(i in seq_along(bus.dates)){
return(abs(tranche.pv(temp$L, temp$R, index$cs, 0, index$K[i+1]) + index$quotes[i]))
}
rhovec <- c()
- for(i in 1:(length(hy21$K)-1)){
- q <- quotes[i-1]
- rho <- optimize(f, interval=c(0,1), index=hy21, N=Ngrid, i=i)$minimum
+ for(j in 1:(length(hy21$K)-1)){
+ rho <- optimize(f, interval=c(0,1), index=hy21, N=Ngrid, i=j)$minimum
rhovec <- c(rhovec, rho)
}
rhovec <- c(0, rhovec)
@@ -61,9 +60,10 @@ for(i in seq_along(bus.dates)){
##use BCtranche.delta function
deltas <- rep(0, length(hy21$K)-1)
- for(i in seq_along(hy21$K[-1])){
- deltas[i] <- BCtranche.delta(hy21, hy21$K[i], hy21$K[i+1], rhovec[i], rhovec[i+1], Z, w, Ngrid, tradedate)
+ for(j in seq_along(hy21$K[-1])){
+ deltas[j] <- BCtranche.delta(hy21, hy21$K[j], hy21$K[j+1], rhovec[j], rhovec[j+1], Z, w, Ngrid, tradedate)
}
deltasmat <- rbind(deltasmat, deltas)
rhomat <- rbind(rhomat, rhovec)
+ cat(i, "\n")
}