diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/process_queue.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/python/process_queue.py b/python/process_queue.py index 81f7e200..0f156436 100644 --- a/python/process_queue.py +++ b/python/process_queue.py @@ -508,12 +508,12 @@ def build_line(obj, trade_type="bond"): obj, { "Settlement Date": "PremiumSettlementDate", - "Price": "PercentageOfPremium", "notional": "Notional", "initial_margin_percentage": "InitialMarginPercentage", }, ) - + obj["PremiumSettlementAmount"] = obj["Price"] * obj["Notional"] * obj["factor"] + obj["PremiumSettlementCurrency"] = obj["Currency"] obj["RegenerateCashFlow"] = "N" for direction in ["Pay", "Receive"]: obj[direction + "MaturityDate"] = obj["MaturityDate"] @@ -775,6 +775,21 @@ def is_tranche_trade(trade): return trade["swap_type"] in ("CD_INDEX_TRANCHE", "BESPOKE") +def swaption_trade_process(conn, session, trade): + sqlstr = ( + "SELECT indexfactor/100 FROM index_version " + "WHERE redindexcode=%(security_id)s" + ) + try: + with conn.cursor() as c: + c.execute(sqlstr, trade) + factor, = c.fetchone() + except ValueError: + return + else: + trade["factor"] = factor + + def cds_trade_process(conn, session, trade): sqlstr = ( "SELECT indexfactor/100 FROM index_version " @@ -915,7 +930,7 @@ if __name__ == "__main__": for trade_type in ["bond", "cds", "swaption", "future", "wire", "spot", "capfloor"]: list_trades = get_trades(q, trade_type, args.fund) if list_trades: - if trade_type in ["bond", "cds"]: + if trade_type in ["bond", "cds", "swaption"]: process_fun = globals()[f"{trade_type}_trade_process"] with init_bbg_session(BBG_IP) as session: for trade in list_trades: |
