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.py24
1 files changed, 10 insertions, 14 deletions
diff --git a/python/analytics/basket_index.py b/python/analytics/basket_index.py
index ef3df15d..4c08c157 100644
--- a/python/analytics/basket_index.py
+++ b/python/analytics/basket_index.py
@@ -154,13 +154,8 @@ class BasketIndex(CreditIndex):
m, self.yc, coupon, epsilon))
return pd.Series(r, index=self.index_desc.tenor, name='pv')
else:
- if coupon is None:
- try:
- coupon = self.index_desc.coupon[maturity]
- except KeyError:
- raise ValueError("Non standard maturity: coupon must be provided")
return super().pv(self.step_in_date, self.cash_settle_date, maturity,
- self.yc, coupon, epsilon)
+ self.yc, coupon or self.coupon(maturity), epsilon)
def pv_vec(self):
return super().pv_vec(self.step_in_date, self.cash_settle_date, self.yc).unstack(0)
@@ -219,19 +214,20 @@ class BasketIndex(CreditIndex):
self.yc, coupon, index_quote, theta_date))
return pd.Series(r, index=self.index_desc.tenor, name='theta')
else:
- if coupon is None:
- try:
- coupon = self.index_desc.coupon[maturity]
- except KeyError:
- raise ValueError("Non standard maturity: coupon must be provided")
return super().theta(self.step_in_date, self.cash_settle_date, maturity,
- self.yc, coupon, np.nan, theta_date)
+ self.yc, coupon or self.coupon(maturity), np.nan, theta_date)
- def coupon(self, maturity=None):
+ def coupon(self, maturity=None, assume_flat=True):
if maturity is None:
return self.index_desc.set_index('tenor').coupon
else:
- return self.index_desc.coupon[maturity]
+ try:
+ return self.index_desc.coupon[maturity]
+ except KeyError:
+ if assume_flat:
+ return self.index_desc.coupon.iat[0]
+ else:
+ raise ValueError("Non standard maturity: coupon must be provided")
def tweak(self, *args):
""" tweak the singlename curves to match index quotes"""