aboutsummaryrefslogtreecommitdiffstats
path: root/R/script_calibrate_tranches.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/script_calibrate_tranches.R')
-rw-r--r--R/script_calibrate_tranches.R30
1 files changed, 15 insertions, 15 deletions
diff --git a/R/script_calibrate_tranches.R b/R/script_calibrate_tranches.R
index e360a712..44e6fe1c 100644
--- a/R/script_calibrate_tranches.R
+++ b/R/script_calibrate_tranches.R
@@ -31,11 +31,11 @@ L3m <- buildMarkitYC(MarkitData)
L6m <- buildMarkitYC(MarkitData, dt = 1/2)
setEvaluationDate(as.Date(MarkitData$effectiveasof))
-## calibrate HY19
+## calibrate HY21
## calibrate the single names curves
singlenames.data <- read.csv(file.path(root.dir, "Scenarios", "Calibration",
- paste0("hy19_singlenames_", workdate, ".csv")))
-nondefaulted <- singlenames.data[!singlenames.data$ticker %in% hy19$defaulted,]
+ paste0("hy21_singlenames_", workdate, ".csv")))
+nondefaulted <- singlenames.data[!singlenames.data$ticker %in% hy21$defaulted,]
bps <- 1e-4
cdsdates <- as.Date(character(0))
@@ -43,7 +43,7 @@ for(tenor in paste0(1:5, "y")){
cdsdates <- c(cdsdates, cdsMaturity(tenor))
}
-hy19portfolio <- c()
+hy21portfolio <- c()
for(i in 1:nrow(nondefaulted)){
SC <- new("creditcurve",
recovery=nondefaulted$recovery[i]/100,
@@ -52,33 +52,33 @@ for(i in 1:nrow(nondefaulted)){
quotes <- data.frame(maturity=cdsdates, upfront = as.numeric(nondefaulted[i,4:8]) /100,
running=rep(nondefaulted$running[i] * bps, 5))
SC@curve <- cdshazardrate(quotes, nondefaulted$recovery[i]/100)
- hy19portfolio <- c(hy19portfolio, SC)
+ hy21portfolio <- c(hy21portfolio, SC)
}
-issuerweights <- rep(1/length(hy19portfolio), length(hy19portfolio))
+issuerweights <- rep(1/length(hy21portfolio), length(hy21portfolio))
## load tranche data
K <- c(0, 0.15, 0.25, 0.35, 1)
-Kmodified <- adjust.attachments(K, hy19$loss, hy19$factor)
+Kmodified <- adjust.attachments(K, hy21$loss, hy21$factor)
markit.data <- read.csv(file.path(root.dir, "Scenarios", "Calibration",
- paste0("hy19_tranches_", workdate, ".csv")))
+ paste0("hy21_tranches_", workdate, ".csv")))
tranche.upf <- markit.data$Mid
tranche.running <- c(0.05, 0.05, 0.05, 0.05)
# get the index ref
-hy19$indexref <- markit.data$bidRefPrice[1]/100
-hy19portfolio.tweaked <- tweakcurves(hy19portfolio, hy19)
-SurvProb <- SPmatrix(hy19portfolio.tweaked, hy19)
+hy21$indexref <- markit.data$bidRefPrice[1]/100
+hy21portfolio.tweaked <- tweakcurves(hy21portfolio, hy21)
+SurvProb <- SPmatrix(hy21portfolio.tweaked, hy21)
Ngrid <- 2 * nrow(nondefaulted) + 1
-recov <- sapply(hy19portfolio.tweaked, attr, "recovery")
-cs <- couponSchedule(nextIMMDate(workdate), hy19$maturity,"Q", "FIXED", 0.05, 0)
+recov <- sapply(hy21portfolio.tweaked, attr, "recovery")
+cs <- couponSchedule(nextIMMDate(workdate), hy21$maturity,"Q", "FIXED", 0.05, 0)
##calibrate by modifying the factor distribution
bottomup <- 1:3
topdown <- 2:4
n.int <- 500
-n.credit <- length(hy19portfolio)
+n.credit <- length(hy21portfolio)
errvec <- c()
quadrature <- gauss.quad.prob(n.int, "normal")
w <- quadrature$weights
@@ -151,6 +151,6 @@ write.table(data.frame(Z=Z, w=w.mod),
paste0("calibration-", workdate, ".csv")),
col.names=T, row.names=F, sep=",")
-save(singlenames.data, hy19, tranche.upf, dist,
+save(singlenames.data, hy21, tranche.upf, dist,
file = file.path(root.dir, "Scenarios", "Calibration",
paste0("marketdata-", workdate, ".RData")), compress="xz")