|
From: Jonathan S. <sw...@gm...> - 2021-11-27 13:15:52
|
Hi Peng, The usual way to back out implied vols from option prices is to use a solver. Since you are using python, scipy.optimize.brentq[1] would be a good choice. I've created a gist[2] on github that shows how to extend the example code from the link you provided to calculate implied vols as well. When I run it on my computer I get the following result, which matches the hardcoded number from the blog. $ python3 iv.py european npv: 6.749271812460607 american npv: 6.837765216321175 european iv: 0.20000000000000023 american iv: 0.19999999999999965 Note that you should be careful about how you deal with implied vols for American options, or any other style of option that is not European. This is because most people will assume you are talking about Black-Scholes implied vols, which requires the option to be European. Plus, in practice you will not want to price American options with flat rates, dividends, or vols, as it is a path-dependent instrument. Nevertheless for the stylized example from the blog the approach I've mentioned here should give you what you want. [1] https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.brentq.html [2] https://gist.github.com/sweemer/7a0270655dc70d224d080b04fe11423e On Sat, Nov 27, 2021 at 2:05 PM Peng Yu <pen...@gm...> wrote: > Hi, > > I see the following example to compute prices for American Options. > > > http://gouthamanbalaraman.com/blog/american-option-pricing-quantlib-python.html > > But it is not clear how to do the reverse. How to compute IV from > bid/ask prices of American options? > > Could anybody show me a complete example of how to do so with quantlib? > Thanks. > > -- > Regards, > Peng > > > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |