diff options
Diffstat (limited to 'python/ctm_allocation.py')
| -rw-r--r-- | python/ctm_allocation.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/python/ctm_allocation.py b/python/ctm_allocation.py index ba143ce7..7a18232f 100644 --- a/python/ctm_allocation.py +++ b/python/ctm_allocation.py @@ -5,22 +5,22 @@ from serenitas.ops.funds import CTM def main(trade_date, upload): - with BondDeal._conn.cursor() as c, BondDeal._conn.cursor() as d: + conn = BondDeal._conn + with conn.cursor() as c: c.execute( - "SELECT id FROM bonds LEFT JOIN counterparties ON cp_code=code " - "WHERE trade_date=%s AND ctm_code IS NOT NULL AND not emailed", + "UPDATE bonds SET emailed=True FROM counterparties " + "WHERE trade_date=%s AND ctm_code IS NOT NULL AND NOT emailed AND cp_code=code RETURNING id", (trade_date,), ) for (tid,) in c: trade = BondDeal.from_tradeid(tid) CTM.stage(trade) - d.execute("UPDATE bonds SET emailed=True WHERE id=%s", (tid,)) if not CTM.staging_queue: return buf, dest = CTM.build_buffer() if upload: CTM.upload(buf) - BondDeal._conn.commit() + conn.commit() if __name__ == "__main__": |
