diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/analytics/basket_index.py | 17 | ||||
| m--------- | python/pyisda | 0 |
2 files changed, 12 insertions, 5 deletions
diff --git a/python/analytics/basket_index.py b/python/analytics/basket_index.py index 4a5ce710..0001a4e7 100644 --- a/python/analytics/basket_index.py +++ b/python/analytics/basket_index.py @@ -167,13 +167,20 @@ class BasketIndex(CreditIndex): def protection_leg(self, maturity=None): return self.pv() + self.coupon_leg() - def spread(self, maturity=None, coupon=None): + def spread(self, maturity=None): + return self.protection_leg(maturity) / \ + self.duration(maturity) *1e4 + + def protection_leg(self, maturity=None): if maturity is None: - return (self.index_desc.coupon.values + self.pv() / - self.duration()) * 1e4 + r = [] + for m in self.maturities: + r.append(super().protection_leg(self.step_in_date, self.cash_settle_date, + m, self.yc)) + return pd.Series(r, index=self.index_desc.tenor, name='protection_leg') else: - return (coupon + self.pv(maturity, coupon=coupon) / - self.duration(maturity)) * 1e4 + return super().protection_leg(self.step_in_date, self.cash_settle_date, + maturity, self.yc) def duration(self, maturity=None): if maturity is None: diff --git a/python/pyisda b/python/pyisda -Subproject 6f1bbc1198993cb5017c3f68ae69f31a9fd4ec7 +Subproject 3167341d4e9e28075b561666f9bd724d91dff06 |
