我是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()
有什么问题的帮助吗?
答案 0 :(得分:0)
由于答案的格式正确且注释不正确,因此这里仍然没有给出答案。
最适合您的参数的重载:
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, 不幸的是,我看不到您的代码有什么问题...
答案 1 :(得分:0)
日历应为ql.UnitedStates()
,而不是ql.UnitedStates
。现在,您正在传递类本身,而不是它的实例。