diff options
| -rw-r--r-- | python/position_file_bowdst.py | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/python/position_file_bowdst.py b/python/position_file_bowdst.py index 2d45ead0..c89714d7 100644 --- a/python/position_file_bowdst.py +++ b/python/position_file_bowdst.py @@ -106,7 +106,7 @@ with dawndb.cursor() as c: process_upload(trades, "bond") c.execute( - "SELECT trb.trade_id, trb.serenitas_clean_nav + trb.serenitas_accrued as mtm, cds.* FROM tranche_risk_bowdst trb left join cds on trade_id=id WHERE date=%s", + "SELECT trb.trade_id, trb.serenitas_clean_nav + trb.serenitas_accrued as mtm, trb.notional as active_notional, cds.* FROM tranche_risk_bowdst trb left join cds on trade_id=id WHERE date=%s", (date,), ) trades = [] @@ -115,7 +115,9 @@ with dawndb.cursor() as c: obj["Client Name"] = "HEDGEMARK" obj["Fund Name"] = "BOS_PAT_BOWDOIN" obj["Product Type"] = "Credit Index Tranche" - # obj['TransactionIndicator (Buy/Sell)'] = 'Buyer' if obj['notional'] > 0 else 'Seller' + obj["TransactionIndicator (Buy/Sell)"] = ( + "B" if obj["protection"] == "Buyer" else "S" + ) obj["MTM Currency"] = "USD" obj["COB Date"] = date obj["Clearing House Name"] = "Bilateral" @@ -125,16 +127,53 @@ with dawndb.cursor() as c: "dealid": "Unique Deal ID", "cp_code": "Counterparty", "currency": "DealCurrencyA", - "notional": "NotionalA", + "active_notional": "NotionalA", "fixed_rate": "FixedRate", "trade_date": "Start Date", "effective_date": "EffectiveDate", "maturity": "Maturity Date", "security_id": "Underlying (ISIN / CUSP / RED CODES)", "security_desc": "Underlying Desc", - "protection": "TransactionIndicator (Buy/Sell)", "mtm": "MTM Valuation", }, ) trades.append(obj) process_upload(trades, "otc") + c.execute( + "SELECT abs(spr.notional) AS active_notional, spr.serenitas_nav, swaptions.*, index_version_markit.annexdate FROM list_swaption_positions_and_risks(%s, 'BOWDST') spr LEFT JOIN swaptions ON deal_id=dealid LEFT JOIN index_version_markit ON swaptions.security_id=redindexcode;", + (date,), + ) + trades = [] + for row in c: + obj = row._asdict() + obj["Client Name"] = "HEDGEMARK" + obj["Fund Name"] = "BOS_PAT_BOWDOIN" + obj["Product Type"] = "CD Swaption" + obj["TransactionIndicator (Buy/Sell)"] = "B" if obj["buysell"] else "S" + obj["PutCall Indicator (Call/Put)"] = ( + "P" if obj["option_type"] == "PAYER" else "C" + ) + obj["Exercise Type"] = "European" + obj["MTM Currency"] = "USD" + obj["COB Date"] = date + obj["Clearing House Name"] = "Bilateral" + rename_keys( + obj, + { + "dealid": "Unique Deal ID", + "cp_code": "Counterparty", + "currency": "DealCurrencyA", + "active_notional": "NotionalA", + "fixed_rate": "FixedRate", + "strike": "Strike", + "annexdate": "EffectiveDate", + "trade_date": "Start Date", + "maturity": "Maturity Date", + "expiration_date": "Underlying Maturity", + "security_id": "Underlying (ISIN / CUSP / RED CODES)", + "security_desc": "Underlying Desc", + "serenitas_nav": "MTM Valuation", + }, + ) + trades.append(obj) + process_upload(trades, "otc") |
