diff options
Diffstat (limited to 'python/collateral')
| -rw-r--r-- | python/collateral/__main__.py | 2 | ||||
| -rw-r--r-- | python/collateral/common.py | 2 | ||||
| -rw-r--r-- | python/collateral/jpm.py | 23 |
3 files changed, 20 insertions, 7 deletions
diff --git a/python/collateral/__main__.py b/python/collateral/__main__.py index 03f37ea5..38e09608 100644 --- a/python/collateral/__main__.py +++ b/python/collateral/__main__.py @@ -55,7 +55,7 @@ workdate = prev_business_day(args.workdate) cp_dict = { "Serenitas": { "fcms": ("baml_fcm", "wells"), - "isda_cps": ("citi", "baml_isda", "ms", "gs", "bnp", "cs"), + "isda_cps": ("citi", "baml_isda", "jpm", "ms", "gs", "bnp", "cs"), }, "Brinker": {"fcms": (), "isda_cps": ("ms", "gs")}, "BowdSt": { diff --git a/python/collateral/common.py b/python/collateral/common.py index a943986d..e278c2cb 100644 --- a/python/collateral/common.py +++ b/python/collateral/common.py @@ -17,6 +17,7 @@ CASH_STRATEGY_MAPPING = { "IGEQY", "HYMEZ", "HYEQY", + "HYSNR", "BSPK", "XOMEZ", "XOEQY", @@ -97,6 +98,7 @@ def send_email(d: datetime.date, df: pd.DataFrame) -> None: "WELLS": "Wells Fargo", "BNP": "BNP Paribas", "CS": "Credit Suisse", + "JPM": "JP Morgan", } html = "<html><body>" for cp, df in df.groupby(level="broker"): diff --git a/python/collateral/jpm.py b/python/collateral/jpm.py index 9e0eb818..fe6ee474 100644 --- a/python/collateral/jpm.py +++ b/python/collateral/jpm.py @@ -1,4 +1,3 @@ -import datetime import pandas as pd from io import BytesIO from pikepdf import Pdf @@ -7,16 +6,23 @@ from .common import load_pdf, get_col, parse_num paths = { - # "Serenitas": ["NYops", "Margin Calls JPM"], + "Serenitas": ["NYops", "Margin Calls JPM"], "BowdSt": ["BowdoinOps", "Margin JPM"], } +accounts = { + "BowdSt": "909271", + "Serenitas": "923550", +} + +passwords = {"BowdSt": "tm64EO", "Serenitas": "JV3RJu"} + def load_file(d, fund): try: fname = next( (DAILY_DIR / fund / "JPM_reports").glob( - f"CSCFTCSTMT-*-{d:%y%m%d}-909271_2.pdf" + f"CSCFTCSTMT-*-{d:%y%m%d}-{accounts[fund]}_2.pdf" ) ) except StopIteration: @@ -52,7 +58,9 @@ def load_positions(positions_page): def download_files(em, count=20, *, fund="BowdSt", **kwargs): if fund not in paths: return - emails = em.get_msgs(path=paths[fund], count=count, subject__startswith="909271") + emails = em.get_msgs( + path=paths[fund], count=count, subject__contains=accounts[fund] + ) DATA_DIR = DAILY_DIR / fund / "JPM_reports" for msg in emails: for attach in msg.attachments: @@ -60,14 +68,17 @@ def download_files(em, count=20, *, fund="BowdSt", **kwargs): p = DATA_DIR / fname if not p.exists(): stream = BytesIO(attach.content) - pdf = Pdf.open(stream, password="tm64EO") + pdf = Pdf.open(stream, password=passwords[fund]) pdf.save(p) def collateral(d, dawn_trades, *, fund="BowdSt", **kwargs): pdf_file = load_file(d, fund) pages = load_pdf(pdf_file, pages=True) - collat = get_collateral(pages[3]) + try: + collat = get_collateral(pages[3]) + except IndexError: + collat = 0.0 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"] |
