aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/collateral_calc.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/python/collateral_calc.py b/python/collateral_calc.py
index 139e89a0..69e96c35 100644
--- a/python/collateral_calc.py
+++ b/python/collateral_calc.py
@@ -45,7 +45,7 @@ def download_files(d=None,
ftp.retrbinary('RETR ' + f, fh.write)
-def download_emails():
+def download_ms_emails():
emails = get_msgs(path=["NYops"], subject_filter="SERCX **Daily")
DATA_DIR = DAILY_DIR / "MS_reports"
for msg in emails:
@@ -55,6 +55,17 @@ def download_emails():
with open(DATA_DIR / fname, "wb") as fh:
fh.write(attach.content)
+def download_gs_emails():
+ emails = get_msgs(path=["NYops", "Margin calls"],
+ subject_filter="Regulatory VM Margin")
+ DATA_DIR = DAILY_DIR / "GS_reports"
+ for msg in emails:
+ for attach in msg.attachments:
+ fname = attach.name
+ if fname.endswith('xls'):
+ with open(DATA_DIR / fname, "wb") as fh:
+ fh.write(attach.content)
+
def sg_collateral(d):
df_activity = pd.read_csv(DAILY_DIR / "SG_reports" / f"{d:%Y%m%d}_OTC_CASH_ACTIVITY.csv")
@@ -144,7 +155,8 @@ def send_email(account, df_ms, df_sg):
if __name__ == "__main__":
- download_emails()
+ download_ms_emails()
+ download_gs_emails()
d = (pd.Timestamp.today() - BDay()).normalize()
download_files(d)
df_ms = ms_collateral(d - BDay())