diff options
| -rw-r--r-- | python/citco_monitor.py | 55 | ||||
| -rw-r--r-- | python/report_ops/misc.py | 7 |
2 files changed, 61 insertions, 1 deletions
diff --git a/python/citco_monitor.py b/python/citco_monitor.py index 7200c92b..dfb22f51 100644 --- a/python/citco_monitor.py +++ b/python/citco_monitor.py @@ -1,9 +1,61 @@ import datetime +from exchangelib import HTMLBody from serenitas.analytics.dates import prev_business_day from serenitas.utils.db import dbconn -from report_ops.utils import check_cleared_cds +from report_ops.utils import check_cleared_cds, Monitor +from report_ops.misc import _recon_recipients, _cc_recipients + + +class BondFactorMonitor( + Monitor, + headers=( + "date", + "citco_security_id", + "security_id", + "serenitas_factor", + "admin_factor", + "difference", + ), + num_format=[("{0:,.2f}", 3), ("{0:,.2f}", 4), ("{0:,.2f}", 5)], +): + @classmethod + def email(cls, fund): + if not cls._staging_queue: + return + cls._em.send_email( + f"*ACTION REQUESTED* Incorrect Factors: {fund}", + HTMLBody( + f""" +<html> + <head> + <style> + table, th, td {{ border: 1px solid black; border-collapse: collapse;}} + th, td {{ padding: 5px; }} + </style> + </head> + <body> + Hello,<br><br>We see the below factor rematches. Could you please correct these factors?<br><br>{cls.to_tabulate()} + </body> +</html>""" + ), + to_recipients=_recon_recipients[fund], + cc_recipients=_cc_recipients[fund], + ) + + +def check_bond_factors(date, fund, conn): + with conn.cursor() as c: + c.execute( + "SELECT citco_security_id, security_id, serenitas_factor, admin_factor, serenitas_factor-admin_factor as difference FROM compare_citco_bonds (%s, %s) WHERE abs(serenitas_factor - admin_factor) > .01;", + (date, fund), + ) + for row in c: + d = row._asdict() | {"date": date} + BondFactorMonitor.stage(d) + BondFactorMonitor.email(fund) + if __name__ == "__main__": import argparse @@ -20,3 +72,4 @@ if __name__ == "__main__": conn = dbconn("dawndb") for fund in ("ISOSEL",): check_cleared_cds(args.cob, fund, conn) + check_bond_factors(args.cob, fund, conn) diff --git a/python/report_ops/misc.py b/python/report_ops/misc.py index e86c8129..184aeb3d 100644 --- a/python/report_ops/misc.py +++ b/python/report_ops/misc.py @@ -79,6 +79,13 @@ _valuation_recipients = { "ISOSEL": ("BHu@citco.com", "zzCFSDubPricing2@citco.com"), } +_recon_recipients = { + "ISOSEL": ( + "RGillis@citco.com", + "InnocapMO@citco.com", + ) +} + _cc_recipients = { "ISOSEL": ("selene-ops@lmcg.com",), "BOWDST": ("bowdoin-ops@lmcg.com",), |
