diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/notify_novations.py | 77 |
1 files changed, 72 insertions, 5 deletions
diff --git a/python/notify_novations.py b/python/notify_novations.py index caa3831a..a4ce00e7 100644 --- a/python/notify_novations.py +++ b/python/notify_novations.py @@ -1,4 +1,8 @@ import datetime +import argparse +from exchangelib import HTMLBody + +from report_ops.utils import Monitor from mtm_status import get_latest_file counterparty_contacts = { @@ -14,7 +18,7 @@ counterparty_contacts = { "dg.cmbs-mbex_trade_support@bofa.com", ), ("JPCBNY", "USD"): ("credit.na.affirmations@jpmorgan.com",), - ("JPCBNY", "EUR"): ("JPM.creditassignmentseurope@jpmorgan.com"), + ("JPCBNY", "EUR"): ("JPM.creditassignmentseurope@jpmorgan.com",), ("MSCSNY", "USD"): ("msnovationsteam@morganstanley.com",), ("GOLDNY", "USD"): ( "Navneet.Sawant@gs.com", @@ -26,13 +30,56 @@ counterparty_contacts = { "Vishal.Kanojia@ny.email.gs.com", "LDNCDMO@gs.com", ), - ("CITINY", "USD"): ("citiassignmentsus@citigroup.com, james.b.okun@citi.com"), - ("CITINY", "EUR"): ("citiassignmentsus@citigroup.com, aaron.beasant@citi.com"), + ("CITINY", "USD"): ( + "citiassignmentsus@citigroup.com", + "james.b.okun@citi.com", + ), + ("CITINY", "EUR"): ( + "citiassignmentsus@citigroup.com", + "aaron.beasant@citi.com", + ), ("BNPBNY", "USD"): ("LM_Sales_Assistants@US.BNPParibas.com",), ("BNPBNY", "EUR"): ("CDSnovationsEurope@bnpparibas.com",), } +class CreditNovationsMonitor( + Monitor, + headers=( + "date", + "ncm_id", + "EE", + "RP", + "currency", + ), + num_format=[], +): + @classmethod + def email(cls, date, contacts): + if not cls._staging_queue: + return + cls._em.send_email( + f"*ACTION REQUESTED* Unconsented Novations Due Today {date}", + 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>We have the below novations expiring today. Could you please consent or provide us an update on the novations?<br><br>{cls.to_tabulate()} + </body> +</html>""" + ), + to_recipients=contacts, + cc_recipients=("NYOPs@lmcg.com",), + reply_to=("NYOPs@lmcg.com",), + ) + + def contact_novation_counterparties(date): df = get_latest_file(date) df = df[ @@ -47,8 +94,28 @@ def contact_novation_counterparties(date): .reset_index() ) for row in df.itertuples(): - print(row.ExecutingBroker, row.RemainingBroker, row.CurrencyCode, row[4]) + d = { + "date": date, + "currency": row.CurrencyCode, + "EE": row.ExecutingBroker, + "RP": row.RemainingBroker, + } + contacts = ( + counterparty_contacts[(row.ExecutingBroker, row.CurrencyCode)] + + counterparty_contacts[(row.RemainingBroker, row.CurrencyCode)] + ) + for novationid in row[4]: + CreditNovationsMonitor.stage(d | {"ncm_id": novationid}) + CreditNovationsMonitor.email(date, contacts) + CreditNovationsMonitor.clear() if __name__ == "__main__": - contact_novation_counterparties(datetime.date(2023, 3, 14)) + parser = argparse.ArgumentParser() + parser.add_argument( + "date", + type=datetime.date.fromisoformat, + default=datetime.date.today(), + ) + args = parser.parse_args() + contact_novation_counterparties(args.date) |
