I am trying to write a Python function that performs some calculations using a list of Quantlib options, and I would like to pass only that list without other information. In particular, the strike of each option is embedded there somewhere, but I am finding it hard to extract. Here is a toy example of an instance (extracted from one of Luigi Ballabio's excellent tutorial notebooks):

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)
exercise = EuropeanExercise(maturity_date)
european_option = VanillaOption(payoff, exercise)

Now I would like to use something like european_option.strike. That doesn't work, of course. Can someone offer a simple solution? (TIA.)


2 Answers 2


Very old question now, but here it is for reference in case someone stumbles upon it: the object returned by european_option.payoff() has type ql.Payoff (i.e., the base class for payoffs) and doesn't have the strike method. Now, Python doesn't do casts like C++, but for some objects we export functions that perform the underlying C++ cast and return the object with the correct derived type. This is one such case, and one can write:


to downcast the payoff and then retrieve the strike.


You can retrieve the strike from the PlainVanillaPayoff object which is payoff in your example.

payoff.strike() returns 130.0 for me.

  • $\begingroup$ Thanks, but option.payoff.strike() does not work. I want to submit option as an argument to a function, and extract the strike from option inside the function. I do not want to submit additional arguments (like payoff). $\endgroup$
    – Drew
    May 16, 2020 at 23:55
  • $\begingroup$ There is no option.payoff.strike(). Your variable is named payoff. You named it as such. You could rename it to option and then option.strike() would work. Sorry if I am misunderstanding your problem. Good luck. $\endgroup$
    – amdopt
    May 17, 2020 at 0:37
  • $\begingroup$ Sorry: I should have said european_option.payoff.strike() does not work. I would like my function to derive the strike from european_option. $\endgroup$
    – Drew
    May 17, 2020 at 0:47

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.