Search code examples
pythonquantlib

Difference between PiecewiseCubicZero and PiecewiseLogCubicDiscount


I'm creating a PiecewiseCubicZerocurve and a PiecewiseLogCubicDiscount and obtaining the 1-year Zero rate from both curves. I expect my 1-year zero rate to be equal to my 1-year par rate.

I got two questions:

  • Why does the zero rate differ for PiecewiseCubicZerocurve and PiecewiseLogCubicDiscount?
  • Why is the 1-year zero rate not equal to the 1-year par rate?

I tried playing around with the number of business days and the convention. But that has not solved the problem so far.

from QuantLib import *
today = Date(29, 1, 2019)
Settings.instance().evaluationDate = today

convention = Actual365Fixed()

helpers = [OISRateHelper(2, Period(*tenor),
                           QuoteHandle(SimpleQuote(rate)), Eonia())
             for rate, tenor in [(0.001, (1, Years)), (0.002, (2,Years))]]

curve1 = PiecewiseCubicZero(0, TARGET(), helpers, convention)
curve2 = PiecewiseLogCubicDiscount(0, TARGET(), helpers, convention)

print('discount factor (zero)', curve1.discount(today + Period(1, Years)))
print('discount factor (discount)', curve2.discount(today + Period(1, Years)))
print('expected discount factor', 1/(1+0.001))
print('zero (zero)', curve1.zeroRate(today + Period(1, Years), convention, Annual))
print('zero (discount)', curve2.zeroRate(today + Period(1, Years), convention, Annual))
print('expected zero 0.1%')

Print statements output:

discount factor (zero) 0.9989871380405977
discount factor (discount) 0.9989954702856564
expected discount factor 0.9990009990009991
zero (zero) 0.101389 % Actual/365 (Fixed) Annual compounding
zero (discount) 0.100554 % Actual/365 (Fixed) Annual compounding
expected zero 0.1%

Solution

  • I think it is a matter of Business Day Convention and Settlement Days.

    When using convention = Actual360(), which is standard for EONIA, and 0 settlementDays in the OISRateHelper (instead of 2), I get the following ouput:

    zero (zero) 0.099999 % Actual/360 Annual compounding
    zero (discount) 0.099999 % Actual/360 Annual compounding
    expected zero 0.1%
    

    When using settlementDays > 0, you have to adjust your curves and your maturity date accordingly.