Diagonal Spreads Options Trading Strategy In Python

Diagonal Spreads Strategy

By Viraj Bhagat

The market progresses rapidly with trades executed in a mere fraction of time. Numerous traders and countless strategies play their part to be a part of this ride. At the end of the day, some stay afloat, while some steer upwards and some stumble or even fall to rise back up the next day.

Trading options play a key role in this, as they provide the trader with the ability to create a variety and a number of strategies, but at the cost of time. The market is replete with many such strategies and it is essential that one spends time getting to learn them and study their technicalities.

While stocks may allow one to trade only bearish or bullish, they often do move sideways but within a particular range. It is in such cases that one enters a Diagonal Spread.

What Are Spreads?

The simultaneous purchase and selling of security are called as a Spread or a Spread Trade or Relative Value Trade and are often executed with futures contracts and options as the legs. Securities besides these are also used sometimes.

Spreads can be constructed with either calls or puts as either debit or credit spreads. Based on the relation of months and legs, the spread constructions are created and distinguished into Vertical Spreads, Horizontal Spreads and Diagonal Spreads.

Options Trading Strategy In Python – Diagonal SpreadsClick To Tweet

What Are Diagonal Spreads?

Diagonal Spread Strategy is:

  • An Options trading strategy
  • A 2-step strategy
  • Combines bits of both Long Call Calendar Spread and Short Call Spread

Comparison Of Vertical Spreads, Horizontal Spreads, and Diagonal Spreads

According to Investopedia, Diagonal Spread makes use of different months and strikes, it moves diagonally, and thus the name.

Spreads Months Strikes Example
Vertical Same Different Bull Call Spread, Bear Put Spread
Horizontal Different Same Calendar Spread
Diagonal Different Different

While it is stated that these were mentioned in the newspapers previously as:[1]

  • Options Prices > Listed in Tabular Manner
  • Strike Prices > Listed in Rows i.e. Vertically
  • Expirations > Listed in Columns i.e. Horizontally

A Diagonal spread would thus mean presence of options in different row and columns with different strike prices and expiration dates.

Difference Between Calendar Spread And Diagonal Spread

The Diagonal Spread has a near-term outlook which could be bearish or bullish.

It is similar to Calendar Spreads in the sense that:

  • Near-term options are sold
  • Long-term options are bought
  • Take advantage of the rapid time decay in soon to expire options

What Is A Diagonal Call Spread?

When the Outlook is slightly bullish > One writes higher strike near-month calls > Against lower strike far-month calls

What Is A Diagonal Put Spread?

When the Outlook is slightly bearish > One writes lower strike near-month puts > Against higher strike far-month puts

When Is A Diagonal Spread Executed?

  • A short-term weakness or Strength that you think would go up (if call) or go down again (if put), then to take advantage of it
  • The strategy is controlled on the short-side for risk and if the market plays smooth, it can become open-ended on the long side
  • When executed for money, it allows margin requirements to be met
  • Short option expires ATM worthless > IV expands > Increases the price of the remaining Long Option> Keep full credit received to Sell the option > Reduces the cost basis of the long option we own
  • Diagonal Spread > short side expires worthless > Money > Buy > Long side of the spread

Change Is The Key!

One must always be aware and be alert of the performance of his/her strategies. If in any case, the spread requires some adjustment, it would have to be taken care of to prevent any loss. One can use it as an advantage after the strategy has been implemented by consistently studying the market and implying the changes in their strategies to gain maximum benefit.

Profit From A Diagonal Spread Trading Strategy

The maximum profit of a Diagonal Spread can be described as follows:

  • Max. Profit = Net credit received* – Premium paid for the call (with strike B)
  • *Net credit is received by selling both calls with strike A)

Loss From A Diagonal Spread Trading Strategy

The maximum loss for a Diagonal Spread can be described as follows:

  • For Net Credit: Max Loss = Strike A – Strike B – Net Credit Recd.
  • For Net Debit: Max Loss = Strike A – Strike B + Net Debit Paid

Setup Of A Diagonal Spread Strategy

If the trade moves fast towards our direction, one could lose money. Thus, when compared to other spreads, the setup of a diagonal spread is very important.

It involves the simultaneous purchase of:

  • An equal number of options
  • Both options should be of the same class
  • Both should have the same underlying security
  • 2 different strike prices
  • 2 different expiration months

A Diagonal Spread for a Call would look like this:

Diagonal Spread diagram

Learn Algorithmic trading from Experienced Market Practitioners

  • This field is for validation purposes and should be left unchanged.

Strategy (In Case Of A ‘Call’)

  • Sell 1 OTM Call – A – Lower Strike Price – Front-month
  • Buy 1 OTM Call – B – Higher Strike Price – Back-month(Long-term)
  • The stock generally will be below strike A

