diff options
| -rw-r--r-- | R/VaR.R | 18 | ||||
| -rw-r--r-- | R/build_portfolios.R | 17 | ||||
| -rw-r--r-- | R/build_scenarios.R | 17 | ||||
| -rw-r--r-- | R/calibrate_tranches_BC.R | 16 | ||||
| -rw-r--r-- | R/calibrate_tranches_MF.R | 15 | ||||
| -rw-r--r-- | R/creditIndex.R | 6 | ||||
| -rw-r--r-- | R/load_cf.R | 23 | ||||
| -rw-r--r-- | R/test_options.R | 15 |
8 files changed, 50 insertions, 77 deletions
@@ -1,20 +1,14 @@ ## parse command line arguments -root.dir <- if(.Platform$OS.type == "unix"){ - "/home/share/CorpCDOs" -}else{ - "//WDSENTINEL/share/CorpCDOs" -} - library(logging) basicConfig() options(stringsAsFactors = FALSE) -source(file.path(root.dir, "code", "R", "yieldcurve.R")) -source(file.path(root.dir, "code", "R", "optimization.R")) -source(file.path(root.dir, "code", "R", "calibration.R"), chdir=TRUE) -source(file.path(root.dir, "code", "R", "serenitasdb.R")) -source(file.path(root.dir, "code", "R", "creditIndex.R")) -source(file.path(root.dir, "code", "R", "tranche_functions.R")) +source("yieldcurve.R") +source("optimization.R") +source("calibration.R") +source("serenitasdb.R") +source("creditIndex.R") +source("tranche_functions.R") #we load the index we want to shock tradedate <- addBusDay(Sys.Date(), -1) diff --git a/R/build_portfolios.R b/R/build_portfolios.R index 9bb13955..acf3c11b 100644 --- a/R/build_portfolios.R +++ b/R/build_portfolios.R @@ -3,17 +3,12 @@ library("yaml") args <- commandArgs(trailingOnly=TRUE) -if(Sys.getenv("DATA_DIR") == ""){ - root.dir <- "/home/serenitas/CorpCDOs" -}else{ - root.dir <- file.path(Sys.getenv("DATA_DIR"), "..") -} -code.dir <- if(Sys.getenv("CODE_DIR")=="") file.path(root.dir, "code") else Sys.getenv("CODE_DIR") - -source(file.path(code.dir, "R", "intex_deal_functions.R"), chdir=TRUE) -source(file.path(code.dir, "R", "yieldcurve.R")) -source(file.path(code.dir, "R", "serenitasdb.R"), chdir=TRUE) -source(file.path(code.dir, "R", "creditIndex.R")) +stopifnot((root.dir <- Sys.getenv("BASE_DIR")) != "") +stopifnot((code.dir <- Sys.getenv("CODE_DIR")) != "") +source("intex_deal_functions.R") +source("yieldcurve.R") +source("serenitasdb.R") +source("creditIndex.R") if(interactive()) { ## enter the parameters here diff --git a/R/build_scenarios.R b/R/build_scenarios.R index c484adde..21f2a401 100644 --- a/R/build_scenarios.R +++ b/R/build_scenarios.R @@ -10,17 +10,12 @@ if(hostname=="debian"){ args <- commandArgs(trailingOnly=TRUE) -if(Sys.getenv("DATA_DIR")=="") { - root.dir <- "/home/serenitas/CorpCDOs" -} else { - root.dir <- file.path(Sys.getenv("DATA_DIR"), "..") -} - -code.dir <- if(Sys.getenv("CODE_DIR")=="") file.path(root.dir, "code") else Sys.getenv("CODE_DIR") -source(file.path(code.dir, "R", "intex_deal_functions.R"), chdir=TRUE) -source(file.path(code.dir, "R", "yieldcurve.R")) -source(file.path(code.dir, "R", "serenitasdb.R"), chdir=TRUE) -source(file.path(code.dir, "R", "tranche_functions.R")) +stopifnot((root.dir <- Sys.getenv("BASE_DIR")) != "") +stopifnot((code.dir <- Sys.getenv("CODE_DIR")) != "") +source("intex_deal_functions.R") +source("yieldcurve.R") +source("serenitasdb.R") +source("tranche_functions.R") if(interactive()) { tradedate <- as.Date("2016-02-25") diff --git a/R/calibrate_tranches_BC.R b/R/calibrate_tranches_BC.R index b090a679..4762bee5 100644 --- a/R/calibrate_tranches_BC.R +++ b/R/calibrate_tranches_BC.R @@ -1,6 +1,6 @@ ## parse command line arguments code.dir <- Sys.getenv("CODE_DIR") -tranchedata.dir <- file.path(Sys.getenv("DATA_DIR"), "..", "Tranche_data") +tranchedata.dir <- file.path(Sys.getenv("BASE_DIR"), "Tranche_data") library(logging) basicConfig() if(!interactive()){ @@ -27,7 +27,7 @@ if(!interactive()){ config <- yaml::yaml.load_file(file.path(code.dir, "etc", args$config)) } } else { - ## args <- list(config=yaml::yaml.load_file(file.path(root.dir,"code", "etc", "runs.yml")), + ## 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) @@ -37,12 +37,12 @@ if(!interactive()){ class(args$until) <- "Date" options(stringsAsFactors = FALSE) -source(file.path(code.dir, "R", "yieldcurve.R")) -source(file.path(code.dir, "R", "optimization.R")) -source(file.path(code.dir, "R", "calibration.R"), chdir=TRUE) -source(file.path(code.dir, "R", "serenitasdb.R")) -source(file.path(code.dir, "R", "creditIndex.R")) -source(file.path(code.dir, "R", "tranche_functions.R")) +source("yieldcurve.R") +source("optimization.R") +source("calibration.R") +source("serenitasdb.R") +source("creditIndex.R") +source("tranche_functions.R") for(run in config$runs){ index.name <- run[1] diff --git a/R/calibrate_tranches_MF.R b/R/calibrate_tranches_MF.R index 8b070f4a..f27ded47 100644 --- a/R/calibrate_tranches_MF.R +++ b/R/calibrate_tranches_MF.R @@ -8,14 +8,13 @@ basicConfig() removeHandler('basic.stdout') addHandler(writeToFile, file=file.path(Sys.getenv("LOG_DIR"), "calibrate_tranches_MF.log")) ##options(warn=2) -code.dir <- Sys.getenv("CODE_DIR") -data.dir <- file.path(Sys.getenv("DATA_DIR"), "..", "Scenarios", "Calibration") -source(file.path(code.dir, "R", "yieldcurve.R")) -source(file.path(code.dir, "R", "optimization.R")) -source(file.path(code.dir, "R", "calibration.R"), chdir=TRUE) -source(file.path(code.dir, "R", "serenitasdb.R")) -source(file.path(code.dir, "R", "creditIndex.R")) -source(file.path(code.dir, "R", "tranche_functions.R")) +data.dir <- file.path(Sys.getenv("BASE_DIR"), "Scenarios", "Calibration") +source("yieldcurve.R") +source("optimization.R") +source("calibration.R") +source("serenitasdb.R") +source("creditIndex.R") +source("tranche_functions.R") ##figure out the tradedate if(length(args) >= 1){ diff --git a/R/creditIndex.R b/R/creditIndex.R index 3788b2a2..7d8859a3 100644 --- a/R/creditIndex.R +++ b/R/creditIndex.R @@ -1,8 +1,4 @@ -root.dir <- if(Sys.getenv("DATA_DIR") == ""){ - "/home/serenitas/CorpCDOs" -}else{ - file.path(Sys.getenv("DATA_DIR"), "..") -} +stopifnot((root.dir <- Sys.getenv("BASE_DIR")) != "") library(lossdistrib) n.int <- 250 diff --git a/R/load_cf.R b/R/load_cf.R index e37fdef0..715e2168 100644 --- a/R/load_cf.R +++ b/R/load_cf.R @@ -8,22 +8,17 @@ library(logging) basicConfig() args <- commandArgs(trailingOnly=TRUE) -root.dir <- if(.Platform$OS.type == "unix"){ - "/home/share/CorpCDOs" -}else{ - "//WDSENTINEL/share/CorpCDOs" -} - +stopifnot((root.dir <- Sys.getenv("BASE_DIR")) != "") tradedate <- if(length(args) >= 1) as.Date(args[1]) else Sys.Date() -source(file.path(root.dir, "code", "R", "yieldcurve.R")) -source(file.path(root.dir, "code", "R", "cds_utils.R")) -source(file.path(root.dir, "code", "R", "intex_deal_functions.R"), chdir=TRUE) -source(file.path(root.dir, "code", "R", "optimization.R")) -source(file.path(root.dir, "code", "R", "interpweights.R")) -source(file.path(root.dir, "code", "R", "serenitasdb.R")) -source(file.path(root.dir, "code", "R", "creditIndex.R")) -source(file.path(root.dir, "code", "R", "tranche_functions.R")) +source("yieldcurve.R") +source("cds_utils.R") +source("intex_deal_functions.R") +source("optimization.R") +source("interpweights.R") +source("serenitasdb.R") +source("creditIndex.R") +source("tranche_functions.R") index <- creditIndex("hy27") index <- set.index.desc(index, tradedate) diff --git a/R/test_options.R b/R/test_options.R index babc8bf4..1d41bba9 100644 --- a/R/test_options.R +++ b/R/test_options.R @@ -1,11 +1,10 @@ -root.dir <- "/home/share/CorpCDOs" -code.dir <- if(Sys.getenv("CODE_DIR")!="") Sys.getenv("CODE_DIR") else root.dir -source(file.path(code.dir, "code", "R", "yieldcurve.R")) -source(file.path(code.dir, "code", "R", "optimization.R")) -source(file.path(code.dir, "code", "R", "calibration.R"), chdir=TRUE) -source(file.path(code.dir, "code", "R", "serenitasdb.R")) -source(file.path(code.dir, "code", "R", "creditIndex.R")) -source(file.path(code.dir, "code", "R", "tranche_functions.R")) +library(logging) +source("yieldcurve.R") +source("optimization.R") +source("calibration.R") +source("serenitasdb.R") +source("creditIndex.R") +source("tranche_functions.R") tradedate <- as.Date("2016-08-02") exportYC(tradedate) |
