diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/analytics/tranche_basket.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py index 21e03a79..9cc876bf 100644 --- a/python/analytics/tranche_basket.py +++ b/python/analytics/tranche_basket.py @@ -317,6 +317,34 @@ class DualCorrTranche(): pass conn.close() + def jump_to_default(self, skew): + curves = self._index.curves + orig_factor, orig_cumloss = self._index.factor, self._index.cumloss + orig_upf = self.tranche_factor * self.upfront + r = [] + tickers = [] + rho_orig = self.rho + for weight, curve in curves: + self._index.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._index._cumloss = orig_cumloss + L + self._index._factor = orig_factor * (1 - weight) + self.K = adjust_attachments(self.K_orig, self._index.cumloss, self._index.factor) + self.mark(skew=skew) + upf = self.tranche_factor * self.upfront + #we allocate the loss to the different tranches + loss = np.diff(np.clip(self.K, None, L)) / np.diff(self.K_orig) * orig_factor + upf += float(loss) + r.append(upf) + tickers.append(curve.ticker) + self._index._factor, self._index._cumloss = orig_factor, orig_cumloss + self.K = self.K = adjust_attachments(self.K_orig, self._index.cumloss, self._index.factor) + self._index.curves = curves + self.rho = rho_orig + r = r - orig_upf + return pd.Series(r/100, index=tickers) + @property def tranche_factor(self): return (self.K[1] - self.K[0]) / (self.K_orig[1] - self.K_orig[0]) * \ |
