|
From: Jonathan S. <sw...@gm...> - 2021-11-27 23:29:28
|
Hi Peng, The spot price should be available on Yahoo Finance, but note that the stock and options market data might have different delays so won't be directly comparable at the same time. For any serious use I recommend getting access to a real-time data feed. According to Yahoo Finance, their options data comes from OPRA[1], so you might be able to find more information on what rates and divs they use to calculate the implied vols shown on Yahoo Finance on an OPRA website. Apart from that, I'm afraid it's beyond the scope of what I'll be able to help you with. [1] https://help.yahoo.com/kb/finance-for-web/SLN2310.html?locale=en_US On Sun, Nov 28, 2021 at 3:08 AM Peng Yu <pen...@gm...> wrote: > Thanks. How to determine dividend_rate in practice? For example, the > dividends for the following stock have been changing. > > https://www.nasdaq.com/market-activity/stocks/sjm/dividend-history > > I see implied vol is computed for each option contract below. What > spot_price, risk_free_rate should be used to reproduce the implied vol > shown on Yahoo Finance? Could you show an example for the following > contract? Thanks. > > https://finance.yahoo.com/quote/SJM/options?p=SJM&date=1642723200 > > Contract Name Last Trade Date Strike Last Price Bid Ask > Change % > Change Volume Open Interest Implied Volatility > SJM220121C00130000 2021-11-24 9:59AM > EST 130.00 5.97 5.00 5.30 0.00 - 1 551 > 23.60% > > On 11/27/21, Jonathan Sweemer <sw...@gm...> wrote: > > 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 > >> > > > > > -- > Regards, > Peng > |