aboutsummaryrefslogtreecommitdiffstats
path: root/python/calibrate_tranches_BC.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/calibrate_tranches_BC.py')
-rw-r--r--python/calibrate_tranches_BC.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/python/calibrate_tranches_BC.py b/python/calibrate_tranches_BC.py
index ecf18383..10bb42dc 100644
--- a/python/calibrate_tranches_BC.py
+++ b/python/calibrate_tranches_BC.py
@@ -1,10 +1,9 @@
from utils.db import dbconn
from analytics.tranche_basket import TrancheBasket, MarkitTrancheBasket
-from pandas.tseries.offsets import BDay
+from analytics.utils import prev_business_day
import datetime
import logging
import numpy as np
-import os
import pandas as pd
from pathlib import Path
from yaml import full_load
@@ -60,9 +59,11 @@ if __name__ == "__main__":
"--tenor", default="5yr", help="Tenor we want to run [default '5yr']"
)
parser.add_argument(
- "--until", default=pd.Timestamp.now() - BDay(), type=pd.Timestamp
+ "--until",
+ default=prev_business_day(datetime.date.today()),
+ type=datetime.date.fromisoformat,
)
- parser.add_argument("--start_from", default=None, type=pd.Timestamp)
+ parser.add_argument("--start_from", default=None, type=datetime.date.fromisoformat)
parser.add_argument(
"-d", "--debug", action="store_true", help="more verbose logging"
)
@@ -75,7 +76,7 @@ if __name__ == "__main__":
if args.markit:
TrancheBasket = MarkitTrancheBasket
- CODE_DIR = Path(os.environ["CODE_DIR"])
+ CODE_DIR = Path(__file__).parent.parent
if not args.debug:
handler = SerenitasFileHandler(f"calib_tranches_{datetime.date.today()}.log")
else:
@@ -150,15 +151,13 @@ if __name__ == "__main__":
tranche_index = None
data = {}
- for d in dr:
- logger.debug(f"calibrating for {d.date()}")
+ for d in dr.date:
+ logger.debug(f"calibrating for {d}")
try:
if tranche_index is None:
- tranche_index = TrancheBasket(
- index, series, tenor, value_date=d.date()
- )
+ tranche_index = TrancheBasket(index, series, tenor, value_date=d)
else:
- tranche_index.value_date = d.date()
+ tranche_index.value_date = d
except (RuntimeError, ValueError) as e:
logger.error(e)
continue