aboutsummaryrefslogtreecommitdiffstats
path: root/python/collateral_calc.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/collateral_calc.py')
-rw-r--r--python/collateral_calc.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/python/collateral_calc.py b/python/collateral_calc.py
index af2e49c3..9bed262d 100644
--- a/python/collateral_calc.py
+++ b/python/collateral_calc.py
@@ -96,6 +96,7 @@ def download_ms_emails(count=20):
with open(DATA_DIR / fname, "wb") as fh:
fh.write(attach.content)
+
def download_gs_emails(count=20):
emails = get_msgs(path=["NYops", "Margin calls"],
subject_filter="Regulatory VM Margin",
@@ -180,15 +181,17 @@ def ms_collateral(d):
r.append(["M_CSH_CASH", -collat - acc, "USD"])
return pd.DataFrame.from_records(r, columns=['Strategy', 'Amount', 'Currency'])
+
def load_gs_file(d, pattern):
try:
- fname = next( (DAILY_DIR / "GS_reports").
- glob(f"{pattern}*{d.strftime('%d_%b_%Y')}*"))
+ fname = next((DAILY_DIR / "GS_reports").
+ glob(f"{pattern}*{d.strftime('%d_%b_%Y')}*"))
except StopIteration:
raise FileNotFoundError(f"GS {pattern} file not found for date {d}")
df = pd.read_excel(fname, skiprows=9, skipfooter=77)
return df
+
def gs_collateral(d):
df = load_gs_file(d, "Collateral_Detail")
collateral = float(df.Quantity)
@@ -207,6 +210,7 @@ def gs_collateral(d):
'Currency': "USD"}, ignore_index=True)
return df
+
def send_email(account, df_ms, df_sg, df_gs):
pd.set_option('display.float_format', '{:.2f}'.format)
content = HTMLBody('<html><body>'