diff options
Diffstat (limited to 'python/analytics/tranche_basket.py')
| -rw-r--r-- | python/analytics/tranche_basket.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py index a42a31c6..b253a8b6 100644 --- a/python/analytics/tranche_basket.py +++ b/python/analytics/tranche_basket.py @@ -151,6 +151,10 @@ class Skew: class DualCorrTranche: __cache = LRU(512) _Legs = namedtuple("Legs", "coupon_leg, protection_leg, bond_price") + _Ngh = 250 + _Ngrid = 301 + _Z, _w = GHquad(_Ngh) + _ignore_hash = ["cs"] def __init__( self, @@ -191,9 +195,6 @@ class DualCorrTranche: self.K = adjust_attachments( self.K_orig, self._index.cumloss, self._index.factor ) - self._Ngh = 250 - self._Ngrid = 301 - self._Z, self._w = GHquad(self._Ngh) self.rho = [corr_attach, corr_detach] self.tranche_running = tranche_running self.notional = notional @@ -208,7 +209,6 @@ class DualCorrTranche: ) self.use_trunc = use_trunc self.trade_id = trade_id - self._ignore_hash = set(["_Z", "_w", "cs", "_cache", "_Legs", "_ignore_hash"]) @property def maturity(self): @@ -247,9 +247,7 @@ class DualCorrTranche: else: return hash(v) - return hash( - tuple(aux(v) for k, v in vars(self).items() if k not in self._ignore_hash) - ) + return hash(tuple(aux(v) for k, v in vars(self).items() if k != "cs")) @classmethod def from_tradeid(cls, trade_id): @@ -877,6 +875,10 @@ class DualCorrTranche: class TrancheBasket(BasketIndex): _Legs = namedtuple("Legs", "coupon_leg, protection_leg, bond_price") + _Ngh = 250 + _Ngrid = 301 + _Z, _w = GHquad(_Ngh) + _ignore_hash = BasketIndex._ignore_hash | set(["_skew"]) def __init__( self, @@ -899,9 +901,6 @@ class TrancheBasket(BasketIndex): self._update_tranche_quotes() self.K_orig = np.hstack((0.0, self.tranche_quotes.detach)) / 100 self.K = adjust_attachments(self.K_orig, self.cumloss, self.factor) - self._Ngh = 250 - self._Ngrid = 301 - self._Z, self._w = GHquad(self._Ngh) self.rho = np.full(self.K.size, np.nan) self.cs = credit_schedule(value_date, 1.0, self.yc, self.maturity) |
