简体   繁体   English

在Quantlib中计算固定腿普通香草IRS的现金流

[英]Calculate Cashflow Fixed Leg Plain Vanilla IRS in Quantlib

I am tryining to calculate the cashflow for the fixed leg of a plain vanilla IRS. 我正在尝试计算普通香草IRS固定支路的现金流量。 Somehow I am receibing the following error message, and don't know where the problem is: 我不知何故收到以下错误消息,并且不知道问题出在哪里:

TypeError: in method 'FixedRateLeg', argument 3 of type 'std::vector< Real,std::allocator< Real > > const &' TypeError:在“ FixedRateLeg”方法中,类型为“ std :: vector <实数,std :: allocator <实>> const&”的参数3

The code looks like the following: 该代码如下所示:

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())

FixedRateLeg allows to pass different notionals for different coupons, so it takes a vector of notionals (a list in Python) instead of a single one. FixedRateLeg允许为不同的优惠券传递不同的名义,因此它采用名义的向量(Python中的列表),而不是一个向量。 Passing [Notional] instead of Notional will work; 通过[Notional]代替Notional将有效; if the list is shorter than the number of coupons, the last notional in the list will be used for all the remaining ones. 如果列表短于优惠券的数量,则列表中的最后一个概念将用于其余所有概念。 The same goes for the rates; 费率也是如此; you'll have to pass [Fixed_Rate] . 您必须通过[Fixed_Rate]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM