Hi I am trying to create a zero curve from continuous rates data. I keep getting an error "RuntimeError: two dates correspond to the same time under this curve's day count convention". What am I doing wrong? Identical function but replacing the daycount with ql.Thirty360 works fine. I also tried replacing compounding and frequency input with ql.Continuous and ql.NoFrequency but it didn't make any difference. Thanks in advance for any help!
-
1$\begingroup$ What an unhelpful error message! Why doesn't the library say right away what the conflicting dates are both bumped and unbunped? $\endgroup$– Dimitri VulisCommented Nov 28, 2022 at 23:03
-
$\begingroup$ Why indeed. This is one for next release. $\endgroup$– Luigi BallabioCommented Nov 29, 2022 at 11:15
1 Answer
In short: the passed dates are converted into times, and the times are used to interpolate the passed rates. The conversion is done by taking the first passed date as t=0
, and by assigning to each further date d
the time t = dayCounter.yearFraction(dates[0], d)
.
What is happening is that the act/act day counter calculates the same time for two different dates, and the code doesn't know how to build the interpolation in this case. As Dimitri said, the error message is not helpful; but you can find the relevant dates by running something like:
day_count = ql.ActualActual(ActualActual.ISMA)
for d in spotDates:
print(d, day_count.yearFraction(spotDates[0], d))
and looking for identical times.
However, note that using a day counter like Act/Act for a curve is not great; see the video at https://www.youtube.com/watch?v=dQjd3hAshj4 for more info. If the rates you have available are indeed using the act/act convention, you might be better off converting them into discount factors and using the DiscountCurve
class instead with a more regular day count.
-
-
$\begingroup$ spotDates in my case is a a vector at monthly interval from 9/30/2022 and goes out to 100Y. The yearFraction check looks fine up until year 2077. From that point onward every January accrues 2 months worth and February accrues zero. Interesting.. $\endgroup$– JessicaCommented Nov 30, 2022 at 21:03