|
From: Luigi B. <lui...@gm...> - 2023-07-10 12:48:04
|
Compounded vs continuous can be managed — but it's the conversion of dates into times that Actual/Actual gets wrong. For more details, see < https://www.youtube.com/watch?v=dQjd3hAshj4>. Hope this helps, Luigi On Fri, Jul 7, 2023 at 5:37 PM Alex Leonard <aml...@gm...> wrote: > Hi Philippe, > > So correct me if I'm wrong but net the issue is that the curve is > interpolating continuously compounded rates and I am charting compounded > rates which is producing this zigzag pattern. I see that when I change my > zeroRate function to price using continuously compounded rates the > interpolation looks smooth. The issue I was encountering was that when I > would calculate Z spreads on USTs ~ 2 weeks apart they were producing very > different levels when using an OIS curve they were more or less the same. > It looks like this is due to the 'stepped' pattern of the discrete > interpolation producing the same discount rates for cash flows even though > they were close but different times. I am guessing using > continuous compounding on the z spread calculation should fix that. > > Much appreciated for pointing me in the right direction, > > Alex > > On Thu, Jul 6, 2023 at 11:45 PM philippe hatstadt <pha...@ma...> > wrote: > >> 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 >> > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |