aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics/option.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics/option.py')
-rw-r--r--python/analytics/option.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/python/analytics/option.py b/python/analytics/option.py
index e931d626..4fcc5023 100644
--- a/python/analytics/option.py
+++ b/python/analytics/option.py
@@ -48,7 +48,7 @@ def memoize(f):
return v
return cached_f
-def ATMstrike(index, exercise_date, price=False):
+def ATMstrike(index, exercise_date):
"""computes the at-the-money strike.
Parameters
@@ -60,9 +60,9 @@ def ATMstrike(index, exercise_date, price=False):
price : bool, defaults to False
If price is true return a strike price, returns a spread otherwise.
"""
- fi = ForwardIndex(index, exercise_date, price)
+ fi = ForwardIndex(index, exercise_date)
fp = fi.forward_pv
- if price:
+ if index._quote_is_price:
return 100 * (1 - fp)
else:
closure = lambda S: g(index, S, exercise_date) - fp
@@ -77,13 +77,11 @@ def ATMstrike(index, exercise_date, price=False):
class Swaption(ForwardIndex):
"""Swaption class"""
- def __init__(self, index, exercise_date, strike,
- option_type="payer", strike_is_price=False):
- ForwardIndex.__init__(self, index, exercise_date, strike_is_price)
+ def __init__(self, index, exercise_date, strike, option_type="payer"):
+ ForwardIndex.__init__(self, index, exercise_date)
self._exercise_date = exercise_date
self._forward_yc = roll_yc(index._yc, exercise_date)
self._T = None
- self._strike_is_price = strike_is_price
self.strike = strike
self.option_type = option_type.lower()
self._Z, self._w = GHquad(50)
@@ -104,14 +102,14 @@ class Swaption(ForwardIndex):
@property
def strike(self):
- if self._strike_is_price:
+ if self.index._quote_is_price:
return 100 * (1 - self._G)
else:
return self._strike
@strike.setter
def strike(self, K):
- if self._strike_is_price:
+ if self.index._quote_is_price:
self._G = (100 - K) / 100
# we compute the corresponding spread to the strike price
def handle(S, index, forward_date, forward_yc):
@@ -294,7 +292,7 @@ class Swaption(ForwardIndex):
@property
def breakeven(self):
pv = self.pv / self.notional
- if self._strike_is_price:
+ if self.index._quote_is_price:
if self.option_type == "payer":
return 100-(self._G + pv)*100
else: