diff options
Diffstat (limited to 'python/collateral/baml_isda.py')
| -rw-r--r-- | python/collateral/baml_isda.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/python/collateral/baml_isda.py b/python/collateral/baml_isda.py index 995ce3e8..badb5f0c 100644 --- a/python/collateral/baml_isda.py +++ b/python/collateral/baml_isda.py @@ -81,11 +81,15 @@ def download_files(d=None, count=20): def collateral(d, dawn_trades, *args): - fname = ( - DAILY_DIR - / "BAML_ISDA_reports" - / f"Interest Rates Trade Summary_{d:%d-%b-%Y}.xls" - ) + REPORTS_DIR = DAILY_DIR / "BAML_ISDA_reports" + try: + fname = next(REPORTS_DIR.glob(f"Collat_*{d:%m%d%Y}_*.xls")) + except StopIteration: + raise ValueError("no data for date {d}") + df = pd.read_excel(fname, skiprows=6, skipfooter=6) + df = df.drop(0, axis=0) + collateral = float(df.Notional) + fname = REPORTS_DIR / f"Interest Rates Trade Summary_{d:%d-%b-%Y}.xls" # TODO: make more robust df = pd.read_excel(fname, skiprows=6, nrows=1) df = df[["Trade ID", "MTM(USD)"]] @@ -101,7 +105,6 @@ def collateral(d, dawn_trades, *args): df = df.reset_index() df.columns = ["Strategy", "Amount", "Currency"] df.Amount *= -1 - collateral = 910_000 df = df.append( { "Strategy": "M_CSH_CASH", |
