diff options
Diffstat (limited to 'python/analytics/basket_index.py')
| -rw-r--r-- | python/analytics/basket_index.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/python/analytics/basket_index.py b/python/analytics/basket_index.py index 60b9986a..4dd02e8f 100644 --- a/python/analytics/basket_index.py +++ b/python/analytics/basket_index.py @@ -134,8 +134,11 @@ class BasketIndex(CreditIndex): def protection_leg(self, maturity=None): return self.pv() + self.coupon_leg() - def spread(self, maturity=None): - return (self.index_desc.coupon.values + self.pv() / self.duration()) * 1e4 + def spread(self, maturity=None, coupon=None): + if maturity is None: + return (self.index_desc.coupon.values + self.pv() / self.duration()) * 1e4 + else: + return (coupon + self.pv(maturity, coupon=coupon) / self.duration(maturity)) * 1e4 def duration(self, maturity=None): if maturity is None: @@ -177,8 +180,11 @@ class BasketIndex(CreditIndex): self.yc, self.recovery, coupon, np.nan) - def coupon(self): - return self.index_desc.set_index('tenor').coupon + def coupon(self, maturity=None): + if maturity is None: + return self.index_desc.set_index('tenor').coupon + else: + return self.index_desc.coupon[maturity] def tweak(self, *args): """ tweak the singlename curves to match index quotes""" |
