aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/analytics/basket_index.py13
-rw-r--r--python/analytics/tranche_basket.py19
2 files changed, 10 insertions, 22 deletions
diff --git a/python/analytics/basket_index.py b/python/analytics/basket_index.py
index b218ed3a..4c3ba6a1 100644
--- a/python/analytics/basket_index.py
+++ b/python/analytics/basket_index.py
@@ -37,6 +37,7 @@ class BasketIndex(CreditIndex):
tweaks: List[float]
_cache = {}
+ _ignore_hash = set(["tenors", "index_desc", "tweaks"])
def __new__(cls, index_type, series, tenors, **kwargs):
if isinstance(tenors, str):
@@ -110,18 +111,6 @@ class BasketIndex(CreditIndex):
self.cash_settle_date = value_date + 3 * BDay()
self.tweaks = []
self.start_date = previous_twentieth(value_date)
- self._ignore_hash = set(
- [
- "_Z",
- "_w",
- "_skew",
- "tenors",
- "index_desc",
- "tweaks",
- "_Legs",
- "_ignore_hash",
- ]
- )
super().__init__(
adjust_next_business_day(self.issue_date),
maturities,
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)