diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/collateral/__main__.py | 5 | ||||
| -rw-r--r-- | python/collateral/baml_isda.py | 12 | ||||
| -rw-r--r-- | python/collateral/citi.py | 6 |
3 files changed, 13 insertions, 10 deletions
diff --git a/python/collateral/__main__.py b/python/collateral/__main__.py index e2958d27..f8781003 100644 --- a/python/collateral/__main__.py +++ b/python/collateral/__main__.py @@ -41,6 +41,7 @@ dawn_trades = get_dawn_trades(args.workdate, dawn_engine) df = {} mapping = {"baml_fcm": "BAML", "wells": "WF"} +args.workdate -= BDay() for cp in counterparties: cp_mod = import_module("." + cp, "collateral") if cp in ["baml_fcm", "wells"]: @@ -63,10 +64,6 @@ for cp in counterparties: ) except ValueError as e: logger.error(e) - if ( - cp == "baml_isda" - ): # all cp except CITI and BAML operate on previous business day - args.workdate = args.workdate - BDay() df = pd.concat(df, names=["broker", "strategy"]).reset_index() df.strategy = df.strategy.str.replace("^(M_|SER_)?", "", 1) diff --git a/python/collateral/baml_isda.py b/python/collateral/baml_isda.py index 4df80c68..619ce309 100644 --- a/python/collateral/baml_isda.py +++ b/python/collateral/baml_isda.py @@ -139,18 +139,24 @@ def load_excel(fname): def collateral(d, dawn_trades, *args): + report_date = d + BDay() REPORTS_DIR = DAILY_DIR / "BAML_ISDA_reports" try: - fname = next(REPORTS_DIR.glob(f"Collat_*{d:%m%d%Y}_*.xls")) + fname = next(REPORTS_DIR.glob(f"Collat_*{report_date:%m%d%Y}_*.xls")) except StopIteration: - raise ValueError(f"no data for date {d}") + raise ValueError(f"no collateral data for date {report_date}") df = pd.read_excel(fname, skiprows=6, skipfooter=6) df = df.drop(0, axis=0) try: collateral = float(df.Notional) except TypeError: collateral = df.Notional.sum() - fname = next(REPORTS_DIR.glob(f"301__LMCG_INVESTMENTSLP_CSA_{d:%m%d%Y}_*")) + try: + fname = next( + REPORTS_DIR.glob(f"301__LMCG_INVESTMENTSLP_CSA_{report_date:%m%d%Y}_*") + ) + except StopIteration: + raise ValueError(f"no trade-level data for date {report_date}") df = load_excel(fname) df = df[["Trade ID", "MTM(USD)"]] df = df.merge(dawn_trades, how="left", left_on="Trade ID", right_on="cpty_id") diff --git a/python/collateral/citi.py b/python/collateral/citi.py index b1d51eb0..5ea8ce60 100644 --- a/python/collateral/citi.py +++ b/python/collateral/citi.py @@ -102,8 +102,8 @@ def get_total_collateral(d): def collateral(d, dawn_trades, *args): - df = load_file(d) - collat = get_total_collateral(d - BDay()) + df = load_file(d + BDay()) + collat = get_total_collateral(d) df = df[["Operations File", "Market Value", "BasicAmt"]].dropna( subset=["Operations File"] ) # missing Operations File means assignment usually @@ -127,5 +127,5 @@ def collateral(d, dawn_trades, *args): }, ignore_index=True, ) - df["date"] = d - bus_day + df["date"] = d return df.set_index("Strategy") |
