diff options
| -rw-r--r-- | R/build_portfolios.R | 4 | ||||
| -rw-r--r-- | R/build_scenarios.R | 4 | ||||
| -rw-r--r-- | python/calibrate_tranches_BC.py | 7 | ||||
| -rw-r--r-- | python/notebooks/Beta & Compression.ipynb | 6 | ||||
| -rw-r--r-- | python/notebooks/path.py | 5 |
5 files changed, 8 insertions, 18 deletions
diff --git a/R/build_portfolios.R b/R/build_portfolios.R index ed00f011..218d4952 100644 --- a/R/build_portfolios.R +++ b/R/build_portfolios.R @@ -5,7 +5,7 @@ library(dplyr, quiet = TRUE, warn.conflict = F) args <- commandArgs(trailingOnly = TRUE) stopifnot((root.dir <- Sys.getenv("BASE_DIR")) != "") -stopifnot((code.dir <- Sys.getenv("CODE_DIR")) != "") +stopifnot((config.dir <- Sys.getenv("SERENITAS_CONFIG_DIR")) != "") source("intex_deal_functions.R") source("yieldcurve.R") source("creditIndex.R") @@ -29,7 +29,7 @@ calibration.date <- addBusDay(workdate, -1) exportYC(calibration.date) index <- creditIndex("hy35") index <- set.index.desc(index, calibration.date) -global.params <- yaml.load_file(file.path(code.dir, "etc", "params.yml"), +global.params <- yaml.load_file(file.path(config.dir, "params.yml"), handlers = list(expr = function(x) eval(parse(text = x)))) cusipdata <- cusip.data(workdate) diff --git a/R/build_scenarios.R b/R/build_scenarios.R index 2097ffab..8760b619 100644 --- a/R/build_scenarios.R +++ b/R/build_scenarios.R @@ -11,7 +11,7 @@ if(hostname=="debian"){ args <- commandArgs(trailingOnly=TRUE) stopifnot((root.dir <- Sys.getenv("BASE_DIR")) != "") -stopifnot((code.dir <- Sys.getenv("CODE_DIR")) != "") +stopifnot((config.dir <- Sys.getenv("SERENITAS_CONFIG_DIR")) != "") source("intex_deal_functions.R") source("yieldcurve.R") source("serenitasdb.R") @@ -42,7 +42,7 @@ Ngrid <- 201 support <- seq(0, 1, length = Ngrid) n.scenarios <- 100 recov.adj <- 1 -params <- yaml.load_file(file.path(code.dir, "etc", "params.yml"), +params <- yaml.load_file(file.path(config.dir, "params.yml"), handlers = list(expr = function(x) eval(parse(text = x)))) for(j in seq_along(dealnames)){ diff --git a/python/calibrate_tranches_BC.py b/python/calibrate_tranches_BC.py index b1a06de5..361f1bfb 100644 --- a/python/calibrate_tranches_BC.py +++ b/python/calibrate_tranches_BC.py @@ -1,11 +1,9 @@ -from serenitas.utils.db import dbconn from serenitas.analytics.tranche_basket import TrancheBasket, MarkitTrancheBasket from serenitas.analytics.utils import prev_business_day import datetime import logging import numpy as np import pandas as pd -from pathlib import Path from yaml import full_load import argparse @@ -38,6 +36,8 @@ def build_sql_str(df, use_markit=False): if __name__ == "__main__": from serenitas.utils import SerenitasFileHandler + from serenitas.utils.db import dbconn + from serenitas.utils.env import CONFIG_DIR logger = logging.getLogger("tranche_calib") parser = argparse.ArgumentParser() @@ -76,7 +76,6 @@ if __name__ == "__main__": if args.markit: TrancheBasket = MarkitTrancheBasket - CODE_DIR = Path(__file__).absolute().parent.parent if not args.debug: handler = SerenitasFileHandler(f"calib_tranches_{datetime.date.today()}.log") else: @@ -131,7 +130,7 @@ if __name__ == "__main__": raise ValueError("Please provide an index to run") config = {"runs": [(args.index, args.tenor, args.skewtype)]} else: - with (CODE_DIR / "etc" / args.config).open("r") as fh: + with (CONFIG_DIR / args.config).open("r") as fh: config = full_load(fh) for index, tenor, skewtype in config["runs"]: diff --git a/python/notebooks/Beta & Compression.ipynb b/python/notebooks/Beta & Compression.ipynb index e7874f4e..8e908988 100644 --- a/python/notebooks/Beta & Compression.ipynb +++ b/python/notebooks/Beta & Compression.ipynb @@ -8,10 +8,6 @@ "source": [ "%matplotlib inline\n", "\n", - "import os\n", - "import sys\n", - "sys.path.append(os.path.join(os.environ['CODE_DIR'], 'python', 'exploration'))\n", - "sys.path.append(os.path.join(os.environ['CODE_DIR'], 'python'))\n", "import beta_trade\n", "import matplotlib.pyplot as plt\n", "from scipy.stats.mstats import zscore" @@ -202,7 +198,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.0" + "version": "3.9.1" } }, "nbformat": 4, diff --git a/python/notebooks/path.py b/python/notebooks/path.py deleted file mode 100644 index 9d22534b..00000000 --- a/python/notebooks/path.py +++ /dev/null @@ -1,5 +0,0 @@ -import sys -import os -sys.path.append(os.path.join(os.environ['CODE_DIR'], 'python')) -sys.path.append(os.path.join(os.environ['CODE_DIR'], 'python', - 'exploration')) |
