在 Quantlib 中计算现金流 Fixed Leg Plain Vanilla IRS
Calculate Cashflow Fixed Leg Plain Vanilla IRS in Quantlib
我正在尝试计算普通 IRS 的固定部分的现金流量。不知何故,我收到了以下错误消息,但不知道问题出在哪里:
TypeError: in method 'FixedRateLeg', argument 3 of type 'std::vector<
Real,std::allocator< Real > > 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())
FixedRateLeg
允许为不同的优惠券传递不同的面值,因此它采用面值向量(Python 中的列表)而不是单个面值。通过 [Notional]
而不是 Notional
将起作用;如果列表少于优惠券的数量,则列表中的最后一个名义将用于所有剩余的。费率也是如此;你必须通过 [Fixed_Rate]
.
我正在尝试计算普通 IRS 的固定部分的现金流量。不知何故,我收到了以下错误消息,但不知道问题出在哪里:
TypeError: in method 'FixedRateLeg', argument 3 of type 'std::vector< Real,std::allocator< Real > > 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())
FixedRateLeg
允许为不同的优惠券传递不同的面值,因此它采用面值向量(Python 中的列表)而不是单个面值。通过 [Notional]
而不是 Notional
将起作用;如果列表少于优惠券的数量,则列表中的最后一个名义将用于所有剩余的。费率也是如此;你必须通过 [Fixed_Rate]
.