|
From: Quant <qua...@gm...> - 2023-12-24 14:16:46
|
Hi QuantLib Users,
I am trying to implement the Convex Monotone interpolation as shown below;
curve = ql.PiecewiseConvexMonotoneZero(today, helpers, day_count)
# curve = ql.PiecewiseLogMixedLinearCubicDiscount(today, helpers, day_count)
# curve = ql.PiecewiseSplineCubicDiscount(today, helpers, day_count)
# Enable Extrapolation:
# This line enables extrapolation for the yield curve.
# Extrapolation allows the curve to provide interest rates or rates
beyond the observed data points,
# which can be useful for pricing or risk management purposes.
curve.enableExtrapolation()
# Print the Zero Rates, Forward Rates and Discount Factors at node dates
# print(pd.DataFrame(curve.nodes()))
node_data = {'Date': [],
'Zero Rates': [],
'Forward Rates': [],
'Discount Factors': []}
for dt in curve.dates():
node_data['Date'].append(dt)
node_data['Zero Rates'].append(curve.zeroRate(dt, day_count,
ql.Compounded, ql.Annual).rate())
node_data['Forward Rates'].append(curve.forwardRate(dt, dt +
ql.Period(1, ql.Years), day_count, ql.Annual).rate())
node_data['Discount Factors'].append(curve.discount(dt))
node_dataframe = pd.DataFrame(node_data)
And I am getting the following error;
Traceback (most recent call last):
File "/Users/Library/CloudStorage/OneDrive-Personal/QuantLib
Software/Valuations/IRS using Bond Bootstrapping/IRS using Bond
Bootstrapping 3.py", line 87, in <module>
node_data['Forward Rates'].append(curve.forwardRate(dt, dt +
ql.Period(1, ql.Years), day_count, ql.Annual).rate())
File "/usr/local/lib/python3.9/site-packages/QuantLib/QuantLib.py", line
8617, in forwardRate
return _QuantLib.YieldTermStructure_forwardRate(self, *args)
RuntimeError: Convex-monotone spline derivative not implemented
Is this a known issue with PiecewiseConvexMonotoneZero or it's an error
that can be fixed in my code? If it can be fixed where do I need to fix?
Thanks & regards,
|