diff options
Diffstat (limited to 'python/collateral/jpm.py')
| -rw-r--r-- | python/collateral/jpm.py | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/python/collateral/jpm.py b/python/collateral/jpm.py index 5d2a5cf7..242030e2 100644 --- a/python/collateral/jpm.py +++ b/python/collateral/jpm.py @@ -84,17 +84,30 @@ def download_files(em, count=20, *, fund="BowdSt", **kwargs): def collateral(d, dawn_trades, *, fund="BowdSt", **kwargs): - pdf_file = load_file(d, fund) - pages = load_pdf(pdf_file, pages=True) try: - collat = get_collateral(pages[3]) - except IndexError: - collat = 0.0 - try: - df = pd.concat([load_positions(pages[4]), load_positions(pages[5])]) - except StopIteration: - # No TRS - df = load_positions(pages[4]) + df = pd.read_excel( + load_file(d, fund, ext="xls"), + sheet_name="Open Positions", + skiprows=14, + skipfooter=13, + ) + breakpoint() + df["Deal ID"] = "810RI" + df["Deal ID"].str.extract(r"([^-]*)-.*") + collat = pd.read_excel( + load_file(d, fund, ext="xls"), sheet_name="Collateral Holdings" + ).iloc[-1][-1] + except StopIteration: # PDF method + pdf_file = load_file(d, fund) + pages = load_pdf(pdf_file, pages=True) + try: + collat = get_collateral(pages[3]) + except IndexError: + collat = 0.0 + try: + df = pd.concat([load_positions(pages[4]), load_positions(pages[5])]) + except StopIteration: + # No TRS + df = load_positions(pages[4]) df = df.merge(dawn_trades, how="left", left_on="Deal ID", right_on="cpty_id") missing_ids = df.loc[df.cpty_id.isnull(), "Deal ID"] if not missing_ids.empty: |
