diff options
Diffstat (limited to 'python/position_file_bowdst.py')
| -rw-r--r-- | python/position_file_bowdst.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/python/position_file_bowdst.py b/python/position_file_bowdst.py index 2e0f9084..f3dfa90a 100644 --- a/python/position_file_bowdst.py +++ b/python/position_file_bowdst.py @@ -125,7 +125,33 @@ with dawndb.cursor() as c: obj["Currency"] = "USD" obj["SecurityType"] = "Bond" trades.append(obj) - process_upload(trades, "bond") + process_upload(trades, "bond") + + c.execute( + "WITH tmp AS (SELECT bbg_ticker, fund, security_desc, currency, maturity, sum(quantity * (2*buysell::int-1)) OVER (PARTITION BY bbg_ticker, fund, security_desc, currency, maturity) notional FROM futures " + "WHERE fund='BOWDST' AND trade_date <= %s) " + "SELECT bbg_ticker, notional, code AS cp_code, cash_account, security_desc, currency, maturity FROM tmp LEFT JOIN accounts USING (fund) WHERE tmp.notional != 0 AND account_type='Future';", + (date,), + ) + trades = [] + for row in c: + obj = row._asdict() + rename_keys( + obj, + { + "bbg_ticker": "BBGTicker", + "notional": "Quantity", + "cp_code": "Prime Broker", + "cash_account": "AccountNumber", + "security_desc": "SecurityDescription", + "currency": "Currency", + "maturity": "MaturityDate", + }, + ) + obj["COB Date"] = date + obj["SecurityType"] = "Futures" + trades.append(obj) + process_upload(trades, "future") c.execute( "SELECT trb.trade_id, trb.serenitas_clean_nav + trb.serenitas_accrued as mtm, trb.notional * trb.tranche_factor as active_notional, cds.* FROM tranche_risk_bowdst trb left join cds on trade_id=id WHERE date=%s", |
