aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics/basket_index.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics/basket_index.py')
-rw-r--r--python/analytics/basket_index.py17
1 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: