diff options
| -rw-r--r-- | R/build_portfolios.R | 4 | ||||
| -rw-r--r-- | R/index_definitions.R | 6 | ||||
| -rw-r--r-- | R/script_calibrate_tranches.R | 30 |
3 files changed, 23 insertions, 17 deletions
diff --git a/R/build_portfolios.R b/R/build_portfolios.R index 4fd2d561..cd056dba 100644 --- a/R/build_portfolios.R +++ b/R/build_portfolios.R @@ -71,7 +71,7 @@ global.params$beta <- 15 global.params$shape <- function(T)0.5+(1-0.5)*(1-exp(-T/5))
global.params$reinvflag <- TRUE
cusipdata <- cusip.data()
-cashspread.discount <- 0.01
+cashspread.discount <- 0
currdealnames <- dbGetQuery(dbCon, "select updatedate, dealname from latest_deal_model_numbers")
## build portfolio data
for(i in seq_along(dealnames)){
@@ -95,7 +95,7 @@ for(i in seq_along(dealnames)){ S <- 1 - sapply(deal.portfolio$SC, attr, "recov")
deal.weights <- deal.portfolio$notional/sum(deal.portfolio$notional)
deal.dates <- getdealschedule(deal.data)
- deal.spread5y <- portfoliospread(deal.portfolio, hy19$maturity)
+ deal.spread5y <- portfoliospread(deal.portfolio, hy21$maturity)
deal.spreadatmaturity <- portfoliospread(deal.portfolio)
save.dir <- file.path(root.dir, "Scenarios", paste("Portfolios", workdate, sep="_"))
if(!file.exists(save.dir)){
diff --git a/R/index_definitions.R b/R/index_definitions.R index 0660febf..2ed8a505 100644 --- a/R/index_definitions.R +++ b/R/index_definitions.R @@ -1,3 +1,9 @@ +hy21 <- list(maturity=as.Date("2018-12-20"),
+ coupon=0.05,
+ factor=1,
+ loss=0,
+ recovery=0.4)
+
hy20 <- list(maturity=as.Date("2018-06-20"),
coupon=0.05,
factor=1,
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")
|
