diff options
| -rw-r--r-- | R/calibrate_tranches_BC.R | 8 | ||||
| -rw-r--r-- | R/calibration.R | 5 | ||||
| -rw-r--r-- | R/tranches_RV_BC.R | 10 |
3 files changed, 12 insertions, 11 deletions
diff --git a/R/calibrate_tranches_BC.R b/R/calibrate_tranches_BC.R index ac0d5fa7..9793fcbf 100644 --- a/R/calibrate_tranches_BC.R +++ b/R/calibrate_tranches_BC.R @@ -44,7 +44,10 @@ for(i in seq_along(runs$name)){ tenor <- runs$tenor[i]
filename <- file.path(root.dir,"Tranche_data","Runs",
paste(index.name,tenor,"csv",sep="."))
- if(args$update && file.exists(filename)){##ghetto way of getting the last row of the file
+ if(!file.exists(filename)){
+ args$update <- FALSE
+ }
+ if(args$update){##ghetto way of getting the last row of the file
runfile <- read.csv(filename)
begin.date <- as.Date(runfile[nrow(runfile),1])+1
}else{
@@ -63,9 +66,6 @@ for(i in seq_along(runs$name)){ next
}
alldates <- seq(begin.date, as.Date(as.character(args$until)), by="1 day")
- if(index.name=="ig19"){
- alldates <- alldates[alldates!=as.Date("2013-11-29")] ##people are lazy the day after Thanksgiving
- }
bus.dates <- alldates[isBusinessDay(calendar="UnitedStates/GovernmentBond", alldates)]
for(j in seq_along(bus.dates)){
diff --git a/R/calibration.R b/R/calibration.R index fb7302b2..4e8cac31 100644 --- a/R/calibration.R +++ b/R/calibration.R @@ -43,7 +43,8 @@ set.singlenamesdata <- function(index, tradedate){ upfront = quotes$upfront_curve[i, tenor] * 0.01, recovery = as.double(quotes$recovery[i,tenor][1])) if(all(is.na(quote$upfront))){ - loginfo(paste("no quotes available for", quote$ticker)) + loginfo(paste("no quotes available for", quote$ticker, "on day", + as.character(tradedate))) return( NULL ) } index$portfolio <- c(index$portfolio, buildSC(quote, cds.cs$cs, cds.cs$cdsdates)) @@ -59,7 +60,7 @@ set.tranchedata <- function(index, tradedate){ } temp <- get.tranchequotes(index$name, index$tenor, tradedate) if(is.null(temp)){ - loginfo(paste(inde$name, "no quote for that day")) + loginfo(paste(index$name, "no quote for day", as.character(tradedate))) return(NULL) } index$quotes <- data.frame(maturity=index$maturity, diff --git a/R/tranches_RV_BC.R b/R/tranches_RV_BC.R index bd06e244..48f9847d 100644 --- a/R/tranches_RV_BC.R +++ b/R/tranches_RV_BC.R @@ -19,7 +19,7 @@ option_list <- list( help="Tenor of index1 [default %default]"),
make_option(c("-t2", "--tenor2"), default="5yr",
help="Tenor of index2 [default %default]"),
- make_option("--until", default=Sys.Date()-1, type="character"
+ make_option("--until", default=Sys.Date()-1, type="character",
help="last day to run [default %default]"))
args <- parse_args(OptionParser(option_list=option_list,
@@ -50,6 +50,9 @@ for(i in seq_along(runs$name1)){ tenor2 <<- tenor2[i]})
filename <- file.path(root.dir,"Tranche_data","Runs",
paste0(paste(index.name2, tenor2, "using", index.name1, tenor1),".csv"))
+ if(!file.exists(filename)){
+ args$update <- FALSE
+ }
if(args$update){
runfile <- read.csv(filename)
begin.date <- as.Date(runfile[nrow(runfile), 1])+1
@@ -64,9 +67,6 @@ for(i in seq_along(runs$name1)){ next
}
alldates <- seq(begin.date, as.Date(as.character(args$until)), by="1 day")
- if(index.name2=="ig19"){
- alldates <- alldates[alldates!=as.Date("2013-11-29")] ##people are lazy the day after Thanksgiving
- }
bus.dates <- alldates[isBusinessDay(calendar="UnitedStates/GovernmentBond", alldates)]
for(j in seq_along(bus.dates)){
@@ -74,7 +74,7 @@ for(i in seq_along(runs$name1)){ 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))
+ loginfo(paste("skipping pair", index.name1, tenor1, index.name2, tenor2))
break
}
accrued2 <- cdsAccrued(tradedate, index2$tranches$running)
|
