使用 Python 进行 QuantLib Vanilla 掉期定价 - 错误

问题描述 投票:0回答:1

我真的需要帮助...我有一个使用 QuantLib 构建自己的 Vanilla Swap Pricer 的项目。我想根据 ois 掉期的市场价格进行贴现计算,并根据 Euribor 6M 掉期 + FRA 的市场价格进行预测固定。

总而言之,我的目标是尽可能接近彭博社对标准 Euribor 6M 掉期的定价(贴现 ois - 远期 Euribor 6M)。

很容易开始,我得到了 QuantLib 的文档,但是当完全遵循这段代码时,我遇到了错误......

https://quantlib-python-docs.readthedocs.io/en/latest/examples/fixedvenue/vanillaswap.html

错误如下:

TypeError:MakeVanillaSwap() 获得意外的关键字参数“Nominal”

我非常感谢您的帮助,因为我陷入了项目的第一步......

谢谢!

我尝试删除标称值,因此我认为它使用 1 个默认值,但我不知道应该在哪里输入标称值。

python swap finance derivative quantlib
1个回答
0
投票

该文档至少对于当前版本的 QuantLib 来说似乎不正确。

检查

MakeVanillaSwap
的源代码会显示参数名称与对应方法名称的查找,该方法名称是在 C++ QuantLib 交换对象的 Python swig 包装类上调用的:

_MAKEVANILLA_METHODS = {
    "receiveFixed": "receiveFixed",
    "swapType": "withType",
    "nominal": "withNominal",
    "settlementDays": "withSettlementDays",
    "effectiveDate": "withEffectiveDate",
    "terminationDate": "withTerminationDate",
    "dateGenerationRule": "withRule",
    "paymentConvention": "withPaymentConvention",
    "fixedLegTenor": "withFixedLegTenor",
    "fixedLegCalendar": "withFixedLegCalendar",
    "fixedLegConvention": "withFixedLegConvention",
    "fixedLegTerminationDateConvention": "withFixedLegTerminationDateConvention",
    "fixedLegDateGenRule": "withFixedLegRule",
    "fixedLegEndOfMonth": "withFixedLegEndOfMonth",
    "fixedLegFirstDate": "withFixedLegFirstDate",
    "fixedLegNextToLastDate": "withFixedLegNextToLastDate",
    "fixedLegDayCount": "withFixedLegDayCount",
    "floatingLegTenor": "withFloatingLegTenor",
    "floatingLegCalendar": "withFloatingLegCalendar",
    "floatingLegConvention": "withFloatingLegConvention",
    "floatingLegTerminationDateConvention": "withFloatingLegTerminationDateConvention",
    "floatingLegDateGenRule": "withFloatingLegRule",
    "floatingLegEndOfMonth": "withFloatingLegEndOfMonth",
    "floatingLegFirstDate": "withFloatingLegFirstDate",
    "floatingLegNextToLastDate": "withFloatingLegNextToLastDate",
    "floatingLegDayCount": "withFloatingLegDayCount",
    "floatingLegSpread": "withFloatingLegSpread",
    "discountingTermStructure": "withDiscountingTermStructure",
    "pricingEngine": "withPricingEngine",
    "withIndexedCoupons": "withIndexedCoupons",
    "atParCoupons": "withAtParCoupons",
}

因此很明显,它期望小写的

Nominal
。因此,只需将调用更改为如下所示的
MakeVanillaSwap
即可使其按预期工作。

swap = ql.MakeVanillaSwap(tenor, index, fixedRate, forwardStart, nominal=10e6, pricingEngine=engine)
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.