Option Pay-off: Buyer and Writers

Payout for Option Buyers

# Buyers Payout

import numpy as np
import matplotlib.pyplot as plt

# Function to calculate call option payoff
def call_payoff(sT, strike_price, premium):
    return np.where(sT > strike_price, sT - strike_price, 0) - premium

# Function to calculate put option payoff
def put_payoff(sT, strike_price, premium):
    return np.where(sT < strike_price, strike_price - sT, 0) - premium

# Stock price range at expiration
sT = np.arange(0, 200, 1)

# Option premium and strike price
premium = 5  # Change this value to the premium you want
strike_price = 100  # Change this value to the strike price you want

# Call option payoff
call_option_payoff = call_payoff(sT, strike_price, premium)

# Put option payoff
put_option_payoff = put_payoff(sT, strike_price, premium)

# Plotting the payoff diagrams
plt.figure(figsize=(10, 6))

# Call option payoff plot
plt.subplot(121)
plt.title('Call Option Payoff')
plt.xlabel('Stock Price at Expiration')
plt.ylabel('Profit/Loss')
plt.grid(True)
plt.plot(sT, call_option_payoff, label='Call Option Payoff')
plt.axhline(0, color='black', linestyle='--', linewidth=1)
plt.axvline(strike_price, color='r', linestyle='--', label='Strike Price')
plt.legend()

# Put option payoff plot
plt.subplot(122)
plt.title('Put Option Payoff')
plt.xlabel('Stock Price at Expiration')
plt.ylabel('Profit/Loss')
plt.grid(True)
plt.plot(sT, put_option_payoff, label='Put Option Payoff', color='orange')
plt.axhline(0, color='black', linestyle='--', linewidth=1)
plt.axvline(strike_price, color='r', linestyle='--', label='Strike Price')
plt.legend()

plt.tight_layout()
plt.show() 

Output

Payout for Option Writers

# Writers Payout

import numpy as np
import matplotlib.pyplot as plt

# Function to calculate short call option payoff
def short_call_payoff(sT, strike_price, premium):
    return -call_payoff(sT, strike_price, premium)

# Function to calculate short put option payoff
def short_put_payoff(sT, strike_price, premium):
    return -put_payoff(sT, strike_price, premium)

# Stock price range at expiration
sT = np.arange(0, 200, 1)

# Option premium and strike price
premium = 5  # Change this value to the premium you want
strike_price = 100  # Change this value to the strike price you want

# Short call option payoff
short_call_option_payoff = short_call_payoff(sT, strike_price, premium)

# Short put option payoff
short_put_option_payoff = short_put_payoff(sT, strike_price, premium)

# Plotting the payoff diagrams for short options
plt.figure(figsize=(10, 6))

# Short call option payoff plot
plt.subplot(121)
plt.title('Short Call Option Payoff')
plt.xlabel('Stock Price at Expiration')
plt.ylabel('Profit/Loss')
plt.grid(True)
plt.plot(sT, short_call_option_payoff, label='Short Call Option Payoff', color='green')
plt.axhline(0, color='black', linestyle='--', linewidth=1)
plt.axvline(strike_price, color='r', linestyle='--', label='Strike Price')
plt.legend()

# Short put option payoff plot
plt.subplot(122)
plt.title('Short Put Option Payoff')
plt.xlabel('Stock Price at Expiration')
plt.ylabel('Profit/Loss')
plt.grid(True)
plt.plot(sT, short_put_option_payoff, label='Short Put Option Payoff', color='blue')
plt.axhline(0, color='black', linestyle='--', linewidth=1)
plt.axvline(strike_price, color='r', linestyle='--', label='Strike Price')
plt.legend()

plt.tight_layout()
plt.show()

Output