QuantLib 中的现金结算掉期期权定价-Python

Cash-settled swaptions pricing in QuantLib-Python

我正在尝试使用 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()

在现金结算的情况下,代码在 Settlement::checkTypeAndMethodConsistency 上失败,抛出异常:

"invalid settlement method for cash settlement"

如果在 swaption 实例化中将 ql.Settlement.Cash 替换为 ql.Settlement.Physical,则相同的代码可以正常工作。

有没有办法从Python设置结算方式?我看到 Python 和 none 中只有两个构造函数可以使用 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 &)

SWIG 接口尚未更新以反映基础库中的更改(您可能想为此在 https://github.com/lballabio/QuantLib-SWIG/issues 上打开一个问题)。

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