aboutsummaryrefslogtreecommitdiffstats
path: root/python/collateral
diff options
context:
space:
mode:
Diffstat (limited to 'python/collateral')
-rw-r--r--python/collateral/__main__.py2
-rw-r--r--python/collateral/cs.py37
2 files changed, 24 insertions, 15 deletions
diff --git a/python/collateral/__main__.py b/python/collateral/__main__.py
index 37e8c2ff..34cc51ac 100644
--- a/python/collateral/__main__.py
+++ b/python/collateral/__main__.py
@@ -46,7 +46,7 @@ cp_dict = {
"isda_cps": ("citi", "baml_isda", "ms", "gs", "bnp", "cs"),
},
"Brinker": {"fcms": (), "isda_cps": ("ms", "gs")},
- "BowdSt": {"fcms": ("gs_fcm",), "isda_cps": ("ms", "bnp", "gs", "baml_isda")},
+ "BowdSt": {"fcms": ("gs_fcm",), "isda_cps": ("ms", "bnp", "gs", "baml_isda", "cs")},
}
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,
)