diff options
Diffstat (limited to 'python/report_ops')
| -rw-r--r-- | python/report_ops/__main__.py | 4 | ||||
| -rw-r--r-- | python/report_ops/custodians.py | 36 | ||||
| -rw-r--r-- | python/report_ops/misc.py | 7 | ||||
| -rw-r--r-- | python/report_ops/utils.py | 25 |
4 files changed, 34 insertions, 38 deletions
diff --git a/python/report_ops/__main__.py b/python/report_ops/__main__.py index 68708109..2f49169c 100644 --- a/python/report_ops/__main__.py +++ b/python/report_ops/__main__.py @@ -1,4 +1,5 @@ from serenitas.analytics.dates import prev_business_day +from serenitas.utils.exchange import ExchangeMessage from serenitas.utils.db import dbconn import logging import argparse @@ -93,8 +94,9 @@ if args.wire_reports: if args.send_to_custodians: conn = dbconn("dawndb") + em = ExchangeMessage() for account in ("UMB", "BBH"): try: - upload_to_custodian(account, args.date, conn, not args.no_upload) + upload_to_custodian(account, args.date, conn, not args.no_upload, em) except ValueError as e: logger.info(e) diff --git a/python/report_ops/custodians.py b/python/report_ops/custodians.py index eab6cb9f..36703f54 100644 --- a/python/report_ops/custodians.py +++ b/python/report_ops/custodians.py @@ -1,8 +1,8 @@ -from serenitas.utils.exchange import ExchangeMessage +from serenitas.utils.exchange import ExchangeMessage, FileAttachment from serenitas.utils.env import DAILY_DIR import warnings import datetime -from .misc import get_dir +from .misc import get_dir, _recipients, _cc_recipients import gpg from serenitas.ops.trade_dataclasses import BondDeal from serenitas.ops.funds import Service @@ -11,21 +11,28 @@ from dataclasses import dataclass _sql = ( "INSERT INTO bond_csv_upload (allocationid, identifier, principal, interest) SELECT id, identifier, principal_payment, " - "accrued_payment FROM bond_trades WHERE trade_date=%s AND account=%s AND tradeid IS NOT NULL ON CONFLICT DO NOTHING RETURNING *" + "accrued_payment FROM bond_trades WHERE trade_date=%s AND account=%s AND tradeid IS NOT NULL ON CONFLICT DO NOTHING RETURNING allocationid;" ) +_bond_query = "SELECT * FROM bond_trades WHERE id in %s;" -def upload_to_custodian(account, trade_date, conn, upload): - _fund = {"BBH": "BRINKER", "UMB": "UMB"} - custodian = Service[_fund[account]] + +def upload_to_custodian(account, trade_date, conn, upload, em): + _service = {"BBH": "BRINKER", "UMB": "UMB"} + _fund = {"BBH": "BRINKER", "UMB": "SERCGMAST"} + custodian = Service[_service[account]] with conn.cursor() as c: c.execute( _sql, ( trade_date, - account, + "BAC" if account == "UMB" else account, ), ) + tids = tuple(row.allocationid for row in c) + if not tids: + return + c.execute(_bond_query, (tids,)) for row in c: trade = BondDeal.from_dict(**row._asdict(), scaled=True) match account: @@ -37,6 +44,15 @@ def upload_to_custodian(account, trade_date, conn, upload): custodian.staging_queue.clear() conn.commit() if upload: + em = ExchangeMessage() + em.send_email( + f"{account}: Bond Positions Uploaded for {trade_date}", + "Hi, \nWe've just uploaded the positions via SFTP. File receipt attached to this email", + _recipients.get(account, _cc_recipients[_fund[account]]), + cc_recipients=_cc_recipients[_fund[account]], + reply_to=_cc_recipients[_fund[account]], + attach=(FileAttachment(name=dest.name, content=buf),), + ) custodian.upload(buf, dest.name, confirm=account != "UMB") @@ -82,7 +98,7 @@ class UMB(Custodian, account="UMB"): for attach in msg.attachments: timestamp = attach.last_modified_time if ( - attach.name.startswith("cash_reporting") + attach.name.startswith("cash_balances_umb") and timestamp.date() == date ): dest = get_dir(timestamp.date(), archived=False) @@ -138,7 +154,3 @@ class BNY(Custodian, account="BONY2"): p.parent.mkdir(parents=True, exist_ok=True) if not p.exists(): p.write_bytes(attach.content) - - -class BBH(Custodian, account="BBH"): - pass diff --git a/python/report_ops/misc.py b/python/report_ops/misc.py index 6d435efe..76ec9cbb 100644 --- a/python/report_ops/misc.py +++ b/python/report_ops/misc.py @@ -18,7 +18,13 @@ _recipients = { "SERENITAS.ops@sscinc.com", ), "BAML_FCM": ("footc_margin_csr_amrs@bofa.com",), + "GS_FCM": ( + "Susan.Olesky@ny.email.gs.com", + "Divyanshi.Girotra@gs.com", + "gs-margin-calls-dcs@ny.email.gs.com", + ), "NYOPS": ("nyops@lmcg.com",), + "UMB": ("lmcgcustody@umb.com",), } _sma_recipients = { @@ -38,6 +44,7 @@ _cc_recipients = { "ISOSEL": ("selene-ops@lmcg.com",), "BOWDST": ("bowdoin-ops@lmcg.com",), "SERCGMAST": ("nyops@lmcg.com",), + "BRINKER": ("nyops@lmcg.com",), } diff --git a/python/report_ops/utils.py b/python/report_ops/utils.py index 1eadde96..b624b1f8 100644 --- a/python/report_ops/utils.py +++ b/python/report_ops/utils.py @@ -275,31 +275,6 @@ class GFSMonitor(Payment): ) -class BamlFcmNotify: - @classmethod - def email_fcm(cls, date, cash_account, data): - em = ExchangeMessage() - em.send_email( - f"FX Details: {cash_account} {date}", - 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>Please see below details for an FX Spot Trade we did with the desk today for account {cash_account} Please let me know if you need more information.<br><br>{data} - </body> -</html>""" - ), - to_recipients=_recipients["BAML_FCM"], - cc_recipients=("nyops@lmcg.com",), - ) - - @dataclass class EmailOps: _em = ExchangeMessage() |
