Black and Scholes pricing and most common option strategies

Hi there,

 

Today we're gonna approach the Black and Scholes (B&S) model and the most common option strategies used on the market (straddle, collar and butterfly) trough Python. Ready ? Let's start then !

 

As you know the B&S model is a standard european option valuation model based on the following hypothesis :

  • no taxes
  • no transactions fees
  • possibility to short the underlying asset
  • constant volatility
  • permanent market for the underlying asset

which allows us to price options on the market trough the use of the two following formulas :

 

Call :

 

Put :

with :

 

N( ) the cumulative distribution function of the standard normal distribution

T - t the time to maturity (expressed in years)

St the spot price of the underlying asset

K the strike price

r the risk free rate

θ the volatility of returns of the underlying asset

q the dividend yield

 

So as you can see with these hypothesis, this model is not the most realistic that you can get. However it is used extensively by traders and investors on the market so it is always good to use it in order to get a first sense of the value of a financial instrument.

 

n.b. (for further explanation on the model or its formulas you can go here).

 

Now, let's open python and start coding this model !

 

Here the strategy that we will use is rather a simple one due to the form of the model. Indeed, we can see that the B&S rely mostly on 4 formulas and distinguish two cases : the Call and the Put. In this sense in order to implement this model with python we just have to create three functions :

  • one function representing the Call
  • one function representing the Put
  • one function calculating the cumulative distribution function of the Standard normal distribution with the help of the error function already implemented in python trough special.erf( ) (see here for formula)

 

And that's it we have our B&S model implemented in python.

 

Now let's see how we can implement the most common option strategies using calls and put in python in order to get a graphical representation of their payoff.

 

In order to do so, first we have to get the payoff of a single put and of a single Call which are mathematically expressed as follows :

 

Call  = Max { 0, (St - S0)}

 

Put = Max{0 , S0 -St}

 

In python, the easiest option, here, is to get our prices into a dataframe and then calculate the difference St - S0 or S0 - St into a second column before applying the get_numeric_data on it in order to transform all the negative values into 0 as shows the code below :

(Here the respective price of the Put and Call is 2)

 

 

Now that we have the payoff for the put and the call we can use them in order to get the one of the three following strategies :

  • Straddle
  • Butterfly
  • Collar

Let's approach first the Straddle.

 

The straddle consists in buying a a put and a call with the same strike, maturity and underlying asset. So to get the payoff of this strategy we just have to use the same methodology as before, aggregate the respective payoffs of the put and the call in the same table and sum them in order to get the payoff of the Straddle strategy.

Let's see now the butterfly strategy. As we know the butterfly strategy consists in :

  • Buy one option of strike K1
  • Sell two options of strike K2
  • buy one option of strike K3

with : K1 < K2 < K3

 

n.b  :  This strategy can be done equally with call options (Call butterfly) or with put option (Put butterfly).

 

So to compute this strategy we only have to use our previous code and adapt it to the butterfly strategy :

Finally, still using the same idea we can easily code the collar strategy which consists in :

  • go long on the underlying asset
  • sell a Call option
  • buy a Put option

 

And that's it ! We successfully implemented the B&S model and plot the payoff of the most common option strategies in python.

 

As always here the full code in which you will also find the code for binary options have fun !

 

Full code :