aboutsummaryrefslogtreecommitdiffstats
path: root/R/calibrate_tranches_BC.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/calibrate_tranches_BC.R')
-rw-r--r--R/calibrate_tranches_BC.R16
1 files changed, 8 insertions, 8 deletions
diff --git a/R/calibrate_tranches_BC.R b/R/calibrate_tranches_BC.R
index a1ccc1b9..64aad871 100644
--- a/R/calibrate_tranches_BC.R
+++ b/R/calibrate_tranches_BC.R
@@ -30,8 +30,8 @@ if(!interactive()){
## args <- list(config=yaml::yaml.load_file(file.path(code.dir, "etc", "runs.yml")),
## until = Sys.Date()-1,
## update = TRUE)
- args <- list(update=TRUE, until = Sys.Date()-1)
- config <- list(runs=list(c("hy21", "3yr")))
+ args <- list(update = F, until = Sys.Date()-1)
+ config <- list(runs = list(c("hy29", "5yr")))
options(error=recover)
}
@@ -63,7 +63,7 @@ for(run in config$runs) {
hy23 = as.Date("2014-10-16"),
hy25 = as.Date("2015-10-01"),
hy27 = as.Date("2016-10-04"),
- hy29 = as.Date("2016-10-03"),
+ hy29 = as.Date("2017-10-03"),
ig9 = as.Date("2013-01-01"),
ig19 = as.Date("2013-05-01"),
ig21 = as.Date("2013-09-26"),
@@ -112,7 +112,7 @@ for(run in config$runs) {
}
temp <- BCindex.pv(index)
index$EL <- -temp$pl
- index$duration <- temp$cl-cdsAccrued(tradedate, 1)
+ index$duration <- temp$cl - cdsAccrued(tradedate, 1)
index$theta <- indextheta(index, tradedate)
## calibrate the tranches using base correlation
@@ -130,7 +130,7 @@ for(run in config$runs) {
temp <- BCtranche.pv(index, protection=TRUE)
index$tranches$duration <-
(temp$cl-cdsAccrued(tradedate, index$tranches$running))/index$tranches$running
- index$tranches$EL <- -temp$pl*diff(index$K)
+ index$tranches$EL <- -temp$pl * diff(index$K)
## save the index object
save(index, file=file.path(tranchedata.dir, "Objects",
@@ -141,9 +141,9 @@ for(run in config$runs) {
cat(csvheaders(index), sep="\n", file=filename)
}
cat(tocsv(index), sep="\n", file=filename, append=TRUE)
- r <- with(tosql(index),
- tryCatch(dbGetQuery(serenitasdb, stmt, params),
- error = function(e) logerror(e$message)))
+ tryCatch(dbWriteTable(serenitasdb, "risk_numbers_new",
+ as.data.frame(index), append=TRUE),
+ error = function(e) logerror(e$message))
loginfo("done")
}
}