diff options
Diffstat (limited to 'R')
| -rw-r--r-- | R/calibrate_tranches_BC.R | 5 | ||||
| -rw-r--r-- | R/calibration.R | 8 |
2 files changed, 7 insertions, 6 deletions
diff --git a/R/calibrate_tranches_BC.R b/R/calibrate_tranches_BC.R index 8687a1f9..6e8bf8ab 100644 --- a/R/calibrate_tranches_BC.R +++ b/R/calibrate_tranches_BC.R @@ -98,8 +98,9 @@ for(run in config$runs){ index <- set.index.desc(index, tradedate)
## calibrate the single names curves
index <- set.singlenamesdata(index, tradedate)
- index <- set.tranchedata(index, tradedate)
- if(is.null(index)){
+ index <- tryCatch(set.tranchedata(index, tradedate),
+ error=function(e) logerror(conditionMessage(e)))
+ if(inherits(index, "error")) {
loginfo(paste("skipping", index.name, tenor))
next
}
diff --git a/R/calibration.R b/R/calibration.R index 405587a3..b4f65ccb 100644 --- a/R/calibration.R +++ b/R/calibration.R @@ -59,12 +59,11 @@ set.singlenamesdata <- function(index, tradedate){ set.tranchedata <- function(index, tradedate){ if(is.null(index)){ - return( NULL ) + stop("index is NULL") } temp <- get.tranchequotes(index$name, index$tenor, tradedate) if(is.null(temp)){ - loginfo(paste(index$name, "no quote for day", as.character(tradedate))) - return(NULL) + stop(paste(index$name, "no quote for day", as.character(tradedate))) } index$quotes <- data.frame(maturity=index$maturity, refspread=temp$indexrefspread[1], @@ -75,11 +74,12 @@ set.tranchedata <- function(index, tradedate){ if(!is.na(index$quotes$refprice) && index$quotes$refprice != 0){ index$quotes$price <- index$quotes$refprice/100 }else{ + index$quotes$price <- snacpv(index$cs, index$quotes$refspread[1]*1e-4, index$quotes$spread, 0.4, tradedate) } if(length(indexpv(index, tradedate=tradedate, check=TRUE))==1){ - return(NULL) + stop("why am I stopping?") } tweak <- tweakcurves(index, tradedate) index$portfolio <- NULL |
