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