aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/risk/tranches.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/python/risk/tranches.py b/python/risk/tranches.py
index d70fbee9..530091f4 100644
--- a/python/risk/tranches.py
+++ b/python/risk/tranches.py
@@ -334,6 +334,10 @@ def VaR(
else:
ref = new_spread
v.tweak([ref])
+ df = pd.DataFrame.from_records(
+ [(*tid, t.pv) for tid, t in portf.items()], columns=["strat", "tid", "pv1"]
+ ).set_index(["strat", "tid"])
+ pv2, pv3 = [], []
for tid, t in portf.items():
# we shock skews
for i in range(-1, 8):
@@ -344,9 +348,11 @@ def VaR(
else:
logging.error("Couldn't find a suitable skew mapping")
t.rho = t._skew(t.moneyness)
+ pv2.append(t.pv)
# we shock rates
t.cs.df = t._index.yc.discount_factor(t.cs.payment_dates)
- d[d_curr] = pd.DataFrame.from_records(
- [(*tid, t.pv) for tid, t in portf.items()], columns=["strat", "tid", "pv"]
- ).set_index(["strat", "tid"])
+ pv3.append(t.pv)
+ df["pv2"] = pv2
+ df["pv3"] = pv3
+ d[d_curr] = df
return pd.concat(d)