diff options
Diffstat (limited to 'python/collateral/cs.py')
| -rw-r--r-- | python/collateral/cs.py | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/python/collateral/cs.py b/python/collateral/cs.py index 5fe5865e..479ec4ec 100644 --- a/python/collateral/cs.py +++ b/python/collateral/cs.py @@ -1,14 +1,18 @@ import pandas as pd from . import DAILY_DIR -from pandas.tseries.offsets import BDay -from .common import load_pdf +from .common import load_pdf, next_business_day +paths = { + "Serenitas": ["NYops", "Margin Calls CS"], + "BowdSt": ["BowdoinOps", "Margin CS"], +} -def download_files(em, count=20, **kwargs): - DATA_DIR = DAILY_DIR / "CS_reports" - emails = em.get_msgs( - path=["NYops", "Margin Calls CS"], count=count, subject__contains="DERV048829" - ) + +def download_files(em, count=20, *, fund="Serenitas", **kwargs): + if fund not in paths: + return + DATA_DIR = DAILY_DIR / fund / "CS_reports" + emails = em.get_msgs(path=paths[fund], count=count, subject__contains="DERV048829") for msg in emails: for attach in msg.attachments: fname = attach.name @@ -18,7 +22,7 @@ def download_files(em, count=20, **kwargs): p.write_bytes(attach.content) emails = em.get_msgs( - path=["NYops", "Margin Calls CS"], + path=paths[fund], count=count, sender="americas.collateralmgt@credit-suisse.com", ) @@ -37,13 +41,18 @@ def download_files(em, count=20, **kwargs): p.write_bytes(attach.content) -def get_collateral(d): - DATA_DIR = DAILY_DIR / "CS_reports" +def get_collateral(d, fund): + DATA_DIR = DAILY_DIR / fund / "CS_reports" collat = 0 + full_name = { + "Serenitas": "SerenitasCGMF", + "BowdSt": "BostonBPStLLC", + } + for collat_type in ("RVM", "IM"): pdf_file = ( DATA_DIR - / f"CollateralCptyStatement161SerenitasCGMF{collat_type}_{d:%m%d%Y}.pdf" + / f"CollateralCptyStatement161{full_name[fund]}{collat_type}_{d:%m%d%Y}.pdf" ) g = iter(load_pdf(pdf_file)) for e in g: @@ -55,10 +64,10 @@ def get_collateral(d): return collat -def collateral(d, dawn_trades, **kwargs): - collateral = get_collateral(d + BDay()) +def collateral(d, dawn_trades, *, fund="Serenitas", **kwargs): + collateral = get_collateral(next_business_day(d), fund) df = pd.read_excel( - f"/home/serenitas/Daily/CS_reports/DERV048829_{d:%b%d%Y}.xlsx", + DAILY_DIR / fund / "CS_reports" / f"DERV048829_{d:%b%d%Y}.xlsx", header=9, skipfooter=50, ) |
