aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/calibrate_tranches_BC.R14
-rw-r--r--R/calibration.R2
2 files changed, 8 insertions, 8 deletions
diff --git a/R/calibrate_tranches_BC.R b/R/calibrate_tranches_BC.R
index 9ce020c8..a1ccc1b9 100644
--- a/R/calibrate_tranches_BC.R
+++ b/R/calibrate_tranches_BC.R
@@ -44,7 +44,7 @@ source("serenitasdb.R")
source("creditIndex.R")
source("tranche_functions.R")
-for(run in config$runs){
+for(run in config$runs) {
index.name <- run[1]
tenor <- run[2]
filename <- file.path(tranchedata.dir, "Runs",
@@ -52,8 +52,8 @@ for(run in config$runs){
## if(!file.exists(filename)){
## args$update <- FALSE
## }
- if(args$update && !is.na(begin.date <- getlastdate(index.name, tenor))){
- }else{
+ if(args$update && !is.na(begin.date <- getlastdate(index.name, tenor))) {
+ } else {
begin.date <- switch(index.name,
hy10 = as.Date("2014-08-11"),
hy15 = as.Date("2014-06-10"),
@@ -83,20 +83,20 @@ for(run in config$runs){
eu26 = as.Date("2016-09-27"),
eu28 = as.Date("2017-09-28"))
}
- if(begin.date > as.Date(args$until)){
+ if(begin.date > as.Date(args$until)) {
next
}
alldates <- seq(begin.date, as.Date(as.character(args$until)), by="1 day")
- if(tolower(substr(index.name,1,2)) %in% c("xo", "eu")){
+ if(tolower(substr(index.name,1,2)) %in% c("xo", "eu")) {
curr <- "EUR"
cal <- Calendar$new("TARGET")
- }else{
+ } else {
curr <- "USD"
cal <- Calendar$new("UnitedStates/GovernmentBond")
}
bus.dates <- alldates[cal$isBusinessDay(alldates)]
- for(j in seq_along(bus.dates)){
+ for(j in seq_along(bus.dates)) {
tradedate <- bus.dates[j]
loginfo(paste("calibrating", index.name, tenor, "for", as.character(tradedate)))
exportYC(tradedate, curr)
diff --git a/R/calibration.R b/R/calibration.R
index e5d9cb50..38f7d329 100644
--- a/R/calibration.R
+++ b/R/calibration.R
@@ -92,7 +92,7 @@ set.tranchedata <- function(index, tradedate){
index$portfolio <- NULL
index <- c(index, tweak)
index$defaultprob <- 1 - SPmatrix(index$portfolio, index$cs$dates)
- negprob <- which(index$defaultprob<0, arr.ind=T)
+ negprob <- which(index$defaultprob < 0, arr.ind=T)
if(nrow(negprob) > 0){
stop(paste(index$portfolio[[negprob[1,1]]]@issuer, "has negative probability, check single names data"))
}