pythonquantlib

Python Quantlib ->TypeError: Wrong number or type of arguments for overloaded function 'new_Thirty360'


I am trying to run the code below, but for some reason on 1 pc it runs normally, on the 2nd one it fails with the below error message; what is the reason that on 1 pc it runs normally and on the 2nd one it fails?

the code source :http://gouthamanbalaraman.com/blog/quantlib-bond-modeling.html

!pip install QuantLib
import QuantLib as ql
todaysDate = ql.Date(15, 1, 2015)
ql.Settings.instance().evaluationDate = todaysDate
spotDates = [ql.Date(15, 1, 2015), ql.Date(15, 7, 2015), ql.Date(15, 1, 2016)]
spotRates = [0.0, 0.005, 0.007]
dayCount = ql.Thirty360()
calendar = ql.UnitedStates()
interpolation = ql.Linear()
compounding = ql.Compounded
compoundingFrequency = ql.Annual
spotCurve = ql.ZeroCurve(spotDates, spotRates, dayCount, calendar, interpolation,
                             compounding, compoundingFrequency)
spotCurveHandle = ql.YieldTermStructureHandle(spotCurve)


> TypeError: Wrong number or type of arguments for overloaded function
> 'new_Thirty360'.   Possible C/C++ prototypes are:
>     QuantLib::Thirty360::Thirty360(QuantLib::Thirty360::Convention,Date
> const &)
>     QuantLib::Thirty360::Thirty360(QuantLib::Thirty360::Convention)

Solution

  • This is expected in version 1.28, as per release notes (see https://github.com/lballabio/QuantLib-SWIG/releases/tag/QuantLib-SWIG-v1.28). The default constructors are no longer available in the underlying C++ library, that deprecated them back in version 1.23.

    The rationale is that there are several different 30/360 conventions. The default constructor used to pick one particular convention (namely, 30/360 bond basis) but this made it possible for a user to just specify 30/360 and get the wrong day counter unknowingly. Since this release, you need to specify the exact convention. If you want the exact behavior as before, replace ql.Thirty360() with ql.Thirty360(ql.Thirty360.BondBasis). If, instead, you realize that those were not the actual conventions you wanted, pass the correct convention to the constructor of the day counter.

    The same applies to ql.ActualActual(), which used to default to ISDA but in 1.28 requires an explicit convention: ql.ActualActual(ql.ActualActual.ISDA)