簡體   English   中英

在Quantlib中計算固定腿普通香草IRS的現金流

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

我正在嘗試計算普通香草IRS固定支路的現金流量。 我不知何故收到以下錯誤消息,並且不知道問題出在哪里:

TypeError:在“ FixedRateLeg”方法中,類型為“ std :: vector <實數,std :: allocator <實>> 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())

FixedRateLeg允許為不同的優惠券傳遞不同的名義,因此它采用名義的向量(Python中的列表),而不是一個向量。 通過[Notional]代替Notional將有效; 如果列表短於優惠券的數量,則列表中的最后一個概念將用於其余所有概念。 費率也是如此; 您必須通過[Fixed_Rate]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM