aboutsummaryrefslogtreecommitdiffstats
path: root/python/risk
diff options
context:
space:
mode:
Diffstat (limited to 'python/risk')
-rw-r--r--python/risk/tranches.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/python/risk/tranches.py b/python/risk/tranches.py
index 540a1689..8c41b523 100644
--- a/python/risk/tranches.py
+++ b/python/risk/tranches.py
@@ -72,20 +72,24 @@ def insert_tranche_portfolio(portf, conn):
" ON CONFLICT (date, tranche_id) DO UPDATE "
f"SET {update_str}"
)
+
with conn.cursor() as c:
for (strat, trade_id), trade in portf.items():
logger.info(f"marking tranche {trade_id} in {strat}")
try:
theta = trade.theta(method="TLP")
except ValueError:
- theta = None
+ theta = (
+ trade.pv / trade.notional / trade.duration
+ + trade.tranche_running * 1e-4
+ )
c.execute(
sql_str,
(
trade.value_date,
trade_id,
trade.clean_pv,
- -trade._accrued * trade.notional,
+ -trade._accrued * trade.notional * trade.tranche_factor,
trade.duration,
trade.delta,
trade.gamma,