diff options
| -rw-r--r-- | python/globeop_monitor.py | 23 | ||||
| -rw-r--r-- | python/report_ops/utils.py | 38 |
2 files changed, 60 insertions, 1 deletions
diff --git a/python/globeop_monitor.py b/python/globeop_monitor.py index 9fc64960..12faddd9 100644 --- a/python/globeop_monitor.py +++ b/python/globeop_monitor.py @@ -7,7 +7,12 @@ from serenitas.utils.db import dbconn from serenitas.ops.trade_dataclasses import WireDeal from serenitas.ops.funds import Service -from report_ops.utils import GFSMonitor, check_cleared_cds, BondMarkMonitor +from report_ops.utils import ( + GFSMonitor, + StratMonitor, + check_cleared_cds, + BondMarkMonitor, +) from collateral.common import CASH_STRATEGY_MAPPING, STRATEGY_CASH_MAPPING @@ -26,6 +31,21 @@ def check_gfs(date, fund, conn): GFSMonitor._staging_queue.clear() +def check_random_strat(date, fund, conn): + with conn.cursor() as c: + c.execute( + "SELECT gfstranid1, invdesc, knowledgedate, periodenddate, port, strat FROM valuation_reports vr WHERE fund=%s AND periodenddate=%s AND port='SERCGMAST';", + ( + fund, + date, + ), + ) + for row in c: + StratMonitor.stage(row._asdict()) + StratMonitor.email(fund) + StratMonitor._staging_queue.clear() + + def reallocate_strategy_cash(date, fund, conn): service = Service[fund] with conn.cursor() as c: @@ -100,5 +120,6 @@ if __name__ == "__main__": match fund: case "SERCGMAST": check_manager_marks(args.cob, "SERCGMAST", conn) + check_random_strat(args.cob, "SERCGMAST", conn) case "BOWDST": reallocate_strategy_cash(args.cob, "BOWDST", conn) diff --git a/python/report_ops/utils.py b/python/report_ops/utils.py index a108c0cd..5ca1a155 100644 --- a/python/report_ops/utils.py +++ b/python/report_ops/utils.py @@ -160,6 +160,44 @@ class GFSMonitor( ) +class StratMonitor( + Monitor, + headers=( + "periodenddate", + "gfstranid1", + "invdesc", + "knowledgedate", + "periodenddate", + "port", + "strat", + ), + num_format=[], +): + @classmethod + def email(cls, fund): + if not cls._staging_queue: + return + cls._em.send_email( + f"Invalid Strategy Issue: {fund}", + HTMLBody( + f""" +<html> + <head> + <style> + table, th, td {{ border: 1px solid black; border-collapse: collapse;}} + th, td {{ padding: 5px; }} + </style> + </head> + <body> + Good morning,<br><br>The below strategies should not exist. Could you please fix this?<br><br>{cls.to_tabulate()} + </body> +</html>""" + ), + to_recipients=_recipients[fund], + cc_recipients=_cc_recipients[fund], + ) + + class BondMarkMonitor( Monitor, headers=( |
