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.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/python/analytics/option.py b/python/analytics/option.py
index 9a829b15..4617cdc7 100644
--- a/python/analytics/option.py
+++ b/python/analytics/option.py
@@ -34,9 +34,9 @@ from scipy.optimize import least_squares
from scipy.special import logit, expit
def calib(S0, fp, exercise_date, exercise_date_settle,
- index, rolled_curve, tilt, w):
+ index, tilt, w):
S = S0 * tilt * 1e-4
- pv = pv_vec(S, rolled_curve, exercise_date, exercise_date_settle,
+ pv = pv_vec(S, index._yc, exercise_date, exercise_date_settle,
index.start_date, index.end_date, index.recovery,
index.fixed_rate * 1e-4)
return np.inner(pv, w) - fp
@@ -75,13 +75,12 @@ def ATMstrike(index, exercise_date):
class BlackSwaption(ForwardIndex):
"""Swaption class"""
- __slots__ = ['_forward_yc', '_T', '_G', '_strike', 'option_type',
+ __slots__ = ['_T', '_G', '_strike', 'option_type',
'notional', 'sigma', '_original_pv', '_direction']
def __init__(self, index, exercise_date, strike, option_type="payer",
direction="Long"):
ForwardIndex.__init__(self, index, exercise_date, False)
- self._forward_yc = roll_yc(index._yc, exercise_date)
self._T = None
self.strike = strike
self.option_type = option_type.lower()
@@ -121,12 +120,11 @@ class BlackSwaption(ForwardIndex):
def exercise_date(self, d):
self.forward_date = d
ForwardIndex.__init__(self, self.index, d)
- self._forward_yc = roll_yc(self.index._yc, d)
if self.index._quote_is_price:
self._strike = g(self.index, self.index.fixed_rate,
- self.exercise_date, self._forward_yc, self._G)
+ self.exercise_date, self._G)
else:
- self._G = g(self.index, K, self.exercise_date, self._forward_yc)
+ self._G = g(self.index, K, self.exercise_date)
@property
def strike(self):
@@ -140,11 +138,10 @@ class BlackSwaption(ForwardIndex):
if self.index._quote_is_price:
self._G = (100 - K) / 100
self._strike = g(self.index, self.index.fixed_rate,
- self.exercise_date, self._forward_yc, self._G)
+ self.exercise_date, self._G)
else:
- self._G = g(self.index, K, self.exercise_date, self._forward_yc)
+ self._G = g(self.index, K, self.exercise_date)
self._strike = K
- #self._G = g(self.index, K, self.exercise_date)
@property
def atm_strike(self):
@@ -374,7 +371,7 @@ class Swaption(BlackSwaption):
T = self.T
tilt = np.exp(-self.sigma**2/2 * T + self.sigma * self._Z * math.sqrt(T))
args = (self.forward_pv, self.exercise_date, self.exercise_date_settle,
- self.index, self._forward_yc, tilt, self._w)
+ self.index, tilt, self._w)
eta = 1.05
a = self.index.spread * 0.99
b = a * eta
@@ -397,7 +394,7 @@ class Swaption(BlackSwaption):
else:
raise ValueError("option_type needs to be either 'payer' or 'receiver'")
S = S0 * np.exp(-self.sigma**2/2 * T + self.sigma * Z * math.sqrt(T))
- r = pv_vec(S * 1e-4, self._forward_yc, self.exercise_date,
+ r = pv_vec(S * 1e-4, self.index._yc, self.exercise_date,
self.exercise_date_settle, self.index.start_date,
self.index.end_date, self.index.recovery, self.index.fixed_rate * 1e-4)
val = (r - self._G) * 1/math.sqrt(2*math.pi) * np.exp(-Z**2/2)