diff options
Diffstat (limited to 'python/reallocate_iam.py')
| -rw-r--r-- | python/reallocate_iam.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/python/reallocate_iam.py b/python/reallocate_iam.py index 3fdd4959..b92b95f4 100644 --- a/python/reallocate_iam.py +++ b/python/reallocate_iam.py @@ -17,6 +17,7 @@ def gen_old_iam(fund, cob, conn): for row in c: d = row._asdict() yield IAMDeal.from_dict(**d) + conn.commit() def gen_new_iam(fund, cob, conn): @@ -58,12 +59,13 @@ def gen_matured_iam(fund, cob, conn): """Sets previous days as matured""" with conn.cursor() as c: c.execute( - "UPDATE iam_tickets SET maturity=%s WHERE maturity is NULL AND trade_date<%s AND fund=%s RETURNING *", + "UPDATE iams SET maturity=%s WHERE maturity is NULL AND trade_date<=%s AND fund=%s RETURNING *", (cob, prev_business_day(cob), fund), ) for row in c: - d = row._asdict() + d = row._asdict() | {} yield IAMDeal.from_dict(**d) + conn.commit() def build_iam(fund, cob, conn, upload): @@ -75,7 +77,6 @@ def build_iam(fund, cob, conn, upload): if fund in ("BOWDST"): for new_iam_offset in gen_new_iam_offsets(fund, cob, conn): new_iam_offset.stage() - conn.commit() for iam in IAMDeal.commit(returning=True): service.push_trade(iam, "NEW") for update_iam in gen_matured_iam(fund, cob, conn): |
