aboutsummaryrefslogtreecommitdiffstats
path: root/python/otc_fx.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/otc_fx.py')
-rw-r--r--python/otc_fx.py86
1 files changed, 0 insertions, 86 deletions
diff --git a/python/otc_fx.py b/python/otc_fx.py
deleted file mode 100644
index 8dacf876..00000000
--- a/python/otc_fx.py
+++ /dev/null
@@ -1,86 +0,0 @@
-import datetime
-from tabulate import tabulate
-from exchangelib import HTMLBody
-
-from serenitas.utils.db2 import dbconn
-from serenitas.utils.exchange import ExchangeMessage
-
-from report_ops.utils import Monitor
-
-from report_ops.misc import _settlement_recipients, _cc_recipients
-
-
-class FXMonitor(
- Monitor,
- headers=(
- "dealid",
- "counterparty_id",
- "trade_date",
- "settle_date",
- "cp_code",
- "name",
- "buy_currency",
- "buy_amount",
- "sell_currency",
- "sell_amount",
- ),
- num_format=[("{0:,.2f}", 7), ("{0:,.2f}", 9)],
-):
- @classmethod
- def email(cls, fund, settle_date):
- if not cls._staging_queue:
- return
- cls._em.send_email(
- f"FX Settlements {fund}: {settle_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>We see the below FX Settlements for VD {settle_date}. Could you please draft wires and reach out to the counterparty? As these are electronically agreed, please send out the funds regardless of confirmation from counterparty.<br><br>{cls.to_tabulate()}
- </body>
-</html>"""
- ),
- to_recipients=_settlement_recipients[fund],
- cc_recipients=_cc_recipients[fund],
- )
-
-
-def email_setts(settle_date, conn, fund):
- QUERY = "SELECT dealid, trade_date, settle_date, ft.cp_code, ft.name, buy_currency, buy_amount, sell_currency, sell_amount, cpty_id as counterparty_id FROM forward_trades ft LEFT JOIN accounts2 USING (cash_account) WHERE accounts2.fund=%s AND ft.settle_date=%s AND accounts2.account_type='Cash';"
- with conn.cursor() as c:
- c.execute(
- QUERY,
- (fund, settle_date),
- )
- for rec in c:
- d = rec._asdict()
- FXMonitor.stage(d)
- FXMonitor.email(fund, settle_date)
- FXMonitor.clear()
-
-
-if __name__ == "__main__":
- import argparse
-
- parser = argparse.ArgumentParser()
- parser.add_argument(
- "date",
- nargs="?",
- type=datetime.date.fromisoformat,
- default=datetime.date.today(),
- help="working date",
- )
- args = parser.parse_args()
- conn = dbconn("dawndb")
- for fund in (
- "SERCGMAST",
- "ISOSEL",
- # "BOWDST",
- ):
- email_setts(args.date, conn, fund)