diff options
Diffstat (limited to 'python/analytics/tranche_basket.py')
| -rw-r--r-- | python/analytics/tranche_basket.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py index f264062a..91000795 100644 --- a/python/analytics/tranche_basket.py +++ b/python/analytics/tranche_basket.py @@ -49,7 +49,7 @@ class DualCorrTranche(): self._Ngh = 250 self._Ngrid = 301 self._Z, self._w = GHquad(self._Ngh) - self.rho = np.array([corr_attach, corr_detach]) + self.rho = [corr_attach, corr_detach] self.tranche_running = tranche_running self._direction = -1. if notional > 0 else 1. self.notional = abs(notional) @@ -87,8 +87,8 @@ class DualCorrTranche(): instance = cls(rec['index'], rec['series'], rec['tenor'], attach=rec['attach'], detach=rec['detach'], - corr_attach=rec['corr_attach'] or -1., - corr_detach=rec['corr_detach'] or -1., + corr_attach=rec['corr_attach'], + corr_detach=rec['corr_detach'], notional=rec['notional'], tranche_running=rec['coupon'], value_date=rec['trade_date']) @@ -113,7 +113,7 @@ class DualCorrTranche(): return self._Legs(0., 0., 1.) elif K == 1.: return self._Legs(*self.index_pv(epsilon)) - elif rho == -1.: + elif rho is None: raise ValueError("ρ needs to be a real number between 0. and 1.") else: if self.use_trunc: @@ -291,10 +291,10 @@ class DualCorrTranche(): def _greek_calc(self): eps = 1e-4 - indexbp = [self.tranche_legs(1., -1., 0.).bond_price] + indexbp = [self.tranche_legs(1., None, 0.).bond_price] bp = [self.pv] for tweak in [eps, -eps, 2*eps]: - indexbp.append(self.tranche_legs(1., -1., tweak).bond_price) + indexbp.append(self.tranche_legs(1., None, tweak).bond_price) bp.append(self._pv(tweak)) return {'indexbp': indexbp, 'bp': bp} @@ -312,7 +312,7 @@ class TrancheBasket(BasketIndex): self._Ngh = 250 self._Ngrid = 201 self._Z, self._w = GHquad(self._Ngh) - self.rho = np.full(self.K.size, -1.) + self.rho = np.full(self.K.size, np.nan) self.cs = credit_schedule(value_date, self.tenor[:-1], 1, self.yc, self.maturity) @@ -402,7 +402,7 @@ class TrancheBasket(BasketIndex): return 0., 0. elif ((K == 1. and not complement) or (K == 0. and complement)): self.index_pv()[:-1] - elif rho == -1.: + elif np.isnan(rho): raise ValueError("rho needs to be a real number between 0. and 1.") else: if shortened > 0: @@ -643,4 +643,4 @@ class TrancheBasket(BasketIndex): K1eq.append(brentq(aux2, K2 * 0.1, K2 * 2.5, (self, index2, K2, shortened))) - return np.hstack([-1., expit(self._skew(logit(K1eq))), 1.]) + return np.hstack([np.nan, expit(self._skew(logit(K1eq))), np.nan]) |
