aboutsummaryrefslogtreecommitdiffstats
path: root/python/collateral/jpm.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/collateral/jpm.py')
-rw-r--r--python/collateral/jpm.py23
1 files changed, 17 insertions, 6 deletions
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"]