Options trading is a popular financial strategy that allows traders to manage risks and potentially maximize profits. One such strategy is the condor, which is specifically designed for neutral or range-bound markets. In this article, we will explore the concept of condors, discuss when and why they are used, and provide a step-by-step guide on how to build condors using stock options in Python. Whether you are a beginner or an experienced trader, understanding and utilizing condors can enhance your trading arsenal and help you navigate various market conditions.
What is a Condor?

A condor is an options trading strategy that involves combining multiple options contracts to create a range-bound position. It is designed to profit from low volatility in the underlying asset's price. This strategy is best suited for situations where you expect the price of the underlying asset to remain within a certain range over a specific period. By constructing a condor, traders can potentially achieve a limited-risk, limited-reward position.
When should we use a Condor strategy?
Condors are most effective when the underlying asset is expected to exhibit low volatility. This means that the price of the asset is likely to remain relatively stable within a specified range. Traders employ condors when they anticipate a period of consolidation or lack of significant price movement in the market.
Building Condors with Stock Options in Python

Now, let's explore how to build condors using stock options in Python. We will demonstrate the step-by-step process.
Step 1: Importing Required Libraries
To begin, we need to import the necessary libraries. In this case, we will use the "yfinance" library for fetching stock data and option chains.
import yfinance as yf
import mathStep 2: Retrieving Option Chain Data
Next, we retrieve the option chain data for the desired stock. In this example, we will use "XOM" as the stock symbol.
stock = yf.Ticker("XOM")
expiration = stock.options[0]
opt = stock.option_chain(expiration)Step 3: Filtering the Option Chain
Once we have the option chain, we need to filter it to extract only the calls to build the condor (Condors can be also built with puts or calls/puts combinations).
options = opt.calls
for idx_left_body, left_body in options.iterrows():
left_wings = options[options['strike'] < left_body['strike']]Step 4: Iterating through Left Wings
In this step, we iterate through the left wings of the option chain, which are the options with strikes lower than the left body's strike.
for idx_left, left in left_wings.iterrows():
right_bodies = options[options['strike'] > left_body['strike']]Step 5: Iterating through Right Bodies
Next, we iterate through the right bodies of the option chain, which are the options with strikes higher than the left body's strike.
for idx_right_body, right_body in right_bodies.iterrows():
right_wings = options[options['strike'] > right_body['strike']]Step 6: Iterating through Right Wings
In this step, we iterate through the right wings of the option chain, which are the options with strikes higher than the right body's strike.
for idx_right, right in right_wings.iterrows():
left_count = round(right['strike'] - right_body['strike'], 2) * 1000
right_count = round(left_body['strike'] - left['strike'], 2) * 1000Step 7: Implementing Condor Conditions
To filter out condors with less than 10 contracts, we can apply a condition and print the details of the eligible condor trades.
if (left_count == int(left_count) and right_count == int(right_count)):
gcd = math.gcd(int(left_count), int(right_count))
left_count /= gcd
right_count /= gcd
if left_count <= 10 and right_count <= 10:
print("Buy %d Contract (Strike %.2f) - Sell %d Contract (Strike %.2f) - Sell %d Contract (Strike %.2f) - Buy %d Contract (Strike %.2f)" %
(left_count, left['strike'], left_count, left_body['strike'], right_count, right_body['strike'], right_count, right['strike']))To summarize, let puts all the code together.
import yfinance as yf
import math
stock = yf.Ticker("XOM")
expiration = stock.options[0]
opt = stock.option_chain(expiration)
options = opt.calls
for idx_left_body, left_body in options.iterrows():
left_wings = options[options['strike'] < left_body['strike']]
for idx_left, left in left_wings.iterrows():
right_bodies = options[options['strike'] > left_body['strike']]
for idx_right_body, right_body in right_bodies.iterrows():
right_wings = options[options['strike'] > right_body['strike']]
for idx_right, right in right_wings.iterrows():
left_count = round(right['strike'] - right_body['strike'], 2) * 1000
right_count = round(left_body['strike'] - left['strike'], 2) * 1000
if (left_count == int(left_count) and right_count == int(right_count)):
gcd = math.gcd(int(left_count), int(right_count))
left_count /= gcd
right_count /= gcd
if left_count <= 10 and right_count <= 10:
print("Buy %d Contract (Strike %.2f) - Sell %d Contract (Strike %.2f) - Sell %d Contract (Strike %.2f) - Buy %d Contract (Strike %.2f)" %
(left_count, left['strike'], left_count, left_body['strike'], right_count, right_body['strike'], right_count, right['strike']))Conclusion
In this article, we have explored the concept of condors and their application in options trading. We have provided a detailed guide on how to build condors using stock options in Python. By following the step-by-step process outlined above, traders can construct condors to take advantage of range-bound markets and potentially enhance their trading strategies.
If you enjoy my work, please support me on Medium by becoming a member through my referral link, and consider giving it a clap as a small gesture of motivation. Thank you!
Twitter / X: https://twitter.com/diegodegese LinkedIn: https://www.linkedin.com/in/ddegese Github: https://github.com/crapher
Disclaimer: Investing in the stock market involves risk and may not be suitable for all investors. The information provided in this article is for educational purposes only and should not be construed as investment advice or a recommendation to buy or sell any particular security. Always do your own research and consult with a licensed financial advisor before making any investment decisions. Past performance is not indicative of future results.
A Message from InsiderFinance

Thanks for being a part of our community! Before you go:
- 👏 Clap for the story and follow the author 👉
- 📰 View more content in the InsiderFinance Wire
- 📚 Take our FREE Masterclass
- 📈 Discover Powerful Trading Tools