aboutsummaryrefslogtreecommitdiffstats
path: root/python/populate_tranche_cashflows.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/populate_tranche_cashflows.py')
-rw-r--r--python/populate_tranche_cashflows.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/python/populate_tranche_cashflows.py b/python/populate_tranche_cashflows.py
index a76aabaf..2b1355a1 100644
--- a/python/populate_tranche_cashflows.py
+++ b/python/populate_tranche_cashflows.py
@@ -49,18 +49,20 @@ def insert_tranche_cashflows(
with dawndb.cursor() as c:
for tranche_id, principal, accrued in data:
c.execute(
- "INSERT INTO tranche_cashflows VALUES(%s, %s, %s, %s, %s) ON CONFLICT ON CONSTRAINT tranche_cashflows_pkey DO NOTHING",
+ "INSERT INTO tranche_cashflows VALUES(%s, %s, %s, %s, %s) "
+ "ON CONFLICT (date, tranche_id) DO NOTHING",
(auction_date + bus_day, tranche_id, principal, accrued, "USD"),
)
dawndb.commit()
-def insert_tranche_accrued(d: datetime.date, dawndb, fund="SERCGMAST"):
- portf = get_tranche_portfolio(d, dawndb, funds=(fund,))
+def insert_tranche_accrued(d: datetime.date, dawndb, funds=("SERCGMAST",)):
+ portf = get_tranche_portfolio(d, dawndb, funds=funds)
with dawndb.cursor() as c:
for t in portf:
c.execute(
- "INSERT INTO tranche_cashflows(date, tranche_id, accrued, currency) ON CONFLICT ON CONSTRAINT tranche_cashflows_pkey DO NOTHING"
+ "INSERT INTO tranche_cashflows(date, tranche_id, accrued, currency) "
+ "ON CONFLICT (date, tranche_id) DO NOTHING"
"VALUES(%s, %s, %s, %s)",
(
t.cs["payment_dates"][0],
@@ -99,5 +101,5 @@ if __name__ == "__main__":
import serenitas.analytics
serenitas.analytics._include_todays_cashflows = True
- for fund in ("SERCGMAST", "BOWDST", "BRINKER", "ISOSEL"):
- insert_tranche_accrued(datetime.date(2022, 12, 16), dawndb, fund)
+ funds = ("SERCGMAST", "BOWDST", "BRINKER", "ISOSEL")
+ insert_tranche_accrued(datetime.date(2022, 12, 16), dawndb, funds)