1
$\begingroup$

I having an issue with interpolation in QuantLib Python. Please see the code below for a minimum working example

myCurve = ql.ZeroCurve([ql.Date(2,3,2024),ql.Date(2,8,2024)], 
                             [0.05,0.09], 
                             ql.Actual365Fixed(), 
                             ql.NullCalendar(),
                             ql.Linear(),
                             ql.Continuous)

print(myCurve.zeroRate(ql.Date(2,3,2024), ql.Actual365Fixed(),ql.Continuous).rate())
print(myCurve.zeroRate(0,ql.Continuous).rate())

The output in both of those cases is 0.05000954248362214. I am expecting to recover the input value of 0.05?

$\endgroup$

1 Answer 1

3
$\begingroup$

For historical reasons, the curve implementation goes through discount factors to calculate zero rates, no matter what the underlying representation is; see https://github.com/lballabio/QuantLib/blob/master/ql/termstructures/yieldtermstructure.cpp#L98-L115.

Unfortunately, this makes $t=0$ a special case. Unlike for all other times, we can't retrieve the zero from the discount as the formula becomes indeterminate. Therefore, we use as proxy the zero we can retrieve from a small time $t' > 0$. Of course, though $t'$ is small, that's already different enough from zero to see a difference, since your rates are increasing sharply.

Other nodes don't have this problem; you should be able to retrieve your original zero rate from 2024-08-02 within numerical accuracy.

I might try to sidestep this problem in a future release, but I'll have to be careful to keep the change backward compatible in interface and behavior, so I can't guarantee I'll succeed.

$\endgroup$
1
  • $\begingroup$ Thanks for your detailed response! I keep this in mind during my curve construction exercises. Cheers! $\endgroup$ Aug 25 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.