diff options
Diffstat (limited to 'R/script_calibrate_tranches.R')
| -rw-r--r-- | R/script_calibrate_tranches.R | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/R/script_calibrate_tranches.R b/R/script_calibrate_tranches.R index ab29feca..10e8f470 100644 --- a/R/script_calibrate_tranches.R +++ b/R/script_calibrate_tranches.R @@ -63,20 +63,20 @@ issuerweights <- rep(1/length(hy21portfolio), length(hy21portfolio)) ## load tranche data
K <- c(0, 0.15, 0.25, 0.35, 1)
Kmodified <- adjust.attachments(K, hy21$loss, hy21$factor)
-markit.data <- read.csv(file.path(root.dir, "Scenarios", "Calibration",
+market.data <- read.csv(file.path(root.dir, "Scenarios", "Calibration",
paste0("hy21_tranches_", tradedate, ".csv")))
-tranche.upf <- markit.data$Mid
+tranche.upf <- market.data$Mid
tranche.running <- c(0.05, 0.05, 0.05, 0.05)
# get the index ref
-hy21$indexref <- markit.data$bidRefPrice[1]/100
+hy21$indexref <- market.data$bidRefPrice[1]/100
hy21portfolio.tweaked <- tweakcurves(hy21portfolio, hy21, tradedate)
SurvProb <- SPmatrix(hy21portfolio.tweaked, hy21)
Ngrid <- 2 * nrow(nondefaulted) + 1
recov <- sapply(hy21portfolio.tweaked, attr, "recovery")
-cs <- couponSchedule(nextIMMDate(tradedate), hy21$maturity,"Q", "FIXED", 0.05, 0)
-
+cs <- couponSchedule(IMMDate(tradedate), hy21$maturity,"Q", "FIXED", 0.05, 0, tradedate, IMMDate(tradedate, "prev"))
+acc <- cdsAccrued(tradedate, 0.05)
##calibrate by modifying the factor distribution
bottomup <- 1:3
topdown <- 2:4
@@ -107,7 +107,7 @@ for(l in 1:150){ R[,,t] <- t(lossdistCZ(p[,t], issuerweights, 1-S, Ngrid, 0, rho, Z))
}
for(i in 1:n.int){
- result[,i] <- tranche.pvvec(Kmodified, L[i,,], R[i,,], cs)
+ result[,i] <- tranche.pvvec(Kmodified, L[i,,], R[i,,], cs) - acc
}
## solve the optimization problem
program <- KLfit(100*(result[bottomup,]+1), w, tranche.upf[bottomup])
|
