aboutsummaryrefslogtreecommitdiffstats
path: root/python/innocap_bond_setts.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/innocap_bond_setts.py')
-rw-r--r--python/innocap_bond_setts.py48
1 files changed, 9 insertions, 39 deletions
diff --git a/python/innocap_bond_setts.py b/python/innocap_bond_setts.py
index 49eb910d..124e0210 100644
--- a/python/innocap_bond_setts.py
+++ b/python/innocap_bond_setts.py
@@ -1,34 +1,8 @@
-from serenitas.utils.db import dbconn
-from serenitas.utils.exchange import ExchangeMessage
import datetime
import logging
-
-_recipients = {
- "ISOSEL": (
- "simon.oreilly@innocap.com",
- "margincalls@innocapglobal.com",
- ),
-}
-
-
-def _formatting(payment_values):
- if not payment_values:
- return None
- else:
- return "\n".join(
- f"\t* {settle_date}: {amount:,.2f} {currency}"
- for settle_date, (amount, currency) in payment_values.items()
- )
-
-
-def payment_values(ped, conn, fund):
- sql_str = "SELECT settle_date, currency, sum(payment_amount) as payment_amount FROM payment_settlements ps2 WHERE fund=%s AND asset_class='bond' AND %s < (settle_date + INTERVAL '5' DAY) group by settle_date, currency;"
- with conn.cursor() as c:
- c.execute(sql_str, (fund, ped))
- return _formatting(
- {row.settle_date: (row.payment_amount, row.currency) for row in c}
- )
-
+from serenitas.utils.db import dbconn
+from serenitas.utils.exchange import ExchangeMessage
+from citco_ops.utils import PaymentSettlement
if __name__ == "__main__":
import argparse
@@ -44,13 +18,9 @@ if __name__ == "__main__":
args = parser.parse_args()
logger = logging.getLogger(__name__)
conn = dbconn("dawndb")
- em = ExchangeMessage()
- for fund in ("ISOSEL",):
- if vals := payment_values(args.date, conn, fund):
- em.send_email(
- f"Payment Settlements Bond NT: {fund} {args.date}",
- "Good morning, \n\nWe have the following amounts settling in the next few days: (Positive Amounts = Receive, Negative Amounts=Pay)\n\n"
- + vals,
- to_recipients=_recipients[fund],
- cc_recipients=("Selene-Ops@lmcg.com",),
- )
+ sql_str = "SELECT settle_date, currency, sum(payment_amount) as payment_amount FROM payment_settlements ps2 WHERE fund=%s AND asset_class in ('bond', 'spot') AND %s < (settle_date + INTERVAL '5' DAY) group by settle_date, currency;"
+ with conn.cursor() as c:
+ for fund in ("ISOSEL",):
+ c.execute(sql_str, (fund, args.date))
+ PaymentSettlement.stage_payment(c)
+ PaymentSettlement.email_innocap(args.date)