diff options
Diffstat (limited to 'python/process_queue.py')
| -rw-r--r-- | python/process_queue.py | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/python/process_queue.py b/python/process_queue.py index a27a72f4..bd52fc5d 100644 --- a/python/process_queue.py +++ b/python/process_queue.py @@ -139,7 +139,7 @@ def terminate_list( def rename_keys(d, mapping): - """ rename keys in dictionary according to mapping dict inplace""" + """rename keys in dictionary according to mapping dict inplace""" for k, v in mapping.items(): if k in d: d[v] = d.pop(k) @@ -622,30 +622,27 @@ def cds_trade_process(conn, session, trade): trade["upfront"] = -index.pv else: accrued = index._accrued * trade["fixed_rate"] - if index.index_type == "HY": - dirty_price = float(trade["traded_level"]) + accrued - trade["upfront"] = ( - -(100 - dirty_price) * index.notional * trade["Factor"] * 0.01 - ) - elif index.index_type == "EU": - if trade["orig_attach"] in (6, 12): + match index.index_type: + case "HY": + dirty_price = float(trade["traded_level"]) + accrued + trade["upfront"] = ( + -(100 - dirty_price) + * index.notional + * trade["Factor"] + * 0.01 + ) + case "EU" | "XO" if trade["orig_attach"] in (6, 12, 35): if trade["orig_attach"] == 6: index.recovery = 0.0 index.spread = float(trade["traded_level"]) trade["upfront"] = ( -index._pv * trade["notional"] * trade["Factor"] ) - elif index.index_type == "XO": - if trade["orig_attach"] == 35: - index.spread = float(trade["traded_level"]) + case _: + dirty_protection = float(trade["traded_level"]) - accrued trade["upfront"] = ( - -index._pv * trade["notional"] * trade["Factor"] + -dirty_protection * index.notional * trade["Factor"] * 0.01 ) - else: - dirty_protection = float(trade["traded_level"]) - accrued - trade["upfront"] = ( - -dirty_protection * index.notional * trade["Factor"] * 0.01 - ) c.execute( "UPDATE cds SET upfront=%s WHERE dealid=%s", (trade["upfront"], trade["dealid"]), |
