Contents

Black-Scholes model


The Black-Scholes model aims to calculate the fair or theoretical price of a European call/put option, meaning that the option cannot be exercised before the expiration date. Below, I explore how to use Python to get options data from Yahoo Finance into Python and apply the Black-Scholes model.

Getting market data for Cloudflare options (you can specify either calls or puts):

Stacking graphs horizontally

Now we can use the Black-Sholes model: here is the formula and its inputs:

Stacking graphs horizontally

Here is the code that I made; it requires the stock ticker, expiry date and contract name of some option.

It works by finding the column number of the contract number (in order to find all of its relevant data), finding the stock price of the ticker and by using the US-10 year yield as the risk free rate of return.

Afterwards, we plug in the calculations into the formula and we can also configure the type of option (call or put), but for this example we are just using calls.

Here is an example of me inputting a specific Cloudflare(NET) call contract and the Black-Scholes theoretical fair price as output:

Stacking graphs horizontally
Stacking graphs horizontally