diff options
| -rw-r--r-- | R/build_portfolios.R | 14 | ||||
| -rw-r--r-- | R/build_scenarios.R | 10 | ||||
| -rw-r--r-- | R/creditIndex.R | 6 | ||||
| -rw-r--r-- | R/pretty_plots.R | 3 | ||||
| -rw-r--r-- | R/yieldcurve.R | 8 | ||||
| -rw-r--r-- | python/common.py | 2 | ||||
| -rw-r--r-- | python/task_server/insert_tranche_quotes.py | 2 |
7 files changed, 16 insertions, 29 deletions
diff --git a/R/build_portfolios.R b/R/build_portfolios.R index 6697ca22..cef04db6 100644 --- a/R/build_portfolios.R +++ b/R/build_portfolios.R @@ -3,10 +3,10 @@ library("yaml") args <- commandArgs(trailingOnly=TRUE) -if(.Platform$OS.type == "unix"){ - root.dir <- "/home/share/CorpCDOs" +if(Sys.getenv("DATA_DIR") == ""){ + root.dir <- "/home/serenitas/CorpCDOs" }else{ - root.dir <- "//WDSENTINEL/share/CorpCDOs" + 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") @@ -25,12 +25,6 @@ if(interactive()) { argslist <- strsplit(args[-1], ",") dealnames <- unlist(lapply(argslist, function(x)x[1])) reinvflags <- as.logical(unlist(lapply(argslist, function(x)x[2]))) - }else{ - data <- read.table(file.path(root.dir, "scripts", "deals_to_price.txt"), - colClasses=c("character", "logical")) - dealnames <- data$V1 - reinvflags <- data$V2 - } workdate <- if(length(args) >=1) as.Date(args[1]) else Sys.Date() } @@ -38,7 +32,7 @@ calibration.date <- addBusDay(workdate, -1) exportYC(calibration.date) index <- creditIndex("hy27") index <- set.index.desc(index, calibration.date) -global.params <- yaml.load_file(file.path(root.dir, "code", "etc", "params.yml")) +global.params <- yaml.load_file(file.path(code.dir, "etc", "params.yml")) cusipdata <- cusip.data(workdate) cashspread.discount <- 0 diff --git a/R/build_scenarios.R b/R/build_scenarios.R index a0187762..c484adde 100644 --- a/R/build_scenarios.R +++ b/R/build_scenarios.R @@ -10,10 +10,10 @@ if(hostname=="debian"){ args <- commandArgs(trailingOnly=TRUE) -if(.Platform$OS.type == "unix"){ - root.dir <- "/home/share/CorpCDOs" -}else{ - root.dir <- "//WDSENTINEL/share/CorpCDOs" +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") @@ -47,7 +47,7 @@ Ngrid <- 201 support <- seq(0, 1, length = Ngrid) n.scenarios <- 100 recov.adj <- 1 -params <- yaml.load_file(file.path(root.dir, "code", "etc", "params.yml")) +params <- yaml.load_file(file.path(code.dir, "etc", "params.yml")) for(j in seq_along(dealnames)){ load(file.path(root.dir, "Scenarios", paste("Portfolios", tradedate, sep="_"), diff --git a/R/creditIndex.R b/R/creditIndex.R index 68986e81..3788b2a2 100644 --- a/R/creditIndex.R +++ b/R/creditIndex.R @@ -1,7 +1,7 @@ -root.dir <- if(.Platform$OS.type == "unix"){ - "/home/share/CorpCDOs" +root.dir <- if(Sys.getenv("DATA_DIR") == ""){ + "/home/serenitas/CorpCDOs" }else{ - "//WDSENTINEL/share/CorpCDOs" + file.path(Sys.getenv("DATA_DIR"), "..") } library(lossdistrib) diff --git a/R/pretty_plots.R b/R/pretty_plots.R index e883910f..5a46f174 100644 --- a/R/pretty_plots.R +++ b/R/pretty_plots.R @@ -1,6 +1,5 @@ library(ggplot2) -root.dir <- "/home/share/CorpCDOs/" -source(file.path(root.dir, "code", "R", "load_cf.R")) +source(file.path(Sys.getenv("CODE_DIR"), "R", "load_cf.R")) date <- Sys.Date() dists <- list() diff --git a/R/yieldcurve.R b/R/yieldcurve.R index fd6c5744..7cf3317b 100644 --- a/R/yieldcurve.R +++ b/R/yieldcurve.R @@ -1,11 +1,5 @@ require(RQuantLib) -root.dir <- if(.Platform$OS.type == "unix"){ - "/home/share/CorpCDOs" -}else{ - "//WDSENTINEL/share/CorpCDOs" -} - -source(file.path(root.dir, "code", "R", "db.R")) +source(file.path(Sys.getenv("CODE_DIR"), "R", "db.R")) getMarkitIRData <- function(date=Sys.Date(), currency=c("USD", "EUR")) { ## returns Markit rates from serenitasdb diff --git a/python/common.py b/python/common.py index 557189a4..009f0ba6 100644 --- a/python/common.py +++ b/python/common.py @@ -3,7 +3,7 @@ import os if os.name =='nt': root = "//WDsentinel/share/CorpCDOs" elif os.name == 'posix': - root = '/home/share/CorpCDOs' + root = '/home/serenitas/CorpCDOs' def sanitize_float(intex_float): try: diff --git a/python/task_server/insert_tranche_quotes.py b/python/task_server/insert_tranche_quotes.py index 58a6e207..02d93190 100644 --- a/python/task_server/insert_tranche_quotes.py +++ b/python/task_server/insert_tranche_quotes.py @@ -36,7 +36,7 @@ runningdict2 = {0: 500, 3:500, 7:500, 10:100, 15:100, 30:100} def insert_quotes(year=2016, quote_dir=None):
if not quote_dir:
- root_dir = '/home/share/CorpCDOs'
+ root_dir = '/home/serenitas/CorpCDOs'
quote_dir = os.path.join(root_dir, 'Tranche_data', 'Quotes')
quotefiles = [f for f in os.listdir(quote_dir) if f.endswith('csv')]
for quotefile in quotefiles:
|
