diff options
Diffstat (limited to 'python/lmcg_monitor.py')
| -rw-r--r-- | python/lmcg_monitor.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/python/lmcg_monitor.py b/python/lmcg_monitor.py new file mode 100644 index 00000000..5f8230cd --- /dev/null +++ b/python/lmcg_monitor.py @@ -0,0 +1,50 @@ +import datetime +import argparse +from serenitas.analytics.dates import prev_business_day +from serenitas.utils.db import dbconn +from serenitas.utils.exchange import ExchangeMessage +from report_ops.utils import CDXNotionalMonitor + + +def monitor_scotia(date, conn): + with conn.cursor() as c: + c.execute( + "SELECT 1 FROM cash_balances cb WHERE fund='ISOSEL' AND account_number = '476960681512' AND date=%s;" + ) + if not (_ := c.fetchone()): + em = ExchangeMessage() + em.send_email( + f"*Action Requested* Scotia Balance Missing {date}", + "Please enter missing cash balance to the blotter.", + to_recipients=("Nyops@lmcg.com",), + ) + + +def monitor_cds_notional(fund, date, conn): + with conn.cursor() as c: + c.execute( + "SELECT *, notional as serenitas_notional, globeop_notional / factor as admin_notional FROM list_cds_marks(%s, NULL, %s) WHERE abs((notional * factor) - globeop_notional) > 100;", + (date, fund), + ) + for row in c: + d = row._asdict() + d["difference"] = d["serenitas_notional"] - d["globeop_notional"] + CDXNotionalMonitor.stage(d) + CDXNotionalMonitor.email(fund) + CDXNotionalMonitor._staging_queue.clear() + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument( + "cob", + nargs="?", + type=datetime.date.fromisoformat, + default=prev_business_day(datetime.date.today()), + help="working date", + ) + args = parser.parse_args() + conn = dbconn("dawndb") + monitor_scotia(args.cob, conn) + for fund in ("SERCGMAST", "BOWDST", "ISOSEL"): + monitor_cds_notional(fund, args.cob, conn) |
