0
$\begingroup$

Prior to QuantLib 1.35 you could create the option obj via:

option = ql.DividendVanillaOption(payoff, exercise, div_dates, div_values)

How ever in the latest release, DividendVanillaOption was deprecated and I'm not sure what the correct replacement should be, as the release doesn't state why this was deprecated. What should I replace DividendVanillaOption with?

If you replace DividendVanillaOption with VanillaOption you get the following error:

TypeError: VanillaOption.__init__() takes 3 positional arguments but 5 were given

$\endgroup$
1
  • $\begingroup$ All, @luigi-ballabio I try to use DividendVanillaOption() with 1.22 Quantlib Python package (to calc greeks for div paying stock). If i've correct understanding: 1.22 release already include AnalyticDividendEuropeanEngine engine class, but my IDE can't hint about it's member/arguments (opposite other used ql option pricing objects). pls, clarify me about correct AnalyticDividendEuropeanEngine arguments (under 1.22 release) b/c for payoff=ql.PlainVanillaPayoff(ql.Option.Call,K) engine =ql.AnalyticDividendEuropeanEngine(process) # optio $\endgroup$
    – Flexy Flex
    Commented Oct 14 at 10:14

1 Answer 1

3
$\begingroup$

You can use VanillaOption; however, the dividend information doesn't go into the option but into the engine instead. For instance, in the European case, the old

option = ql.DividendVanillaOption(payoff, exercise, div_dates, div_values)
option.setPricingEngine(
    ql.AnalyticDividendEuropeanEngine(stochProcess)
)

becomes

option = ql.VanillaOption(payoff, exercise)
option.setPricingEngine(
    ql.AnalyticDividendEuropeanEngine(stochProcess, dividends)
)

where dividends is a vector of Dividend instances; you can create it as

dividends = [
    ql.FixedDividend(v, d) for v, d in zip(div_values, div_dates)
]

The idea is that, like the stochastic process used for the underlying, the dividends are part of the model and the current market data, not of the contract specification, so it makes more sense for them to go in the engine (which is where the model and the market data are specified.)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.