aboutsummaryrefslogtreecommitdiffstats
path: root/python/gfs_monitor.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/gfs_monitor.py')
-rw-r--r--python/gfs_monitor.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/python/gfs_monitor.py b/python/gfs_monitor.py
new file mode 100644
index 00000000..5bfa6b53
--- /dev/null
+++ b/python/gfs_monitor.py
@@ -0,0 +1,61 @@
+from serenitas.analytics.dates import prev_business_day
+from serenitas.utils.db import dbconn
+from serenitas.utils.exchange import ExchangeMessage
+import datetime
+import logging
+
+_recipients = {
+ "BOWDST": (
+ "shkumar@sscinc.com",
+ "hedgemark.lmcg.ops@sscinc.com",
+ "hm-operations@bnymellon.com",
+ ),
+ "SERCGMAST": (
+ "SERENITAS.FA@sscinc.com",
+ "SERENITAS.ops@sscinc.com",
+ ),
+}
+
+
+def _formatting(gfs_values):
+ if not gfs_values:
+ return None
+ else:
+ return "\n".join(
+ f"\t* {amount} {currency}" for currency, amount in gfs_values.items()
+ )
+
+
+def gfs_values(ped, conn, fund):
+ sql_str = "SELECT endqty, invccy FROM valuation_reports vr WHERE fund=%s AND port ='GFS_HELPER_BUSINESS_UNIT' AND periodenddate =%s AND abs(endqty) > 50000;"
+ with conn.cursor() as c:
+ c.execute(sql_str, (fund, ped))
+ return _formatting({row.invccy: row.endqty for row in c})
+
+
+if __name__ == "__main__":
+ import argparse
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ "workdate",
+ nargs="?",
+ type=datetime.date.fromisoformat,
+ default=prev_business_day(datetime.date.today()),
+ help="working date",
+ )
+ args = parser.parse_args()
+ logger = logging.getLogger(__name__)
+ conn = dbconn("dawndb")
+ em = ExchangeMessage()
+ for fund in ("BOWDST", "SERCGMAST"):
+ if vals := gfs_values(args.workdate, conn, fund):
+ em.send_email(
+ f"GFS Helper Strategy Issue: {fund}",
+ "Good morning, \n\nWe noticed some cash in the GFS helper strategy that shouldn't be there:\n\n"
+ + vals,
+ to_recipients=_recipients[fund],
+ cc_recipients=(
+ "Bowdoin-Ops@LMCG.com" if fund == "BOWDST" else "NYOps@lmcg.com",
+ ),
+ )