QuantLib Python中以现金结算的互换期权定价

QuantLib Python中以现金结算的互换期权定价,python,quantlib,quantlib-swig,Python,Quantlib,Quantlib Swig,我正在尝试使用swigged python版本在QuantLib中为现金结算掉期期权定价,代码如下: import QuantLib as ql # QL session today = ql.Date(2, ql.January, 2019) ql.Settings.instance().evaluationDate = today # Underlying swap definition curve = ql.YieldTermStructureHandle(ql.FlatForward(t

我正在尝试使用swigged python版本在
QuantLib
中为现金结算掉期期权定价,代码如下:

import QuantLib as ql
# QL session
today = ql.Date(2, ql.January, 2019)
ql.Settings.instance().evaluationDate = today
# Underlying swap definition
curve = ql.YieldTermStructureHandle(ql.FlatForward(today, 0.03, ql.Actual365Fixed()))
libor_3m = ql.USDLibor(ql.Period('3M'), curve)
calendar = ql.UnitedStates()
effective = calendar.advance(today, 1, ql.Years)
maturity = calendar.advance(effective, 4, ql.Years)
fixed_schedule = ql.Schedule(effective, maturity, ql.Period('6M'), calendar,
                             ql.ModifiedFollowing, ql.ModifiedFollowing,
                             ql.DateGeneration.Forward, False)
float_schedule = ql.Schedule (effective, maturity, ql.Period('3M'), calendar,
                              ql.ModifiedFollowing, ql.ModifiedFollowing,
                              ql.DateGeneration.Forward, False)
notional = 1e6
swap = ql.VanillaSwap(ql.VanillaSwap.Payer, notional, fixed_schedule, 0.03,
                      ql.Actual365Fixed(), float_schedule, libor_3m, 0.,
                      ql.Actual360())
# Swaption definition
swaption = ql.Swaption(swap, ql.EuropeanExercise(effective), ql.Settlement.Cash)
engine = ql.BlackSwaptionEngine(curve, ql.QuoteHandle(ql.SimpleQuote(0.1)))
swaption.setPricingEngine(engine)
swaption.NPV()
在以现金结算的情况下,代码在
结算::checkTypeAndMethodConsistency
上失败,引发异常:

"invalid settlement method for cash settlement"
如果在swoption实例化中将
ql.consolution.Cash
替换为
ql.consolution.Physical
,同样的代码也可以正常工作

有没有办法从Python设置结算方法?我看到Python中只有两个构造函数可用,没有一个采用
settlementMethod
参数:

Possible C/C++ prototypes are:
   SwaptionPtr::SwaptionPtr(VanillaSwapPtr const &,boost::shared_ptr<Exercise > const &,Settlement::Type)
   SwaptionPtr::SwaptionPtr(VanillaSwapPtr const &,boost::shared_ptr<Exercise > const &)
可能的C/C++原型包括:
SwaptionPtr::SwaptionPtr(VanillaSwaptr常量和,boost::共享常量和,结算::类型)
SwaptionPtr::SwaptionPtr(VanillaSwaptr常量&,boost::Sharedptr常量&)

SWIG界面尚未更新,以反映基础库中的更改(您可能希望为此打开一个问题)


同时,使用QuantLib 1.13应该可以工作。

你好,Luigi,谢谢你的及时回答!我打开了以下问题:(你答案中的链接指向QuantLib而不是QuantLib SWIG,我认为这是一个拼写错误)。是的,这是一个拼写错误。谢谢