NotImplementedError: Wrong number or type of arguments for overloaded function Quantlib Python
NotImplementedError: Wrong number or type of arguments for overloaded function Quantlib Python
我是 QuantLib 的新手,刚刚安装了 Quantlib 和 Quantlib-Python。我有 MS Visual Studio 2017 和 2.7.15 64 位。
我正在尝试完成 Goutham Balaraman 博客 (http://gouthamanbalaraman.com/blog/quantlib-basics.html) 中的示例。但是,我遇到了一个错误。
代码:
# schedule object can be used to construct a list of dates such as coupon payments
date1 = ql.Date(1, 1, 2015)
date2 = ql.Date(1, 1, 2016)
tenor = ql.Period(ql.Monthly)
calendar = ql.UnitedStates
schedule = ql.Schedule(date1, date2, tenor, calendar, ql.Following, ql.Following, ql.DateGeneration.Forward, False)
schedule
Error:
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-5-cae31a33e500> in <module>()
4 tenor = ql.Period(ql.Monthly)
5 calendar = ql.UnitedStates
----> 6 schedule = ql.Schedule(date1, date2, tenor, calendar, ql.Following, ql.Following, ql.DateGeneration.Forward, False)
7 schedule
c:\users\papu\envs\quantlib\lib\site-packages\QuantLib\QuantLib.pyc in __init__(self, *args)
9419
9420 def __init__(self, *args):
-> 9421 this = _QuantLib.new_Schedule(*args)
9422 try:
9423 self.this.append(this)
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Schedule'.
Possible C/C++ prototypes are:
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &,Calendar const &,BusinessDayConvention const,boost::optional< BusinessDayConvention >,boost::optional< Period > const,boost::optional< DateGeneration::Rule >,boost::optional< bool >,std::vector< bool,std::allocator< bool > > const &)
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &,Calendar const &,BusinessDayConvention const,boost::optional< BusinessDayConvention >,boost::optional< Period > const,boost::optional< DateGeneration::Rule >,boost::optional< bool >)
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &,Calendar const &,BusinessDayConvention const,boost::optional< BusinessDayConvention >,boost::optional< Period > const,boost::optional< DateGeneration::Rule >)
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &,Calendar const &,BusinessDayConvention const,boost::optional< BusinessDayConvention >,boost::optional< Period > const)
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &,Calendar const &,BusinessDayConvention const,boost::optional< BusinessDayConvention >)
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &,Calendar const &,BusinessDayConvention const)
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &,Calendar const &)
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &)
Schedule::Schedule(Date const &,Date const &,Period const &,Calendar const &,BusinessDayConvention,BusinessDayConvention,DateGeneration::Rule,bool,Date const &,Date const &)
Schedule::Schedule(Date const &,Date const &,Period const &,Calendar const &,BusinessDayConvention,BusinessDayConvention,DateGeneration::Rule,bool,Date const &)
Schedule::Schedule(Date const &,Date const &,Period const &,Calendar const &,BusinessDayConvention,BusinessDayConvention,DateGeneration::Rule,bool)
Schedule::Schedule()
有什么问题的帮助吗?
不是真正的答案,仍然在这里给出,因为答案格式正确而评论不是。
与您的参数最匹配的重载:
schedule = ql.Schedule(
date1,
date2,
tenor,
calendar,
ql.Following,
ql.Following,
ql.DateGeneration.Forward,
False
)
是:
Schedule::Schedule(
Date const &,
Date const &,
Period const &,
Calendar const &,
BusinessDayConvention,
BusinessDayConvention,
DateGeneration::Rule,
bool
)
假设 ql.DataGeneration.Forward 是 DataGeneration.Rule 类型,
不幸的是我看不出你的代码有什么问题...
日历应该是 ql.UnitedStates()
,而不是 ql.UnitedStates
。就像现在一样,您传递的是 class 本身,而不是它的一个实例。
我是 QuantLib 的新手,刚刚安装了 Quantlib 和 Quantlib-Python。我有 MS Visual Studio 2017 和 2.7.15 64 位。
我正在尝试完成 Goutham Balaraman 博客 (http://gouthamanbalaraman.com/blog/quantlib-basics.html) 中的示例。但是,我遇到了一个错误。
代码:
# schedule object can be used to construct a list of dates such as coupon payments
date1 = ql.Date(1, 1, 2015)
date2 = ql.Date(1, 1, 2016)
tenor = ql.Period(ql.Monthly)
calendar = ql.UnitedStates
schedule = ql.Schedule(date1, date2, tenor, calendar, ql.Following, ql.Following, ql.DateGeneration.Forward, False)
schedule
Error:
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-5-cae31a33e500> in <module>()
4 tenor = ql.Period(ql.Monthly)
5 calendar = ql.UnitedStates
----> 6 schedule = ql.Schedule(date1, date2, tenor, calendar, ql.Following, ql.Following, ql.DateGeneration.Forward, False)
7 schedule
c:\users\papu\envs\quantlib\lib\site-packages\QuantLib\QuantLib.pyc in __init__(self, *args)
9419
9420 def __init__(self, *args):
-> 9421 this = _QuantLib.new_Schedule(*args)
9422 try:
9423 self.this.append(this)
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Schedule'.
Possible C/C++ prototypes are:
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &,Calendar const &,BusinessDayConvention const,boost::optional< BusinessDayConvention >,boost::optional< Period > const,boost::optional< DateGeneration::Rule >,boost::optional< bool >,std::vector< bool,std::allocator< bool > > const &)
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &,Calendar const &,BusinessDayConvention const,boost::optional< BusinessDayConvention >,boost::optional< Period > const,boost::optional< DateGeneration::Rule >,boost::optional< bool >)
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &,Calendar const &,BusinessDayConvention const,boost::optional< BusinessDayConvention >,boost::optional< Period > const,boost::optional< DateGeneration::Rule >)
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &,Calendar const &,BusinessDayConvention const,boost::optional< BusinessDayConvention >,boost::optional< Period > const)
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &,Calendar const &,BusinessDayConvention const,boost::optional< BusinessDayConvention >)
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &,Calendar const &,BusinessDayConvention const)
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &,Calendar const &)
Schedule::Schedule(std::vector< Date,std::allocator< Date > > const &)
Schedule::Schedule(Date const &,Date const &,Period const &,Calendar const &,BusinessDayConvention,BusinessDayConvention,DateGeneration::Rule,bool,Date const &,Date const &)
Schedule::Schedule(Date const &,Date const &,Period const &,Calendar const &,BusinessDayConvention,BusinessDayConvention,DateGeneration::Rule,bool,Date const &)
Schedule::Schedule(Date const &,Date const &,Period const &,Calendar const &,BusinessDayConvention,BusinessDayConvention,DateGeneration::Rule,bool)
Schedule::Schedule()
有什么问题的帮助吗?
不是真正的答案,仍然在这里给出,因为答案格式正确而评论不是。
与您的参数最匹配的重载:
schedule = ql.Schedule(
date1,
date2,
tenor,
calendar,
ql.Following,
ql.Following,
ql.DateGeneration.Forward,
False
)
是:
Schedule::Schedule(
Date const &,
Date const &,
Period const &,
Calendar const &,
BusinessDayConvention,
BusinessDayConvention,
DateGeneration::Rule,
bool
)
假设 ql.DataGeneration.Forward 是 DataGeneration.Rule 类型, 不幸的是我看不出你的代码有什么问题...
日历应该是 ql.UnitedStates()
,而不是 ql.UnitedStates
。就像现在一样,您传递的是 class 本身,而不是它的一个实例。