我正在尝试计算普通香草国税局固定航段的现金流量。不知何故,我收到以下错误消息,并且不知道问题出在哪里:
TypeError:在方法' FixedRateLeg'中,类型' std :: vector<的参数3 皇马的std ::分配器<真实> > const&'
代码如下所示:
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())
答案 0 :(得分:1)
FixedRateLeg
允许为不同的优惠券传递不同的概念,因此它需要一个概念向量(Python中的列表)而不是单个。传递[Notional]
代替Notional
将有效;如果列表短于优惠券数量,则列表中的最后一个名称将用于所有剩余的优惠券。费率也是如此;你必须通过[Fixed_Rate]
。