diff options
Diffstat (limited to 'python/risk')
| -rw-r--r-- | python/risk/tranches.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/python/risk/tranches.py b/python/risk/tranches.py index 530091f4..647fffba 100644 --- a/python/risk/tranches.py +++ b/python/risk/tranches.py @@ -308,7 +308,7 @@ def VaR( otr = {k: on_the_run(k, value_date) for k in ("EU", "XO", "IG", "HY")} # store current spreads old_spreads = {k: float(v.spread()) for k, v in BasketIndex._cache.items()} - + orig_pvs = np.array([t.pv for t in portf.trades]) for prev, curr in zip(yc_hist, yc_hist[1:]): d_curr, curr_usd, curr_eur = curr d_prev, prev_usd, prev_eur = prev @@ -335,7 +335,8 @@ def VaR( ref = new_spread v.tweak([ref]) df = pd.DataFrame.from_records( - [(*tid, t.pv) for tid, t in portf.items()], columns=["strat", "tid", "pv1"] + [(*tid, t.pv) for tid, t in portf.items()], + columns=["strat", "tid", "spread_shock"], ).set_index(["strat", "tid"]) pv2, pv3 = [], [] for tid, t in portf.items(): @@ -352,7 +353,8 @@ def VaR( # we shock rates t.cs.df = t._index.yc.discount_factor(t.cs.payment_dates) pv3.append(t.pv) - df["pv2"] = pv2 - df["pv3"] = pv3 + df["skew_shock"] = np.array(pv2) - df["spread_shock"].values + df["rate_shock"] = np.array(pv3) - np.array(pv2) + df["spread_shock"] -= orig_pvs d[d_curr] = df return pd.concat(d) |
