diff options
| -rw-r--r-- | python/risk/tranches.py | 6 | ||||
| -rw-r--r-- | sql/dawn.sql | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/python/risk/tranches.py b/python/risk/tranches.py index f468108f..5f7edb39 100644 --- a/python/risk/tranches.py +++ b/python/risk/tranches.py @@ -38,11 +38,12 @@ def get_tranche_portfolio(date, conn, by_strat=False, fund="SERCGMAST"): def insert_tranche_portfolio(portf, conn): cols = ["clean_nav", "accrued", "duration", "delta", "gamma", - "theta", "upfront", "running", "corr_attach", "corr_detach", + "theta", "tranche_factor", "upfront", "running", + "corr_attach", "corr_detach", "index_refprice", "index_refspread", "index_duration"] update_str = ",".join(f"{c} = EXCLUDED.{c}" for c in cols) - sql_str = (f"INSERT INTO tranche_risk VALUES({','.join(['%s'] * 15)}) " + sql_str = (f"INSERT INTO tranche_risk VALUES({','.join(['%s'] * 16)}) " " ON CONFLICT (date, tranche_id) DO UPDATE " f"SET {update_str}") with conn.cursor() as c: @@ -60,6 +61,7 @@ def insert_tranche_portfolio(portf, conn): trade.delta, trade.gamma, theta, + trade.tranche_factor, trade.upfront, trade.tranche_running, trade.rho[0], diff --git a/sql/dawn.sql b/sql/dawn.sql index 443dfe8b..da6392fc 100644 --- a/sql/dawn.sql +++ b/sql/dawn.sql @@ -913,6 +913,7 @@ CREATE TABLE tranche_risk( delta float, gamma float, theta float, + tranche_factor float, upfront float, running float, corr_attach float, @@ -1638,13 +1639,14 @@ $$ LANGUAGE plpythonu; CREATE OR REPLACE VIEW globeop_tranche_risk AS -SELECT date, security_desc, index, series, maturity, orig_attach, +SELECT date, tranche_id as trade_id, security_desc, index, series, maturity, orig_attach, orig_detach, CASE protection WHEN 'Buyer' THEN notional ELSE -notional END AS notional, endqty as globeop_notional, clean_nav as serenitas_clean_nav, endbooknav-endbookunrealincome as globeop_clean_nav, - accrued as serenitas_accrued, endbookunrealincome, - duration, delta, gamma, theta, tranche_risk.corr_attach, tranche_risk.corr_detach, + accrued as serenitas_accrued, endbookunrealincome as globeop_accrued, + duration, delta, gamma, theta, tranche_factor, + tranche_risk.corr_attach, tranche_risk.corr_detach, tranche_risk.upfront, tranche_risk.running, index_refprice, index_refspread, index_duration FROM tranche_risk |
