Modeling a bear spread using Python

A bear spread is formed by buying a put option at strike price K1, and selling a put option at K2 where K2 > K1. The python example forms a bear spread and computes the payoff for upward and downward price movements.

Options Updated 22 Mar 2019 1 min read

Overview

  • The players of the options market employ a bear spread when they consider the market is going to be bearish in the short run.

  • Forming of a bear spread involves the following transactions:

    1. Buying of a European put option with one strike price (K1)
    2. Selling of a European put option with the strike price (K2) less than the strike price of transaction 1.
  • When the stock price moves less than K1 there is a limited profit.

  • When the stock price is between K1 and K2, there is a limited profit.

  • If the stock price moves to K2 or above K2, the profit is zero. There is no loss as well.

Example: Modeling of a Bear Spread using Python

python
# Python example that models a bear option spread

stockPrice  = 70;

K1          = 80;

K2          = 90;

# Stock price goes upwards

i = 0

while i < 5:

    stockPrice  = stockPrice + 5

    payoff      = 0

    if (stockPrice > K1 and stockPrice < K2):

        payoff      = K2-stockPrice;

    elif (stockPrice <= K1):

        payoff      = K2-K1;

    elif (stockPrice >= K2):

        payoff  = 0;

    else:

        payoff  = 0;

    print("Stock price:%2.2f"%stockPrice);

    print("Payoff from bull spread:%2.2f"%payoff);

    print("-")

    i = i + 1;

stockPrice = 70;

# Stock price goes downwards

while i >= 0:

    stockPrice  = stockPrice - 5;

    payoff      = 0

    if (stockPrice > K1 and stockPrice < K2):

        payoff      = K2-stockPrice;

    elif (stockPrice <= K1):

        payoff      = K2-K1;

    elif (stockPrice >= K2):

        payoff  = 0;

    else:

        payoff  = 0;

    print("Stock price:%2.2f"%stockPrice);

    print("Payoff from bull spread:%2.2f"%payoff);

    print("-")

    i = i -1;

Output

Output
Stock price:75.00

Payoff from bull spread:10.00

-

Stock price:80.00

Payoff from bull spread:10.00

-

Stock price:85.00

Payoff from bull spread:5.00

-

Stock price:90.00

Payoff from bull spread:0.00

-

Stock price:95.00

Payoff from bull spread:0.00

-

Stock price:65.00

Payoff from bull spread:10.00

-

Stock price:60.00

Payoff from bull spread:10.00

-

Stock price:55.00

Payoff from bull spread:10.00

-

Stock price:50.00

Payoff from bull spread:10.00

-

Stock price:45.00

Payoff from bull spread:10.00

-

Stock price:40.00

Payoff from bull spread:10.00

-