diff options
Diffstat (limited to 'python/analytics/tranche_basket.py')
| -rw-r--r-- | python/analytics/tranche_basket.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py index 5cd152f3..c55a3bd3 100644 --- a/python/analytics/tranche_basket.py +++ b/python/analytics/tranche_basket.py @@ -18,6 +18,8 @@ import numpy as np class DualCorrTranche(): + _cache = LRU(64) + def __init__(self, index_type: str, series: int, tenor: str, *, attach: float, detach: float, corr_attach: float, corr_detach: float, tranche_running: float, @@ -46,7 +48,6 @@ class DualCorrTranche(): 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) - self._cache = LRU(64) self._ignore_hash = set(['_Z', '_w', 'cs', '_cache', '_ignore_hash']) def _default_prob(self): @@ -97,7 +98,7 @@ class DualCorrTranche(): self.cs = credit_schedule(d, None, 1., self._index.yc, self._index.maturities[0]) self._accrued = cds_accrued(d, self.tranche_running * 1e-4) - @memoize + @memoize(lambda args: (hash(args[0]._index), *args[1:])) def tranche_legs(self, K, rho): if K == 0.: return 0., 0. |
