diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/analytics/tranche_basket.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py index 5d713a09..5af661a9 100644 --- a/python/analytics/tranche_basket.py +++ b/python/analytics/tranche_basket.py @@ -199,12 +199,20 @@ class TrancheBasket(BasketIndex): def tranche_durations(self, complement=False): cl = self.tranche_pvs(complement=complement).coupon_leg - durations = (cl - cds_accrued(self.value_date, self.tranche_quotes.running)) / \ - self.tranche_quotes.running + accrued = np.array([cds_accrued(self.value_date, r) + for r in self.tranche_quotes.running]) + durations = (cl - accrued) / self.tranche_quotes.running durations.index = self._row_names durations.name = 'duration' return durations + def tranche_spreads(self, complement=False): + cl, pl, _ = self.tranche_pvs(complement=complement) + accrued = np.array([cds_accrued(self.value_date, r) + for r in self.tranche_quotes.running]) + durations = (cl - accrued) / self.tranche_quotes.running.values + return pd.Series(-pl / durations * 1e4, index=self._row_names, name='spread') + @property def _row_names(self): """ return pretty row names based on attach-detach""" |
