Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 计算Quantlib中的固定资产现金流_Python_Swap_Quantlib - Fatal编程技术网

Python 计算Quantlib中的固定资产现金流

Python 计算Quantlib中的固定资产现金流,python,swap,quantlib,Python,Swap,Quantlib,我正在尝试计算普通IRS固定分支的现金流。不知何故,我收到了以下错误消息,不知道问题出在哪里: TypeError:在方法“FixedRateLeg”中,参数3的类型为“std::vector”< Real,std::分配器>常量&' 代码如下所示: import QuantLib as ql today = ql.Date(15, ql.December, 2015) ql.Settings.instance().evaluationDate = today #Input paramete

我正在尝试计算普通IRS固定分支的现金流。不知何故,我收到了以下错误消息,不知道问题出在哪里:

TypeError:在方法“FixedRateLeg”中,参数3的类型为“std::vector”< Real,std::分配器>常量&'

代码如下所示:

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中采用概念向量作为列表,而不是单个列表。通过[名义上的]而不是名义上的将起作用;如果列表短于优惠券数量,则列表中的最后一个概念将用于所有剩余的优惠券。利率也是如此;您必须通过[固定利率]。

嗨,Luigi,非常感谢您的快速回答!!!不知怎的,我错过了它被定义为向量。嗨,路易吉,很抱歉再次询问,但我如何才能得到现金流的现值?净现值(npv)在swapengine中是明确的,但我如何才能获得净现值?优惠券可以给出它们的金额,但它们没有折扣信息。您可以使用CashFlows类的方法。非常感谢您的回答。你有一个例子吗?我手边没有,但是现金流。npvleg,折扣曲线应该是你的腿,折扣曲线是你想要使用的曲线的手柄。