简体   繁体   中英

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. 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 &'

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. Passing [Notional] instead of Notional will work; 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] .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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