I am borrowing from an example in the "Quantlib Python Cookbook" section 7, to ask my question. To make the point as clear as possible I simplify the code a bit. The aim is to strip the EONIA curve from OIS quotes.

The initialization is not to question:

%pylab inline --no-import-all
import math
import numpy
import utils
import matplotlib.pyplot as plt

from QuantLib import *
today = Date(11, December, 2012)
Settings.instance().evaluationDate = today

A list of OISRateHelpers is set up from which the term structure shall be stripped. The "2" tells the helper object that the quotes correspond to contracts that start +2 days from now.

helpers = [ OISRateHelper(2, Period(*tenor),      
         QuoteHandle(SimpleQuote(rate/100)), eonia)
         for rate, tenor in [(0.002, (15,Months)), (0.008, (18,Months)),
                             (0.021, (21,Months)), (0.036, (2,Years)),
                             (0.127, (3,Years)), (0.274, (4,Years)),
                             (0.456, (5,Years)), (0.647, (6,Years)),
                             (0.827, (7,Years)), (0.996, (8,Years)),
                             (1.147, (9,Years)), (1.280, (10,Years)),
                             (1.404, (11,Years)), (1.516, (12,Years)),
                             (1.764, (15,Years)), (1.939, (20,Years)),
                             (2.003, (25,Years)), (2.038, (30,Years))] ]

The bootstrapping is then performed by

eonia_curve = PiecewiseLogCubicDiscount(0, TARGET(), helpers, Actual365Fixed() ) 

The initial "0" above tells the bootstrapping algorithm that the reference date of the term structure should be on the previously defined evaluationDate.

I don't want my term structure object to change its reference date later on when I change the evaluation date. So I tried to call

eonia_curve = PiecewiseLogCubicDiscount(today, TARGET(), helpers, Actual365Fixed() ) 

which I found very natural. But it resulted in: NotImplementedError: Wrong number or type of arguments for overloaded function 'new_PiecewiseLogCubicDiscount'.

Question: How could I correct the above code line to bootstrap with a fixed reference date?

Side note: In section 5 of the mentioned book the author discussed the difference of fixed vs unfixed reference dates. However the code they used did't really help me, because the date was not explicitly specified but taken from an earlier stripped term structure.

# curve1 is an allready stripped term structure object
dates, rates = zip(*curve1.nodes())

# first date is taken as reference date
curve2 = ForwardCurve(dates, rates, Actual360())

However, I don't want to call the bootstripping algorithm twice: once with the evaluation date as reference date and a second time with today as reference date.

Thank you very much, Bernd


2 Answers 2


To construct a PiecewiseLogCubicDiscount object with a fixed reference date, please use the following constructor:

PiecewiseLogCubicDiscount(reference_date, helpers, day_counter, ...)

Taking your example:

eonia_curve = PiecewiseLogCubicDiscount(Date(15, December, 2012), helpers, Actual365Fixed())
# result: Date(15,12,2012)

How you can get to this result yourself:

If you use a constructor that doesn't exist, or that's not SWIGed, then you will get the NotImplementedError, which will usually list the available implementations, and in your case, you can see in this list the one you are looking for. For example:

#NotImplementedError: Wrong number or type of arguments for overloaded function 'new_PiecewiseLogCubicDiscount'.
# Possible C/C++ prototypes are:
# ...
# PiecewiseLogCubicDiscountPtr::PiecewiseLogCubicDiscountPtr(Date const &,std::vector< boost::shared_ptr< RateHelper >,std::allocator< boost::shared_ptr< RateHelper > > > const &,DayCounter const &)

You could also check what's available or not in the SWIG interface files:

  1. Check piecewiseyieldcurve.i file in the QuantLib-SWIG project. Specifically lines 46 and 110.

     46: %define export_piecewise_curve(Name,Base,Interpolator)
    110: export_piecewise_curve(PiecewiseLogCubicDiscount,Discount,MonotonicLogCubic);

    These show that PiecewiseLogCubicDiscount is a PiecewiseYieldCurve with Base = Discount and Interpolator = MonotonicLogCubic.

  2. Have a look at the SWIGed constructors. In lines 56 to 69, you can find the one you are looking for. It takes the following arguments:

    • Reference date: const Date& referenceDate
    • Rate helpers : const std::vector<boost::shared_ptr<RateHelper> >& instruments
    • Day counter : const DayCounter& dayCounter
    • Optional arguments jumps, jumpDates, accuracy and interpolator.
  • 1
    $\begingroup$ Dear byouness, thank you for you extensive answer. You made the point very clear. I must admit, that it is also very reasonable that the stripping function doesn't want to be given a calendar object. If it doesn't need to add some additional settlement days, it also doesn't need to know the calendar. $\endgroup$
    – Bernd
    Jun 11, 2018 at 18:08

Try ql.Date(dd,mm,yyyy) instead of Date(dd,mm,yyyy). It should fix your problem. I use the former "today" and it's fine.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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