Juypter Notebook (HTML format) to Calculate Theoretical SPX Option Prices


An iPython Juypter Notebook (in HTML format) used to calculate options prices from a time series of  S&P 500 historic end of day cash prices


I have to thank these guys for the idea: Financial_Hacker

I recommend you do not buy this product unless:

  • You are familiar with Python and it’s most important dependencies; and
  • You have downloaded and inspected SPX2017Opt.csv which is sample output from the code for calendar year 2017.

For each trading day (as drafted), up to 24 expiries are listed.

Cut this right down if you want to look at shorter term options only.

For each expiry on each day I calculate a different volatility for use in the Black Scholes formula later on. If the days to expiry is 5 I have used 5 days for the standard deviation calculation, if 252 days until expiry then historic volatility is calculated for 252 days.

In other words differing periods of “historic” volatility are used to calculate price. It does not make sense (to me at least) to use 20 day volatility to estimate future volatility over the next 700 days. This still takes no account of the fact that implied volatility is often higher than historic and therefore the option prices calculated here are likely to be too low. I may attempt to estimate the premium of implied volatility over historic in a later draft which will form a separate product.

Note also that no account is taken of the usual “volatility smile” prevalent in the US equity markets post 1987. In other words I have assumed the same volatility for all strikes. In practice, OTM and ITM strikes tend to have a higher implied volatility hence higher prices than shown here. Possibly because of the realisation after Black Monday 1987 that fat tails need to be priced in.

Again I am currently proposing to estimate the volatility smile in a later draft which will form a separate product.

This draft is “cheap” because of these limitations. It may or may not be of use to you. You may query or spot errors in my work! If so please point them out.

This product MAY be of use to someone who wants a good base to work from. It represents a great deal of effort on my part and no doubt I will spend a great deal of effort in later products which attempt to more closely estimate implied volatility and the volatility smile.

The product is sold as is with no support and no guarantees of accuracy or worth!

Caveat Emptor.

#QuantLib-Python 1.11
#numpy 1.11.3
#pandas 0.18.1
#Python 3.5.2


There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.