aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics/tranche_basket.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics/tranche_basket.py')
-rw-r--r--python/analytics/tranche_basket.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py
index 0bdf9354..8b9d6e5f 100644
--- a/python/analytics/tranche_basket.py
+++ b/python/analytics/tranche_basket.py
@@ -353,7 +353,7 @@ class DualCorrTranche:
bp = 1 + cl * self.tranche_running * 1e-4 + pl
return self._Legs(cl, pl, bp)
- def index_pv(self, epsilon=0.0, discounted=True):
+ def index_pv(self, epsilon=0.0, discounted=True, clean=False):
DP = self._default_prob(epsilon)
df = self.cs.df.values
coupons = self.cs.coupons
@@ -367,6 +367,10 @@ class DualCorrTranche:
pl = -np.diff(np.hstack((0.0, ELvec))) @ df
cl = coupons @ (sizeadj * df)
bp = 1 + cl * self._index.coupon(self.maturity) + pl
+ if clean:
+ accrued = self._index.accrued(self.maturity)
+ bp -= accrued
+ cl -= accrued / self._index.coupon(self.maturity)
return self._Legs(cl, pl, bp)
@property
@@ -864,8 +868,7 @@ class TrancheBasket(BasketIndex):
):
super().__init__(index_type, series, [tenor], value_date=value_date)
self.tenor = tenor
- index_desc = self.index_desc.reset_index("maturity").set_index("tenor")
- self.maturity = index_desc.loc[tenor, "maturity"].date()
+ self.maturity = self.index_desc[0].maturity
try:
self._set_tranche_quotes(value_date)
except ValueError as e:
@@ -1095,7 +1098,7 @@ class TrancheBasket(BasketIndex):
bp = 1 + pl + cl - self._accrued
return self._Legs(cl, pl, bp)
- def index_pv(self, discounted=True, shortened=0, zero_recovery=False):
+ def index_pv(self, discounted=True, shortened=0, zero_recovery=False, clean=False):
cs, DP = self._default_prob(shortened)
df = cs.df.values
coupons = cs.coupons.values
@@ -1112,6 +1115,10 @@ class TrancheBasket(BasketIndex):
pl = -np.diff(np.hstack((0.0, ELvec))) @ df
cl = coupons @ (sizeadj * df)
bp = 1 + cl * self.coupon(self.maturity) + pl
+ if clean:
+ accrued = self.accrued()
+ cl -= accrued / self.coupon(self.maturity)
+ bp -= self.accrued(self.maturity)
return self._Legs(cl, pl, bp)
def expected_loss(self, discounted=True, shortened=0):