|
From: philippe h. <pha...@ma...> - 2023-07-06 21:45:39
|
Actual/Actual or 30/360 should never ever be used as the internal day count representation of a zero curve. Actual/360 or Actual/365 is safe. Be careful to not confuse the day count basis of instruments versus that of the curve itself. Zero rates are jagged if you use linear instantaneous zeros. If you plan to bump rates to compute hedges, a stepwise zero if better, which is the same as log linear discount factors. Linear zeroes have bad perturbation propagation behavior and any spline obviously. Stepwise zeros do not. If you want a smooth curve for relative value, Nelson-Siegel works well. Regards Philippe Hatstadt +1-203-252-0408 > On Jul 6, 2023, at 5:18 PM, Alex Leonard <aml...@gm...> wrote: > > > Hello, > > I have recently started using quantlib in python so hope this hasn't been answered many times before > > I was trying to bootstrap a zero curve with benchmark USTs and I noticed that the zero rates were jagged in between the nodes. I subsequently tried building a zeroCurve with the bootstrapped node points and the interpolated zero rates are still jagged even with a simple linear interp. Just as a toy example I put together the following. I have attached the graph of the zero rates with the zig zag forwards. Is there some interpolation method I need to instantiate somewhere? > > I have additionally noticed that when I change the dayCounter to ActualActual(1) the forwards are stepped instead of zig zagged. Any help is much appreciated. > > thanks in advance, > > Alex > > ######################### > > import datetime > import pandas as pd > import matplotlib.pyplot as plt > import QuantLib as ql > from dateutil.relativedelta import relativedelta > > #setting up the day > date = pd.Timestamp(2015, 1, 20) > day = datetime.datetime(date.year, date.month, date.day) > today = ql.Date(day.day, day.month, day.year) > ql.Settings.instance().evaluationDate = today > > #data points and the curve > dates = [ql.Date(20,1,2015),ql.Date(15,2,2016), ql.Date(15,2,2017), ql.Date(15,2,2018)] > zeros = [0.001,0.01, 0.02, 0.03] > curve = ql.ZeroCurve(dates, zeros, ql.ActualActual(3)) > > #dates and zero rates to check smoothness of interpolation > start = day > end = day + relativedelta(years = 2) > dates = pd.date_range(start, end, freq='B') > > rates = [] > for date in dates: > thisRate = curve.zeroRate(ql.Date(date.day,date.month,date.year), ql.ActualActual(1), ql.Compounded, ql.Semiannual).rate() > rates.append(thisRate*100) > > plt.plot(dates,rates) > > ######################### > <Figure 2023-07-06 230502.png> > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users |