diff options
| -rw-r--r-- | python/analytics/tranche_basket.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py index dc691f15..d4e2b993 100644 --- a/python/analytics/tranche_basket.py +++ b/python/analytics/tranche_basket.py @@ -471,6 +471,35 @@ class TrancheBasket(BasketIndex): else: return tranche_cl(L, R, cs, 0., K), tranche_pl(L, cs, 0., K) + def jump_to_default(self): + curves = self.curves + orig_factor, orig_cumloss = self.factor, self.cumloss + el_orig = self.expected_loss() + orig_tranche_pvs = self.tranche_factors() * self.tranche_pvs(protection=True).bond_price + r = [] + tickers = [] + rho_orig = self.rho + for weight, curve in curves: + self.curves = [(w, c) if c.ticker != curve.ticker else (w, None) for w, c in curves] + L = (1 - curve.recovery_rates[0]) * weight * orig_factor + self._cumloss = orig_cumloss + L + self._factor = orig_factor * (1 - weight) + self.K = adjust_attachments(self.K_orig, self.cumloss, self.factor) + Korig_eq = np.clip(el_orig / self.expected_loss() * self.K[1:-1], None, .999) + self.rho = np.hstack([np.nan, expit(self._skew(logit(Korig_eq))), np.nan]) + bp = self.tranche_pvs(protection=True).bond_price * self.tranche_factors() + bp[0] += L / self.K_orig[1] + r.append(bp) + tickers.append(curve.ticker) + breakpoint() + self._factor, self._cumloss = orig_factor, orig_cumloss + self.K = adjust_attachments(self.K_orig, self.cumloss, self.factor) + self.curves = curves + self.rho = rho_orig + r = np.vstack(r) + r = r - orig_tranche_pvs + return pd.DataFrame(r, index=tickers, columns=self._row_names) + def tranche_pvs(self, protection=False, complement=False, shortened=0): """ computes coupon leg, protection leg and bond price. |
