diff options
Diffstat (limited to 'python/upload_umb_bonds.py')
| -rw-r--r-- | python/upload_umb_bonds.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/python/upload_umb_bonds.py b/python/upload_umb_bonds.py index e53d0071..438734f9 100644 --- a/python/upload_umb_bonds.py +++ b/python/upload_umb_bonds.py @@ -11,16 +11,27 @@ if __name__ == "__main__": default=datetime.date.today(), ) args = parser.parse_args() + sql_query = ( + "SELECT bonds.*, bond_allocation.notional, fund, custodian, " + "cash_account, bond_submission.id as sid, allocation_id, action, " + "counterparties.name, dtc_number " + "FROM bonds " + "INNER JOIN bond_allocation ON bond_allocation.tradeid=bonds.id " + "INNER JOIN accounts USING (code) " + "INNER JOIN bond_submission ON allocation_id=bond_allocation.id " + "INNER JOIN counterparties ON counterparties.code = bonds.cp_code " + "WHERE fund= %s and trade_date = %s " + "ORDER BY fund, allocation_id, bonds" + ) with BondDeal._conn.cursor() as c: c.execute( - "SELECT id FROM bond_trades WHERE fund= %s " "AND trade_date = %s ", + sql_query, ( "SERCGMAST", args.trade_date, ), ) - for (tid,) in c: - trade = BondDeal.from_allocationid(tid) - UMB.staging_queue.append(next(trade.to_umb("NEW"))) + for row in c: + UMB.stage(row._asdict(), trade_type="bond", redis_pipeline=None) buf, dest = UMB.build_buffer("bond") UMB.upload(buf, dest) |
