aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/collateral/gs.py24
-rw-r--r--python/external_deriv_marks.py6
2 files changed, 18 insertions, 12 deletions
diff --git a/python/collateral/gs.py b/python/collateral/gs.py
index 6b88069f..61b9d803 100644
--- a/python/collateral/gs.py
+++ b/python/collateral/gs.py
@@ -1,12 +1,16 @@
import pandas as pd
from . import DAILY_DIR
+paths = {
+ "Serenitas": ["NYops", "Margin calls"],
+ "Brinker": ["NYops", "Margin Calls GS-Brinker"],
+ "BowdSt": ["BowdoinOps", "Margin GS"],
+}
-def download_files(em, count=20, **kwargs):
- emails = em.get_msgs(
- path=["NYops", "Margin calls"], count=count, subject__contains="Margin"
- )
- DATA_DIR = DAILY_DIR / "GS_reports"
+
+def download_files(em, count=20, *, fund="Serenitas", **kwargs):
+ emails = em.get_msgs(path=paths[fund], count=count, subject__contains="Margin")
+ DATA_DIR = DAILY_DIR / fund / "GS_reports"
for msg in emails:
for attach in msg.attachments:
fname = attach.name
@@ -16,22 +20,22 @@ def download_files(em, count=20, **kwargs):
p.write_bytes(attach.content)
-def load_file(d, pattern):
+def load_file(d, fund, pattern):
try:
- fname = next((DAILY_DIR / "GS_reports").glob(f"{pattern}*{d:%d_%b_%Y}*"))
+ fname = next((DAILY_DIR / fund / "GS_reports").glob(f"{pattern}*{d:%d_%b_%Y}*"))
except StopIteration:
raise FileNotFoundError(f"GS {pattern} file not found for date {d}")
return pd.read_excel(fname, skiprows=9, skipfooter=77)
-def collateral(d, dawn_trades, **kwargs):
- df = load_file(d, "Collateral_Detail")
+def collateral(d, dawn_trades, *, fund="Serenitas", **kwargs):
+ df = load_file(d, fund, "Collateral_Detail")
df = df.dropna(subset=["Quantity"])
try:
collateral = float(df.Quantity)
except TypeError:
collateral = df.Quantity.sum()
- df = load_file(d, "Trade_Detail")
+ df = load_file(d, fund, "Trade_Detail")
df = df.dropna(subset=["GS Entity"])
df = df[df["Notional (USD)"] != 0.0]
df = df[["Trade Id", "Transaction Type", "NPV (USD)", "Initial Margin Required"]]
diff --git a/python/external_deriv_marks.py b/python/external_deriv_marks.py
index 7b6ee322..bd9cf97a 100644
--- a/python/external_deriv_marks.py
+++ b/python/external_deriv_marks.py
@@ -7,10 +7,12 @@ from collateral.citi import load_pdf, get_col
from dates import bus_day
-def gs_navs(date: datetime.date = None, **kwargs):
+def gs_navs(date: datetime.date = None, fund: str = "Serenitas"):
d = {}
date_str = date.strftime("%d_%b_%Y") if date else ""
- for fname in (DAILY_DIR / "GS_reports").glob(f"Trade_Detail*{date_str}*.xls"):
+ for fname in (DAILY_DIR / fund / "GS_reports").glob(
+ f"Trade_Detail*{date_str}*.xls"
+ ):
try:
df = pd.read_excel(fname, skiprows=9, skipfooter=77, index_col="Trade Id")
except ValueError: