diff options
Diffstat (limited to 'R/script_calibrate_tranches.R')
| -rw-r--r-- | R/script_calibrate_tranches.R | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/R/script_calibrate_tranches.R b/R/script_calibrate_tranches.R index d79875c4..a0f0afbf 100644 --- a/R/script_calibrate_tranches.R +++ b/R/script_calibrate_tranches.R @@ -43,10 +43,12 @@ bps <- 1e-4 cdsdates <- as.Date(character(0))
for(tenor in paste0(1:5, "y")){
- cdsdates <- c(cdsdates, cdsMaturity(tenor, date=tradedate+1))
+ cdsdates <- c(cdsdates, cdsMaturity(tenor, date=tradedate))
}
hy21portfolio <- c()
+cs <- couponSchedule(IMMDate(tradedate), cdsdates[length(cdsdates)], "Q", "FIXED",
+ 1, tradedate, IMMDate(tradedate, "prev"))
for(i in 1:nrow(nondefaulted)){
SC <- new("creditcurve",
recovery=nondefaulted$recovery[i]/100,
@@ -54,7 +56,7 @@ for(i in 1:nrow(nondefaulted)){ issuer=as.character(nondefaulted$ticker[i]))
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, tradedate)
+ SC@curve <- cdshazardrate(quotes, nondefaulted$recovery[i]/100, tradedate, cs)
hy21portfolio <- c(hy21portfolio, SC)
}
@@ -70,7 +72,7 @@ tranche.upf <- market.data$Mid tranche.running <- c(0.05, 0.05, 0.05, 0.05)
# get the index ref
hy21$indexref <- market.data$bidRefPrice[1]/100
-hy21portfolio.tweaked <- tweakcurves(hy21portfolio, hy21, tradedate)
+hy21portfolio.tweaked <- tweakcurves(hy21portfolio, hy21, tradedate)$portfolio
SurvProb <- SPmatrix(hy21portfolio.tweaked, hy21)
Ngrid <- 2 * nrow(nondefaulted) + 1
|
