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.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/python/analytics/option.py b/python/analytics/option.py
index b05fe374..27ee9059 100644
--- a/python/analytics/option.py
+++ b/python/analytics/option.py
@@ -1,3 +1,5 @@
+from __future__ import division
+
import array
import datetime
import math
@@ -14,7 +16,7 @@ from pyisda.flat_hazard import pv_vec
from scipy.optimize import brentq
from scipy.integrate import simps
-def calib(S0, fp, exercise_date : datetime.date, exercise_date_settle :datetime.date,
+def calib(S0, fp, exercise_date, exercise_date_settle,
index, rolled_curve, tilt, w):
S = S0 * tilt * 1e-4
pv = pv_vec(S, rolled_curve, exercise_date, exercise_date_settle,
@@ -22,7 +24,7 @@ def calib(S0, fp, exercise_date : datetime.date, exercise_date_settle :datetime.
index.fixed_rate * 1e-4)
return np.inner(pv, w) - fp
-def ATMstrike(index, exercise_date : datetime.date):
+def ATMstrike(index, exercise_date):
exercise_date_settle = (pd.Timestamp(exercise_date) + 3* BDay()).date()
fp = index.forward_pv(exercise_date) / index.notional
closure = lambda S: g(index, S, exercise_date) - fp
@@ -37,7 +39,7 @@ def ATMstrike(index, exercise_date : datetime.date):
class Swaption(ForwardIndex):
"""Swaption class"""
- def __init__(self, index, exercise_date : datetime.date, strike : float,
+ def __init__(self, index, exercise_date, strike,
option_type="payer", strike_is_price = False):
ForwardIndex.__init__(self, index, exercise_date, strike_is_price)
self._exercise_date = exercise_date
@@ -54,7 +56,7 @@ class Swaption(ForwardIndex):
return self._exercise_date
@exercise_date.setter
- def exercise_date(self, d : datetime.date):
+ def exercise_date(self, d):
self._exercise_date = d
ForwardIndex.__init__(self, self.index, d)
self._forward_yc = roll_yc(self.index._yc, d)
@@ -68,7 +70,7 @@ class Swaption(ForwardIndex):
return self._strike
@strike.setter
- def strike(self, K : float):
+ def strike(self, K):
if self._strike_is_price:
self._G = (100 - K) / 100
# we compute the corresponding spread to the strike price
@@ -127,7 +129,7 @@ class Swaption(ForwardIndex):
return self.notional * simps(val, Z) * self.df
@pv.setter
- def pv(self, val: float):
+ def pv(self, val):
if np.isnan(val):
raise ValueError("val is nan")
if val < self.intrinsic_value:
@@ -161,7 +163,7 @@ class Swaption(ForwardIndex):
self.sigma,
self.option_type) * self.notional
@pv_black.setter
- def pv_black(self, val: float):
+ def pv_black(self, val):
if np.isnan(val):
raise ValueError("val is nan")
if val < self.intrinsic_value: