aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics/index.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics/index.py')
-rw-r--r--python/analytics/index.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/python/analytics/index.py b/python/analytics/index.py
index 32001ac2..88c06485 100644
--- a/python/analytics/index.py
+++ b/python/analytics/index.py
@@ -27,18 +27,14 @@ def g(index, spread, exercise_date, forward_yc=None, pv=None):
forward_yc = index._yc
step_in_date = exercise_date + datetime.timedelta(days=1)
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', [upfront]),
- array.array('d', [index.recovery]))
a = index._fee_leg.pv(exercise_date, step_in_date, exercise_date_settle,
- forward_yc, sc, True)
+ forward_yc, index._sc, True)
+ prot = index._default_leg.pv(exercise_date, step_in_date, exercise_date_settle, forward_yc,
+ index._sc, index.recovery)
if pv is not None:
return 1e4 * pv / a + spread
else:
- return (spread - index.fixed_rate) * a * 1e-4
+ return prot - a * index.fixed_rate*1e-4
class Index(object):
""" minimal class to represent a credit index """
@@ -51,7 +47,7 @@ class Index(object):
'_original_clean_pv', '_original_trade_date',
'index_type', 'series', 'tenor', '_observed']
def __init__(self, start_date, end_date, recovery, fixed_rate,
- notional = 10e6, quote_is_price=False, issue_date=None):
+ notional=10e6, quote_is_price=False, issue_date=None):
"""
start_date : :class:`datetime.date`
index start_date (Could be issue date, or last imm date)