aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/analytics/index.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/python/analytics/index.py b/python/analytics/index.py
index 10238fce..5fa1ed48 100644
--- a/python/analytics/index.py
+++ b/python/analytics/index.py
@@ -22,20 +22,21 @@ from bbg_helpers import BBG_IP, retrieve_data, init_bbg_session
engine = dbengine('serenitasdb')
-def g(index, spread, exercise_date, forward_yc=None, pv=0.):
+def g(index, spread, exercise_date, forward_yc=None, pv=None):
"""computes the strike clean price using the expected forward yield curve. """
if forward_yc is None:
forward_yc = index._yc
step_in_date = exercise_date + datetime.timedelta(days=1)
- exercise_date_settle = pd.Timestamp(exercise_date) + 3* BDay()
+ exercise_date_settle = pd.Timestamp(exercise_date) + 3 * BDay()
rates = array.array('d', [spread * 1e-4])
+ upfront = 0. if pv is None else pv
sc = SpreadCurve(exercise_date, forward_yc, index.start_date,
step_in_date, exercise_date_settle,
- [index.end_date], rates, array.array('d',[pv]),
+ [index.end_date], rates, array.array('d', [upfront]),
array.array('d', [index.recovery]))
a = index._fee_leg.pv(exercise_date, step_in_date, exercise_date_settle,
forward_yc, sc, True)
- if pv != 0.:
+ if pv is not None:
return 1e4 * pv / a + spread
else:
return (spread - index.fixed_rate) * a * 1e-4