diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/baml_fcm_fx.py | 86 | ||||
| -rw-r--r-- | python/citco_ops/utils.py | 4 |
2 files changed, 34 insertions, 56 deletions
diff --git a/python/baml_fcm_fx.py b/python/baml_fcm_fx.py index 56d2068f..163c2f02 100644 --- a/python/baml_fcm_fx.py +++ b/python/baml_fcm_fx.py @@ -3,6 +3,32 @@ from citco_ops.utils import BamlFcmNotify from serenitas.utils.db2 import dbconn from tabulate import tabulate + +def main(trade_date, conn, fund): + with conn.cursor() as c: + c.execute("SELECT * FROM baml_fcm_fx(%s, %s) ", (trade_date, fund)) + if rec := c.fetchone(): + rec = list(rec) + num_format = [("{0:,.2f}", 2), ("{0:.5f}", 4), ("{0:,.2f}", 5)] + for f, i in num_format: + rec[i] = f.format(rec[i]) + t = tabulate( + [rec], + headers=[ + "account", + "curr", + "TotBal", + "HomeCurrency", + "fxRate", + "convTotBal", + "BuySell", + "Value Date", + ], + tablefmt="unsafehtml", + ) + BamlFcmNotify.email_fcm(trade_date, rec[0], t) + + if __name__ == "__main__": import argparse @@ -15,57 +41,9 @@ if __name__ == "__main__": help="working date", ) args = parser.parse_args() - sql_str = ( - "SELECT settle_date, buy_currency, buy_amount, " - "sell_currency, sell_amount, spot_rate, cash_account FROM spots " - "WHERE cash_account in ('V0NSCLMSPT', '6MZ20K79') AND trade_date = %s" - ) - dawndb = dbconn("dawndb") - with dawndb.cursor() as c: - c.execute(sql_str, (args.date,)) - rec = next(iter(c)) - if rec: - if rec.buy_currency == "EUR": - cash_account = ( - "6MZ20049" if rec.cash_account == "V0NSCLMSPT" else rec.cash_account - ) - data = [ - cash_account, - "EUR", - -rec.buy_amount, - "USD", - rec.spot_rate, - rec.sell_amount, - "Buy", - rec.settle_date, - ] - else: - data = [ - cash_account, - "EUR", - rec.sell_amount, - "USD", - rec.spot_rate, - rec.buy_amount, - "Sell", - rec.settle_date, - ] - num_format = [("{0:,.2f}", 2), ("{0:.5f}", 4), ("{0:,.2f}", 5)] - for f, i in num_format: - data[i] = f.format(data[i]) - - t = tabulate( - [data], - headers=[ - "account", - "curr", - "TotBal", - "HomeCurrency", - "fxRate", - "convTotBal", - "BuySell", - "Value Date", - ], - tablefmt="unsafehtml", - ) - BamlFcmNotify.email_fcm(args.date, t, cash_account) + conn = dbconn("dawndb") + for fund in ( + "SERCGMAST", + "ISOSEL", + ): + main(args.date, conn, fund) diff --git a/python/citco_ops/utils.py b/python/citco_ops/utils.py index 5f122091..36839865 100644 --- a/python/citco_ops/utils.py +++ b/python/citco_ops/utils.py @@ -296,7 +296,7 @@ class GFSMonitor(Payment): class BamlFcmNotify: @classmethod - def email_fcm(cls, date, data, cash_account): + def email_fcm(cls, date, cash_account, data): em = ExchangeMessage() em.send_email( f"FX Details: {cash_account} {date}", @@ -310,7 +310,7 @@ class BamlFcmNotify: </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} + 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>""" ), |
