diff options
Diffstat (limited to 'R/calibration.R')
| -rw-r--r-- | R/calibration.R | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/R/calibration.R b/R/calibration.R index 86ca5065..674e1817 100644 --- a/R/calibration.R +++ b/R/calibration.R @@ -44,9 +44,8 @@ set.singlenamesdata <- function(index, tradedate){ } set.tranchedata <- function(index, tradedate){ - index$tranche.data <- read.csv(file.path(root.dir, "Scenarios", "Calibration", - paste0(index$name, "_tranches_", tradedate, ".csv")), header=TRUE) - index$indexref <- index$tranche.data$bidRefPrice[1]/100 + temp <- get.tranchequotes(index$name, tradedate) + index$indexref <- temp$refbasketprice[1]/100 index$cs <- couponSchedule(IMMDate(tradedate), index$maturity,"Q", "FIXED", 0.05, 0, tradedate, IMMDate(tradedate, "prev")) index$portfolio <- tweakcurves(index, tradedate)$portfolio @@ -55,14 +54,11 @@ set.tranchedata <- function(index, tradedate){ if(nrow(negprob)>0){ stop(paste(index$portfolio[[negprob[1,]]]@issuer, "has negative probability, check single names data")) } - K <- c(0, 0.15, 0.25, 0.35, 1) + K <- c(0, temp$detach/100) index$K <- adjust.attachments(K, index$loss, index$factor) - index$tranche.upf <- index$tranche.data$Mid - if("Coupon" %in% names(index$tranche.data)){ - index$tranche.running <- index$tranche.data$Coupon - }else{ - index$tranche.running <- rep(0.05, nrow(index$tranche.data)) - } + index$tranche.upf <- temp$upfront + index$tranche.running <- temp$running*1e-4 + ## convert the quotes ## - we convert to protection terms x->1-x/100 ## - we remove accrued x->x-acc |
