我试着计算普通香草国税局固定支腿的现金流。不知何故,我收到了以下错误消息,不知道问题出在哪里:
TypeError:在方法'FixedRateLeg‘中,'std::vector< Real,std::allocator< Real >> const &’类型的参数3
代码如下所示:
import QuantLib as ql
today = ql.Date(15, ql.December, 2015)
ql.Settings.instance().evaluationDate = today
#Input parameters
effective_date = ql.Date(1, ql.January, 2016)
termination_date = ql.Date(10, ql.January, 2018)
tenor_fixed = ql.Period(6, ql.Months)
calendar = ql.TARGET()
business_convention = ql.Following
termination_business_convention = ql.Following
date_generation = ql.DateGeneration.Forward
end_of_month = False
Notional = 10000.0
day_count_conv_fixed = ql.Thirty360()
Fixed_Rate = 0.02
Spread_On_Interest_Rate = 0.0
#Fixed Rate
fixed_schedule = ql.Schedule(effective_date, termination_date,
                          tenor_fixed, calendar, business_convention, termination_business_convention,
                          date_generation, end_of_month)
cfs= ql.FixedRateLeg(fixed_schedule,ql.Thirty360(),Notional,Fixed_Rate)
for c in cfs:
    print(c.date(), c.amount())发布于 2017-07-25 08:13:47
FixedRateLeg允许为不同的优惠券传递不同的符号,因此它采用了一个notionals向量(在Python中是一个列表),而不是一个单独的。传递[Notional]而不是Notional将有效;如果列表小于优惠券的数量,则列表中的最后一个概念将用于所有剩余的优惠券。费率也是如此;您必须通过[Fixed_Rate]。
https://stackoverflow.com/questions/45290981
复制相似问题