aboutsummaryrefslogtreecommitdiffstats
path: root/python/report_ops/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/report_ops/utils.py')
-rw-r--r--python/report_ops/utils.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/python/report_ops/utils.py b/python/report_ops/utils.py
index 2d9f69e5..7884697e 100644
--- a/python/report_ops/utils.py
+++ b/python/report_ops/utils.py
@@ -79,6 +79,20 @@ def notify_payment_settlements(date, fund, conn):
PaymentMonitor.email(fund)
+def notify_fx_hedge(date, fund, conn):
+ with conn.cursor() as c:
+ c.execute(
+ "SELECT * from fcm_moneyline LEFT JOIN accounts2 ON account=cash_account WHERE date=%s AND currency='EUR' AND fund=%s AND abs(current_excess_deficit) > 1000000",
+ (date, fund),
+ )
+ for row in c:
+ d = row._asdict()
+ d["amount"] = d["current_excess_deficit"]
+ d["category"] = "FCM"
+ FxHedge.stage(d)
+ FxHedge.email(fund)
+
+
@dataclass
class CitcoSubmission(Deal, deal_type=None, table_name="citco_submission2"):
id: int = field(init=False, metadata={"insert": False})
@@ -383,6 +397,42 @@ class PaymentMonitor(
)
+class FxHedge(
+ Monitor,
+ headers=(
+ "date",
+ "account",
+ "amount",
+ "currency",
+ "fund",
+ "category",
+ ),
+ num_format=[("{0:,.2f}", 2)],
+):
+ @classmethod
+ def email(cls, fund):
+ if not cls._staging_queue:
+ return
+ cls._em.send_email(
+ f"Projected Hedges: {fund}",
+ 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>Here are the positions we need to hedge:<br><br>{cls.to_tabulate()}
+ </body>
+</html>"""
+ ),
+ to_recipients=("fyu@lmcg.com",),
+ )
+
+
@dataclass
class EmailOps:
_em = ExchangeMessage()