diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/analytics/option.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/python/analytics/option.py b/python/analytics/option.py index 11664eeb..6551b46c 100644 --- a/python/analytics/option.py +++ b/python/analytics/option.py @@ -296,7 +296,9 @@ class BlackSwaption(ForwardIndex): @price.setter def price(self, p): - self.pv = p * 1e-2 * self.notional * self.index.factor * self._direction + BlackSwaption.pv.fset( + self, p * 1e-2 * self.notional * self.index.factor * self._direction + ) @property def tail_prob(self): @@ -315,7 +317,7 @@ class BlackSwaption(ForwardIndex): if np.isnan(val): raise ValueError("val is nan") # early exit - if self.sigma is not None and abs(self.pv - val) < 1e-12: + if self.sigma is not None and abs(BlackSwaption.pv.fget(self) - val) < 1e-12: return if self._direction * (val - self.intrinsic_value) < 0: raise ValueError( @@ -327,7 +329,7 @@ class BlackSwaption(ForwardIndex): def handle(x): self.sigma = x - return self._direction * (self.pv - val) + return self._direction * (BlackSwaption.pv.fget(self) - val) eta = 1.01 a = 0.1 @@ -587,6 +589,14 @@ class Swaption(BlackSwaption): b *= eta self.sigma = brentq(handle, a, b) + @property + def price(self): + return super().price + + @price.setter + def price(self, p): + self.pv = p * 1e-2 * self.notional * self.index.factor * self._direction + def _get_keys(df, models=["black", "precise"]): for quotedate, source in ( |
