Skip to content
All library documents

Moving Dividend Data from QuantLib Options into Pricing Engines

Article Quant Q&A · Author: pyCthon

Summary

This note explains how to adapt QuantLib code after `DividendVanillaOption` was deprecated. The replacement is `VanillaOption`, constructed with the payoff and exercise terms alone; dividend information is supplied to the pricing engine instead. For a European option, the example changes the engine setup to include a dividend vector made from fixed dividends and their dates.

The explanation reflects a modeling distinction: dividends are treated as market data and part of the pricing model, while the option object represents the contract. The guidance is specific to the shown European analytic engine setup and does not explain the deprecation rationale or cover every option type and engine. Users should check the appropriate engine interface for their particular pricing setup.

Key ideas

  • Use `VanillaOption` to represent the contract after `DividendVanillaOption` deprecation.
  • Pass dividend information to the pricing engine rather than the option constructor.
  • Represent dated cash dividends as dividend instances supplied to the engine.
  • The example applies to a European option using an analytic dividend pricing engine.

Tags

Full text
# QuantLib DividendVanillaOption deprecation replacement/alternative


# QuantLib DividendVanillaOption deprecation replacement/alternative












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`

## Answer by Luigi Ballabio (score 4, accepted)

https://quant.stackexchange.com/a/80574

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.)

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.