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.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/python/analytics/index.py b/python/analytics/index.py
index 0da98e47..a1ec4bb8 100644
--- a/python/analytics/index.py
+++ b/python/analytics/index.py
@@ -15,9 +15,24 @@ from pyisda.curve import SpreadCurve
from .utils import previous_twentieth
from yieldcurve import YC, ql_to_jp, roll_yc, rate_helpers
-
serenitasdb = dbconn('serenitasdb')
+def g(index, spread : float, exercise_date : datetime.date, use_rolled_curve = True):
+ """ computes the strike clean price using the expected forward yield curve """
+ if use_rolled_curve:
+ rolled_curve = roll_yc(index._yc, exercise_date)
+ else:
+ rolled_curve = index._yc
+ step_in_date = exercise_date + datetime.timedelta(days=1)
+ exercise_date_settle = (pd.Timestamp(exercise_date) + 3* BDay()).date()
+ sc = SpreadCurve(exercise_date, rolled_curve, index.start_date,
+ step_in_date, exercise_date_settle,
+ [index.end_date], array.array('d', [spread * 1e-4]),
+ index.recovery)
+ a = index._fee_leg.pv(exercise_date, step_in_date, exercise_date_settle,
+ rolled_curve, sc, True)
+ return (spread - index.fixed_rate) * a *1e-4
+
class Index():
""" minimal class to represent a credit index """
def __init__(self, start_date, end_date, recovery, fixed_rate,