pythonquantlibquantlib-swig

Quantlib Scehdule Error "Wrong number or type of arguments for overloaded function 'new_Schedule'."


Hi I am trying to create a quantlib schedule using the below parameters. I suspect the error is due to me passing a class rather than a class method?

I have bought the python cookbook and looked at Read the Docs for quantlib - is there another resource that has python code examples? There seems to be a huge variety of variables / classes and function calls and I can't see the wood for the trees!

any help much appreciated @Luigi Ballabio

import quantlib as ql

issue_date = ql.Date(30,3,2021)
maturity_date = ql.Date(23,4,2028)
frequency = ql.Semiannual
calendar = ql.UnitedKingdom
bus_day_convention = ql.ModifiedFollowing

schedule = ql.Schedule(
    issue_date,
    maturity_date,
    ql.Period(frequency),
    calendar,
    bus_day_convention, 
    bus_day_convention,  
    ql.DateGeneration.Backward,
    False
)

Error message:

TypeError: Wrong number or type of arguments for overloaded function

Possible C/C++ prototypes are:
[...]
Schedule::Schedule(Date const &,Date const &,Period const &,Calendar const &,BusinessDayConvention,BusinessDayConvention,DateGeneration::Rule,bool)

Update - I replaced frequency with ql.Period(frequency) as the function signature looks to expect a ql.Period object. The error persists.


Solution

  • Calendars are classes, not enumerations. You need

    calendar = ql.UnitedKingdom()