We will explain this strategy with the help of an Example.

Long Call Diagonal Spread

Implementing Long Call Diagonal Spread Trading Strategy

I would be explaining the example using Diagonal Spread with Long Calls and for this, I will use the example of NIFTY (Ticker – NIFTY)

Following is the Option Chain for NIFTY

Diagonal Spread Option Chain

We would now take 2 Call Prices from April 2018 and May 2018

For April 2018:

Call Price Apr. 2018

For May 2018:

Call Price May 2018


# Importing Libraries

# Data manipulation
import numpy as np
import pandas as pd

# To plot
import matplotlib.pyplot as plt
import seaborn

# BS Model
import mibian
# Importing Libraries
# Data manipulation
import numpy as np
import pandas as pd
# To plot
import matplotlib.pyplot as plt
import seaborn
# BS Model
import mibian

# Nifty futures price
nifty_april_fut = 10595.40
nifty_may_fut = 10625.50
april_strike_price = 10700
may_strike_price = 10800
april_call_price = 10
may_call_price = 82
setup_cost = may_call_price - april_call_price
# Today's date is 20 April 2018. Therefore, days to April expiry is 7 days and days to May expiry is 41 days.
days_to_expiry_april_call = 6
days_to_expiry_may_call = 41
# Range of values for Nifty
sT = np.arange(0.97*nifty_april_fut,1.03*nifty_april_fut,1)
#interest rate for input to Black-Scholes model
interest_rate = 0.0

# Front-month IV
april_call_iv = mibian.BS([nifty_april_fut, april_strike_price, interest_rate, days_to_expiry_april_call],
print "Front Month IV %.2f" % april_call_iv,"%"
# Back-month IV
may_call_iv = mibian.BS([nifty_may_fut, may_strike_price, interest_rate, days_to_expiry_may_call],
print "Back Month IV %.2f" % may_call_iv,"%"
Front Month IV 8.53 %
Back Month IV 11.26 %

# Changing days to expiry to a day before the front-month expiry
days_to_expiry_april_call = 0.001
days_to_expiry_may_call = 35 - days_to_expiry_april_call
df = pd.DataFrame()
df['nifty_price'] = sT
df['april_call_price'] = np.nan
df['may_call_price'] = np.nan
# Calculating call price for different possible values of Nifty
for i in range(0,len(df)):
df.loc[i,'april_call_price'] = mibian.BS([df.iloc[i]['nifty_price'], april_strike_price, interest_rate, days_to_expiry_april_call],
# Since, interest rate is considered 0%, 35 is added to the nifty price to get the Nifty December futures price.
df.loc[i,'may_call_price'] = mibian.BS([df.iloc[i]['nifty_price']+35, may_strike_price, interest_rate, days_to_expiry_may_call],
    nifty_price april_call_price may_call_price
0    10277.538        0.0             27.305711
1    10278.538        0.0             27.455138
2    10279.538        0.0             27.605211
3    10280.538        0.0             27.755935
4    10281.538        0.0             27.907309
df['payoff'] = df.may_call_price - df.april_call_price - setup_cost
plt.xlabel("Nifty Price")

Diagonal Spread Payoff Graph

max_profit = max(df['payoff'])
min_profit = min(df['payoff'])
print "%.2f" %max_profit
print "%.2f" %min_profit

Maximum Profit: INR 35.55
Maximum Loss: INR -88.94


Seasoned Veterans and higher are mostly seen practising this strategy since it involves selling 2 options while having some volatility and predictability; yet having a steady stock price. One thus needs to be quite thorough with the market and his options to practise this strategy.

Next Step

Are you keen on learning more about algorithmic trading? Connect with us and get to know different worldviews on financial strategies. QuantInsti® aids people in acquiring skill sets which can be applied across various trading instruments and platforms. The Executive Programme in Algorithmic Trading (EPAT™) course covers training modules like Statistics & Econometrics, Financial Computing & Technology, and Algorithmic & Quantitative Trading. EPAT™ equips you with the required skill sets to be a successful trader.

Disclaimer: All investments and trading in the stock market involve risk. Any decisions to place trades in the financial markets, including trading in stock or options or other financial instruments is a personal decision that should only be made after thorough research, including a personal risk and financial assessment and the engagement of professional assistance to the extent you believe necessary. The trading strategies or related information mentioned in this article is for informational purposes only.

Learn Algorithmic trading from Experienced Market Practitioners

  • This field is for validation purposes and should be left unchanged.

Download Data File

  • Diagonal Spread Options Strategy – Python Code

Login to DOWNLOAD these files for FREE!

Existing Users Log In