aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/report_ops/__main__.py14
-rw-r--r--python/report_ops/utils.py50
2 files changed, 63 insertions, 1 deletions
diff --git a/python/report_ops/__main__.py b/python/report_ops/__main__.py
index 18416eb3..c0700d66 100644
--- a/python/report_ops/__main__.py
+++ b/python/report_ops/__main__.py
@@ -8,7 +8,7 @@ from .cash import CashReport
from .admin import CitcoReport
from .wires import Wire
from .custodians import upload_to_custodian
-from .utils import notify_payment_settlements, PaymentMonitor
+from .utils import notify_payment_settlements, notify_fx_hedge, PaymentMonitor, FxHedge
from .misc import _fund_custodians
logger = logging.getLogger(__name__)
@@ -46,6 +46,12 @@ parser.add_argument(
help="notify payment settlements by email",
)
parser.add_argument(
+ "-fh",
+ "--fx_hedge",
+ action="store_true",
+ help="return fx trades",
+)
+parser.add_argument(
"-n", "--no-upload", action="store_true", help="do not upload, just create files"
)
parser.add_argument(
@@ -108,3 +114,9 @@ if args.payment_settlements:
for fund in ("SERCGMAST", "BRINKER", "BOWDST", "ISOSEL"):
notify_payment_settlements(args.date, fund, conn)
PaymentMonitor._staging_queue.clear()
+
+if args.fx_hedge:
+ conn = dbconn("dawndb")
+ for fund in ("SERCGMAST", "BOWDST", "ISOSEL"):
+ notify_fx_hedge(cob, fund, conn)
+ FxHedge._staging_queue.clear()
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()