diff options
Diffstat (limited to 'R/calibration.R')
| -rw-r--r-- | R/calibration.R | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/R/calibration.R b/R/calibration.R index b6a05c91..3b1755bb 100644 --- a/R/calibration.R +++ b/R/calibration.R @@ -11,9 +11,9 @@ buildSC <- function(quote, cs, cdsdates){ return( SC ) } -get.cdsSchedule <- function(tradedate){ +get.cdsSchedule <- function(tradedate, tenors=c(1:5, 7, 10)) { cdsdates <- as.Date(character(0)) - for(tenor in paste0(c(1:5, 7, 10), "y")){ + for(tenor in paste0(tenors, "y")){ newdate <- cdsMaturity(tenor, date=tradedate) cdsdates <- c(cdsdates, newdate) } @@ -22,18 +22,22 @@ get.cdsSchedule <- function(tradedate){ cdsdates=cdsdates) ) } -set.singlenamesdata <- function(index, tradedate, recov=NULL){ - cds.cs <- get.cdsSchedule(tradedate) +set.singlenamesdata <- function(index, tradedate, recov=NULL) { + cds.cs <- if (index$type %in% c("HY", "XO")) { # no need to build the full 10y curve + get.cdsSchedule(tradedate, 1:5) + } else { + get.cdsSchedule(tradedate) + } quotes <- get.singlenamesquotes(index$name, tradedate) tenor <- names(cds.cs$cdsdates) index$portfolio <- list() for(i in seq_along(quotes$tickers)){ if(quotes$ticker[i] %in% c("IACI", "TITANC", "ESPSAN", "CBRY")){ - quotes$spread_curve[i,] <- rep(0.001,8) - quotes$upfront_curve[i,] <- rep(0,8) - quotes$recovery[i,] <- rep(0.4,8) + quotes$spread_curve[i,] <- rep(0.001, 8) + quotes$upfront_curve[i,] <- rep(0, 8) + quotes$recovery[i,] <- rep(0.4, 8) } - quotes$upfront_curve[i, tenor] <- pmax(-yearFrac(tradedate+2,cds.cs$cdsdates)* + quotes$upfront_curve[i, tenor] <- pmax(-yearFrac(tradedate+2, cds.cs$cdsdates)* quotes$spread_curve[i, tenor]*1e-2, quotes$upfront_curve[i, tenor]) quote <- list(ticker = quotes$ticker[i], |
