aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics')
-rw-r--r--python/analytics/tranche_basket.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py
index e62130b4..d5398ffd 100644
--- a/python/analytics/tranche_basket.py
+++ b/python/analytics/tranche_basket.py
@@ -84,8 +84,8 @@ class DualCorrTranche():
instance = cls(rec['index'], rec['series'], rec['tenor'],
attach=rec['attach'],
detach=rec['detach'],
- corr_attach=rec['corr_attach'] or np.nan,
- corr_detach=rec['corr_detach'] or np.nan,
+ corr_attach=rec['corr_attach'] or -1.,
+ corr_detach=rec['corr_detach'] or -1.,
notional=rec['notional'],
tranche_running=rec['coupon'],
value_date=rec['trade_date'])
@@ -110,7 +110,7 @@ class DualCorrTranche():
return 0., 0.
elif K == 1.:
return self.index_pv()[:-1]
- elif np.isnan(rho):
+ elif rho == -1.:
raise ValueError("ρ needs to be a real number between 0. and 1.")
else:
Legs = namedtuple('TrancheLegs', 'coupon_leg, protection_leg')
@@ -307,7 +307,7 @@ class TrancheBasket(BasketIndex):
self._Ngh = 250
self._Ngrid = 201
self._Z, self._w = GHquad(self._Ngh)
- self.rho = np.full(self.K.size, np.nan)
+ self.rho = np.full(self.K.size, -1.)
self.cs = credit_schedule(value_date, self.tenor[:-1],
1, self.yc, self.maturity)
@@ -396,8 +396,8 @@ class TrancheBasket(BasketIndex):
if ((K == 0. and not complement) or (K == 1. and complement)):
return 0., 0.
elif ((K == 1. and not complement) or (K == 0. and complement)):
- return self.index_pv()[:-1]
- elif np.isnan(rho):
+ return Legs(*self.index_pv()[:-1])
+ elif rho == -1.:
raise ValueError("rho needs to be a real number between 0. and 1.")
else:
if shortened > 0:
@@ -641,4 +641,4 @@ class TrancheBasket(BasketIndex):
K1eq.append(brentq(aux2, K2 * 0.1, K2 * 2.5,
(self, index2, K2, shortened)))
- return np.hstack([np.nan, expit(self._skew(logit(K1eq))), np.nan])
+ return np.hstack([-1., expit(self._skew(logit(K1eq))), 1.])