aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/calibrate_tranches_BC.R19
1 files changed, 10 insertions, 9 deletions
diff --git a/R/calibrate_tranches_BC.R b/R/calibrate_tranches_BC.R
index afebb179..0ddfc573 100644
--- a/R/calibrate_tranches_BC.R
+++ b/R/calibrate_tranches_BC.R
@@ -4,7 +4,7 @@ if(.Platform$OS.type == "unix"){
root.dir <- "//WDSENTINEL/share/CorpCDOs"
}
-options(warn=2, stringsAsFactors = FALSE)
+options(stringsAsFactors = FALSE)
source(file.path(root.dir, "code", "R", "yieldcurve.R"))
source(file.path(root.dir, "code", "R", "optimization.R"))
@@ -31,16 +31,17 @@ if(length(args)>=2&&args[2]!="update"){
updateflag <- args[length(args)]=="update"
if(updateflag){##ghetto way of getting the last row of the file
- runfile <- read.csv(file.path(root.dir,"Tranche_data","Runs", paste0(index.name,tenor,".csv")))
+ runfile <- read.csv(file.path(root.dir,"Tranche_data","Runs", paste(index.name,tenor,"csv",sep=".")))
begin.date <- as.Date(runfile[nrow(runfile),1])+1
-}
-
-begin.date <- switch(index.name,
+}else{
+ begin.date <- switch(index.name,
hy10=as.Date("2014-06-10"),
ig19=as.Date("2013-05-01"),
ig21=as.Date("2013-09-26"),
hy19=as.Date("2013-02-01"),
hy21=as.Date("2013-10-04"))
+}
+
alldates <- seq(begin.date, Sys.Date()-1, by="1 day")
if(index.name=="ig19"){
alldates <- alldates[alldates!=as.Date("2013-11-29")] ##people are lazy the day after Thanksgiving
@@ -121,8 +122,8 @@ colnames(risk.numbers) <- c(paste(tranche.names, "Model Delta"),
paste(tranche.names, "Corr01"),
paste(tranche.names, "Dur"),
paste(tranche.names, "EL"))
-data <- cbind(quotes, indexEL, indexTheta, risk.numbers)
-row.names(data) <- as.character(bus.dates)
+data <- cbind(bus.dates, quotes, indexEL, indexTheta, risk.numbers)
+colnames(data)[1] <- "date"
-write.csv(data, file.path(root.dir,"Tranche_data","Runs", paste(index.name,tenor,"csv",sep=".")),
- append=updateflag, col.names=!updateflag)
+write.table(data, file=file.path(root.dir,"Tranche_data","Runs", paste(index.name,tenor,"csv",sep=".")),
+ append=updateflag, col.names=!updateflag, qmethod="double", sep=",", row.names=FALSE)