aboutsummaryrefslogtreecommitdiffstats
path: root/python/citco_ops/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/citco_ops/utils.py')
-rw-r--r--python/citco_ops/utils.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/python/citco_ops/utils.py b/python/citco_ops/utils.py
index ba863a01..b2b5b356 100644
--- a/python/citco_ops/utils.py
+++ b/python/citco_ops/utils.py
@@ -6,6 +6,7 @@ import csv
from serenitas.ops.trade_dataclasses import Deal
from serenitas.utils.exchange import ExchangeMessage
from psycopg.errors import UniqueViolation
+from typing import ClassVar
logger = logging.getLogger(__name__)
@@ -119,3 +120,42 @@ class CitcoSubmission(Deal, deal_type=None, table_name="citco_submission"):
)
finally:
cls._insert_queue.clear()
+
+
+_recipients = {
+ "ISOSEL": (
+ "simon.oreilly@innocap.com",
+ "margincalls@innocapglobal.com",
+ ),
+}
+
+
+@dataclass
+class PaymentSettlement:
+ settle_date: datetime.date
+ currency: str
+ amount: float
+ _insert_queue: ClassVar[list] = []
+
+ @classmethod
+ def stage_payment(cls, settlements):
+ for row in settlements:
+ cls._insert_queue.append(
+ cls(row.settle_date, row.currency, row.payment_amount)
+ )
+
+ def to_innocap(self):
+ return f"\t* {self.settle_date}: {self.amount:,.2f} {self.currency}"
+
+ @classmethod
+ def email_innocap(cls, date):
+ if not cls._insert_queue:
+ return
+ em = ExchangeMessage()
+ em.send_email(
+ f"Payment Settlements Bond NT: ISOSEL {date}",
+ "Good morning, \n\nWe have the following amounts settling in the next few days at Northern Trust: (Positive Amounts = Receive, Negative Amounts=Pay)\n\n"
+ + "\n".join(settlement.to_innocap() for settlement in cls._insert_queue),
+ to_recipients=_recipients["ISOSEL"],
+ cc_recipients=("Selene-Ops@lmcg.com",),
+ )