aboutsummaryrefslogtreecommitdiffstats
path: root/python/calibrate_tranches.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/calibrate_tranches.py')
-rw-r--r--python/calibrate_tranches.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/python/calibrate_tranches.py b/python/calibrate_tranches.py
index 743a0df7..0c4f1099 100644
--- a/python/calibrate_tranches.py
+++ b/python/calibrate_tranches.py
@@ -16,17 +16,16 @@ with open("../R/index_definitions.yml") as fh:
indices['hy21']['maturity'] = datetime.date(1970, 1, 1) + datetime.timedelta(indices['hy21']['maturity'])
hy21 = indices['hy21']
hy21["startdate"] = datetime.date(2013, 9, 20)
-root = "/home/share/CorpCDOs"
-dates = [f[9:19] for f in os.listdir(os.path.join(root, "data", "Backtest")) if "survprob" in f]
+dates = [f[9:19] for f in os.listdir(os.path.join(os.environ['DATA_DIR'], "Backtest")) if "survprob" in f]
Rho = np.zeros((len(dates), 3))
for i, d in enumerate(dates):
startdate = datetime.datetime.strptime(d, "%Y-%m-%d")
ts = YC(startdate)
- with open(os.path.join(root, "data", "Backtest", "recov_{0}.csv".format(d))) as fh:
+ with open(os.path.join(os.environ['DATA_DIR'], "Backtest", "recov_{0}.csv".format(d))) as fh:
recov = np.array([float(e) for e in fh], dtype='double', order='F')
- with open(os.path.join(root, "data", "Backtest", "survprob_{0}.csv".format(d))) as fh:
+ with open(os.path.join(os.environ['DATA_DIR'], "Backtest", "survprob_{0}.csv".format(d))) as fh:
fh.readline() ##skip header
SurvProb = np.array([[float(e) for e in line.split(",")] for line in fh], dtype='double', order='F')
@@ -39,7 +38,7 @@ for i, d in enumerate(dates):
K = np.array([0, 0.15, 0.25, 0.35, 1])
Kmod = adjust_attachments(K, hy21["loss"], hy21["factor"])
- quotes = pd.read_csv(os.path.join(root, "Scenarios", "Calibration",
+ quotes = pd.read_csv(os.path.join(os.environ['BASE_DIR'], "Scenarios", "Calibration",
"hy21_tranches_{0}.csv".format(d)))
quotes = quotes["Mid"]/100
dK = np.diff(Kmod)