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.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py
index 01261808..dc691f15 100644
--- a/python/analytics/tranche_basket.py
+++ b/python/analytics/tranche_basket.py
@@ -205,10 +205,15 @@ class DualCorrTranche():
@property
def upfront(self):
- """ returns upfront in points"""
+ """returns protection upfront in points"""
pl, cl = self._pv()
return -100 * (pl + cl - self._accrued)
+ @property
+ def price(self):
+ pl, cl = self._pv()
+ return 100 * (1 + pl + cl - self._accrued)
+
@upfront.setter
def upfront(self, upf):
def aux(rho):
@@ -236,7 +241,7 @@ class DualCorrTranche():
"",
"{:<20}\t{:>15}".format("Value Date", f'{self.value_date:%m/%d/%y}'),
"{:<20}\t{:>15}".format("Direction", self.direction)]
- rows = [["Notional", self.notional, "PV", self.pv *100],
+ rows = [["Notional", self.notional, "PV", self.pv],
["Attach", self.attach, "Detach", self.detach],
["Attach Corr", self.rho[0], "Detach Corr", self.rho[1]],
["Delta", self.delta, "Gamma", self.gamma]]
@@ -324,16 +329,17 @@ class DualCorrTranche():
(calc['indexbp'][3] - calc['indexbp'][0]) * factor
delta = (calc['bp'][1] - calc['bp'][2]) / \
(calc['indexbp'][1] - calc['indexbp'][2]) * factor
- return -(deltaplus - delta) / (calc['indexbp'][1] - calc['indexbp'][0]) / 100
+ return (deltaplus - delta) / (calc['indexbp'][1] - calc['indexbp'][0]) / 100
def _greek_calc(self):
eps = 1e-4
indexbp = [self.tranche_legs(1., None, 0.).bond_price]
- bp = [self.pv]
+ pl, cl = self._pv()
+ bp = [pl + cl]
for tweak in [eps, -eps, 2*eps]:
indexbp.append(self.tranche_legs(1., None, tweak).bond_price)
pl, cl = self._pv(tweak)
- bp.append(float(-pl - cl + self._accrued))
+ bp.append(pl + cl)
return {'indexbp': indexbp, 'bp': bp}
class TrancheBasket(BasketIndex):