diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/citco_ops/utils.py | 38 | ||||
| -rw-r--r-- | python/gfs_monitor.py | 53 |
2 files changed, 45 insertions, 46 deletions
diff --git a/python/citco_ops/utils.py b/python/citco_ops/utils.py index b2b5b356..3cdf2ce5 100644 --- a/python/citco_ops/utils.py +++ b/python/citco_ops/utils.py @@ -127,11 +127,20 @@ _recipients = { "simon.oreilly@innocap.com", "margincalls@innocapglobal.com", ), + "BOWDST": ( + "shkumar@sscinc.com", + "hedgemark.lmcg.ops@sscinc.com", + "hm-operations@bnymellon.com", + ), + "SERCGMAST": ( + "SERENITAS.FA@sscinc.com", + "SERENITAS.ops@sscinc.com", + ), } @dataclass -class PaymentSettlement: +class Payment: settle_date: datetime.date currency: str amount: float @@ -144,9 +153,11 @@ class PaymentSettlement: cls(row.settle_date, row.currency, row.payment_amount) ) - def to_innocap(self): + def to_email_format(self): return f"\t* {self.settle_date}: {self.amount:,.2f} {self.currency}" + +class PaymentSettlement(Payment): @classmethod def email_innocap(cls, date): if not cls._insert_queue: @@ -155,7 +166,28 @@ class PaymentSettlement: em.send_email( f"Payment Settlements Bond NT: ISOSEL {date}", "Good morning, \n\nWe have the following amounts settling in the next few days at Northern Trust: (Positive Amounts = Receive, Negative Amounts=Pay)\n\n" - + "\n".join(settlement.to_innocap() for settlement in cls._insert_queue), + + "\n".join( + settlement.to_email_format() for settlement in cls._insert_queue + ), to_recipients=_recipients["ISOSEL"], cc_recipients=("Selene-Ops@lmcg.com",), ) + + +class GFSMonitor(Payment): + @classmethod + def email_globeop(cls, fund): + if not cls._insert_queue: + return + em = ExchangeMessage() + 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" + + "\n".join( + settlement.to_email_format() for settlement in cls._insert_queue + ), + to_recipients=_recipients[fund], + cc_recipients=( + "Bowdoin-Ops@LMCG.com" if fund == "BOWDST" else "NYOps@lmcg.com", + ), + ) diff --git a/python/gfs_monitor.py b/python/gfs_monitor.py index 6e5ea735..9e3187bb 100644 --- a/python/gfs_monitor.py +++ b/python/gfs_monitor.py @@ -1,44 +1,16 @@ +import datetime +import logging 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:,.2f} {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}) - +from citco_ops.utils import GFSMonitor if __name__ == "__main__": import argparse parser = argparse.ArgumentParser() parser.add_argument( - "workdate", + "cob", nargs="?", type=datetime.date.fromisoformat, default=prev_business_day(datetime.date.today()), @@ -47,15 +19,10 @@ if __name__ == "__main__": args = parser.parse_args() logger = logging.getLogger(__name__) conn = dbconn("dawndb") + 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;" 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", - ), - ) + with conn.cursor() as c: + for fund in ("BOWDST", "SERCGMAST"): + c.execute(sql_str, (fund, args.cob)) + GFSMonitor.stage_payment(c) + GFSMonitor.email_globeop(fund) |
