diff options
Diffstat (limited to 'python/analytics/tranche_basket.py')
| -rw-r--r-- | python/analytics/tranche_basket.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py index ae2d73e2..853f8468 100644 --- a/python/analytics/tranche_basket.py +++ b/python/analytics/tranche_basket.py @@ -46,9 +46,9 @@ class DualCorrTranche(): self._Ngrid = 201 self._Z, self._w = GHquad(self._Ngh) self.rho = np.array([corr_attach, corr_detach]) - self.notional = notional self.tranche_running = tranche_running self._direction = -1. if notional > 0 else 1. + self.notional = abs(notional) self.cs = credit_schedule(value_date, None, 1., self._index.yc, self._index.maturities[0]) self._accrued = cds_accrued(value_date, tranche_running * 1e-4) @@ -176,15 +176,16 @@ class DualCorrTranche(): else: # TODO: handle factor change days_accrued = (self.value_date - self._trade_date).days / 360 - return self.notional * self._direction * -(self.pv - self._original_pv + + return self.notional * self._direction * (-self.pv + self._original_pv + self.tranche_running/10000 * days_accrued) def __repr__(self): s = ["{}{} {} Tranche".format(self.index_type, self.series, self.tenor), "", "{:<20}\t{:>15}".format("Value Date", ('{:%m/%d/%y}'. - format(self.value_date)))] - rows = [["Notional", self.notional * self._direction, "PV", self.pv *100], + format(self.value_date))), + "{:<20}\t{:>15}".format("Direction", self.direction)] + rows = [["Notional", self.notional, "PV", self.pv *100], ["Attach", self.attach, "Detach", self.detach], ["Attach Corr", self.rho[0] * 100, "Detach Corr", self.rho[1] * 100]] format_strings = [[None, '{:,.0f}', None, '{:,.4f}%'], |
