aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/creditIndex.R10
-rw-r--r--R/tranches_RV_BC.R10
2 files changed, 17 insertions, 3 deletions
diff --git a/R/creditIndex.R b/R/creditIndex.R
index 6ac58375..7b49aa76 100644
--- a/R/creditIndex.R
+++ b/R/creditIndex.R
@@ -54,8 +54,14 @@ print.creditIndex <- function(index){
load.index <- function(name, tenor, date){
## load a creditIndex which was previously saved
- load(file.path(root.dir, "Tranche_data", "Objects",
- paste0(paste(name, tenor, date, sep="_"),".RData")))
+ indexfile <- file.path(root.dir, "Tranche_data", "Objects",
+ paste0(paste(name, tenor, date, sep="_"),".RData"))
+ if(file.exists(indexfile)){
+ load(indexfile)
+ }else{
+ loginfo(paste(name, tenor, "file missing"))
+ return(NULL)
+ }
return(index)
}
diff --git a/R/tranches_RV_BC.R b/R/tranches_RV_BC.R
index 31e1fab5..a7cd368a 100644
--- a/R/tranches_RV_BC.R
+++ b/R/tranches_RV_BC.R
@@ -3,7 +3,10 @@ if(.Platform$OS.type == "unix"){
}else{
root.dir <- "//WDSENTINEL/share/CorpCDOs"
}
-
+library(logging)
+basicConfig()
+removeHandler('basic.stdout')
+addHandler(writeToFile, file=file.path(root.dir, "logs", "tranches_RV_BC.log"))
library(optparse)
option_list <- list(
make_option(c("-u", "--update"), action="store_true", default=FALSE,
@@ -69,6 +72,10 @@ for(i in seq_along(runs$name1)){
tradedate <- bus.dates[j]
index1 <- load.index(index.name1, tenor1, tradedate)
index2 <- load.index(index.name2, tenor2, tradedate)
+ if(any(c(is.null(index1), is.null(index2)))){
+ loginfo(paste("skipping pair ", index.name1, tenor1, index.name2, tenor2))
+ break
+ }
accrued2 <- cdsAccrued(tradedate, index2$tranches$running)
mappedpv <- list()
for(method in c("ATM", "TLP", "PM")){
@@ -89,4 +96,5 @@ for(i in seq_along(runs$name1)){
}
cat(paste(row, collapse=","), "\n", file=filename, append=TRUE)
}
+
}