0

使用二项式定价引擎和 Cox-Rubinstein 模型为普通的美式期权定价。尝试检索 vega 时,我收到主题错误:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/opt/conda/lib/python3.6/site-packages/QuantLib.py", line 10506, in vega
    return _QuantLib.VanillaOption_vega(self)
RuntimeError: vega not provided

尽管这vega是一种方法american_option

>>> dir(american_option)  # scroll to the right -->
['NPV', '__class__', '__del__', '__delattr__', '__deref__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__nonzero__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__swig_destroy__', '__weakref__', 'asObservable', 'delta', 'dividendRho', 'errorEstimate', 'freeze', 'gamma', 'impliedVolatility', 'isExpired', 'priceCurve', 'recalculate', 'rho', 'setPricingEngine', 'strikeSensitivity', 'theta', 'thetaPerDay', 'this', 'thisown', 'unfreeze', 'vega']

这是基于几个在线示例的代码:

>>> from QuantLib import *
>>> maturity_date = Date(15, 1, 2016)
>>> spot_price = 127.62
>>> strike_price = 130
>>> volatility = 0.20 # the historical vols for a year
>>> dividend_rate =  0.0163
>>> option_type = Option.Call
>>> risk_free_rate = 0.001
>>> day_count = Actual365Fixed()
>>> calendar = UnitedStates()
>>> calculation_date = Date(8, 5, 2015)
>>> Settings.instance().evaluationDate = calculation_date
>>> payoff = PlainVanillaPayoff(option_type, strike_price)
>>> settlement = calculation_date
>>> am_exercise = AmericanExercise(settlement, maturity_date)
>>> american_option = VanillaOption(payoff, am_exercise)
>>> spot_handle = QuoteHandle(
...             SimpleQuote(spot_price)
...         )
>>> flat_ts = YieldTermStructureHandle(
...     FlatForward(calculation_date,
...                 risk_free_rate,
...                 day_count)
... )
>>> dividend_yield = YieldTermStructureHandle(
...     FlatForward(calculation_date,
...                 dividend_rate,
...                 day_count)
... )
>>> flat_vol_ts = BlackVolTermStructureHandle(
...     BlackConstantVol(calculation_date,
...                      calendar,
...                      volatility,
...                      day_count)
... )
>>> bsm_process = BlackScholesMertonProcess(spot_handle,
...                                         dividend_yield,
...                                         flat_ts,
...                                         flat_vol_ts)
>>> 
>>> 
>>> binomial_engine = BinomialVanillaEngine(bsm_process, "crr", 100)
>>> american_option.setPricingEngine(binomial_engine)
>>> print(american_option.vega())

版本:

>>> import QuantLib
>>> print(QuantLib.__version__)
1.11

Python 3.6.3 |Anaconda, Inc.| (default, Oct 13 2017, 12:02:49)

问题是为什么没有提供vega?是什么导致了错误?

4

1 回答 1

1

The VanillaOption class declares the vega method, but the latter can only return a result if the chosen engine calculates it.

In general, engines that use an analytic formula are able to return Greeks cheaply, because they also have an analytic expression; an engine based on a binomial tree, like the one you're using, doesn't have a simple way to calculate the vega. In order to provide it, it should perform an expensive operation (that is, recalculate with a perturbed volatility and get the vega numerically) and therefore it bails out and leaves it to you to perform the expensive calculation explicitly.

In this case, you can calculate the vega by increasing the volatility, calculating a new option price, and calculate the derivative numerically.

I elaborate more on this and provide a few basic examples in this video.

于 2018-01-31T16:14:12.100 回答