diff options
Diffstat (limited to 'python/risk/tranches.py')
| -rw-r--r-- | python/risk/tranches.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/python/risk/tranches.py b/python/risk/tranches.py index c6b41c3e..d5373183 100644 --- a/python/risk/tranches.py +++ b/python/risk/tranches.py @@ -48,12 +48,15 @@ def get_tranche_portfolio(date, conn, by_strat=False, fund="SERCGMAST"): def insert_tranche_portfolio(portf, conn): cols = [ + "date", + "tranche_id", "clean_nav", "accrued", "duration", "delta", "gamma", "theta", + "corr01", "tranche_factor", "upfront", "running", @@ -63,9 +66,10 @@ def insert_tranche_portfolio(portf, conn): "index_refspread", "index_duration", ] - update_str = ",".join(f"{c} = EXCLUDED.{c}" for c in cols) + update_str = ",".join(f"{c} = EXCLUDED.{c}" for c in cols[2:]) sql_str = ( - f"INSERT INTO tranche_risk VALUES({','.join(['%s'] * 16)}) " + f"INSERT INTO tranche_risk({','.join(cols)}) " + f"VALUES({','.join(['%s'] * len(cols))}) " " ON CONFLICT (date, tranche_id) DO UPDATE " f"SET {update_str}" ) @@ -91,6 +95,7 @@ def insert_tranche_portfolio(portf, conn): trade.delta, trade.gamma, theta, + trade.corr01, trade.tranche_factor, trade.upfront, trade.tranche_running, |
