aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics')
-rw-r--r--python/analytics/tranche_basket.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py
index ba8ce313..7608858d 100644
--- a/python/analytics/tranche_basket.py
+++ b/python/analytics/tranche_basket.py
@@ -131,6 +131,23 @@ class DualCorrTranche():
return Legs(tranche_cl(L, R, self.cs, 0., K),
tranche_pl(L, self.cs, 0., K))
+ def index_pv(self, epsilon=0., discounted=True):
+ DP = self._default_prob(epsilon).values
+ df = self.cs.df.values
+ coupons = self.cs.coupons
+ ELvec = self.weights * (1 - self.recovery_rates) @ DP
+ size = 1 - self.weights @ DP
+ sizeadj = 0.5 * (np.hstack((1., size[:-1])) + size)
+ if not discounted:
+ pl = - ELvec[-1]
+ cl = coupons @ sizeadj
+ else:
+ pl = - np.diff(np.hstack((0., ELvec))) @ df
+ cl = coupons @ (sizeadj * df)
+ bp = 1 + cl * self.coupon(self.maturity) + pl
+ Pvs = namedtuple('IndexPvs', 'coupon_leg, protection_leg, bond_price')
+ return Pvs(cl, pl, bp)
+
@property
def direction(self):
if self._direction == -1.: