diff options
Diffstat (limited to 'python/analytics/option.py')
| -rw-r--r-- | python/analytics/option.py | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/python/analytics/option.py b/python/analytics/option.py index 1669803a..11664eeb 100644 --- a/python/analytics/option.py +++ b/python/analytics/option.py @@ -265,11 +265,6 @@ class BlackSwaption(ForwardIndex): intrinsic = max(V, 0) if self.option_type == "payer" else max(-V, 0) return self._direction * intrinsic * self.notional * self.index.factor - def __hash__(self): - return hash( - (hash(super()), tuple(getattr(self, k) for k in BlackSwaption.__slots__)) - ) - @property def pv(self): """compute pv using black-scholes formula""" @@ -515,17 +510,14 @@ class BlackSwaption(ForwardIndex): class Swaption(BlackSwaption): - __slots__ = ("_cache", "_Z", "_w") + __slots__ = ("__cache", "__Z", "__w") def __init__( self, index, exercise_date, strike, option_type="payer", direction="Long" ): super().__init__(index, exercise_date, strike, option_type, direction) - self._cache = {} - self._Z, self._w = GHquad(30) - - def __hash__(self): - return super().__hash__() + self.__cache = {} + self.__Z, self.__w = GHquad(30) @property @memoize @@ -534,7 +526,7 @@ class Swaption(BlackSwaption): if T == 0.0: return self.notional * self.intrinsic_value * self.index.factor sigmaT = self.sigma * math.sqrt(T) - tilt = np.exp(-0.5 * sigmaT ** 2 + sigmaT * self._Z) + tilt = np.exp(-0.5 * sigmaT ** 2 + sigmaT * self.__Z) ctx = init_context( self.index._yc, self.exercise_date, @@ -547,7 +539,7 @@ class Swaption(BlackSwaption): sigmaT, 0.01, ) - args = (self.forward_pv, tilt, self._w, ctx) + args = (self.forward_pv, tilt, self.__w, ctx) eta = 1.05 a = self.index.spread * 0.99 b = a * eta |
