Covered Call Strategy Using Machine Learning

14 min read

A covered call is used by an investor to make some small gain while holding the stock. Mostly the reason why a trader would want to create a covered call is because the trader is bullish on the underlying stock and wants to hold for long-term, but the stock doesn't pay any dividend. The stock is expected to go up over a period of next 6 months, and in the meantime, you would want to use this stock as collateral and sell some call and pocket the premium.

But there is a risk to the strategy, that is, if the stock goes up then your stock would get sold off at expiry. So, instead of waiting for the option to expire, you can buy it back for a lesser premium.

There are many ways to use machine learning for trading and covered call strategy can be also utilised with machine learning. In this blog, we will see how you could use a simple decision tree algorithm to predict a short-term move in the option premium price and pocket the difference (stock price and premium) while holding the stock.

This blog covers:


What is machine learning in finance?

Machine learning in finance refers to the application of algorithms and statistical models by computers to analyse and interpret financial data, make predictions, and automate decision-making processes. This field leverages the vast amounts of data available in financial markets, including stock prices, trading volumes, economic indicators, and customer transaction histories, among others.

Some common applications of machine learning in finance include:

  • Algorithmic Trading: Machine learning algorithms are used to analyse market data and identify patterns that can be exploited for trading purposes. These algorithms can execute trades automatically based on predefined criteria without human intervention.
  • Risk Management: Machine learning models can assess the risk associated with different financial assets and portfolios by analysing historical data and identifying patterns that indicate potential risks. This helps financial institutions optimise their portfolios and manage risk more effectively.
  • Portfolio Management: Machine learning algorithms can analyse market data and historical performance to optimise investment portfolios and maximise returns while minimising risk.
  • Market Sentiment Analysis: Machine learning models can analyse news articles, social media posts, and other sources of unstructured data to gauge market sentiment and predict future market movements.

Overall, machine learning is increasingly being used in finance to automate processes, improve decision-making, and gain insights from large and complex datasets.

Let us now move further to find out the basics of options trading.


Basics of options trading

Options trading is a type of derivative trading where participants, known as options traders, enter contracts that provide them with the right, but not the obligation, to buy (via a call option) or sell (via a put option) a specific underlying asset at a predetermined price (known as the strike price) within a specified period of time (referred to as the expiration date).

Here are the basics of call options:

Components of Options

  • Underlying Asset: The asset (e.g., stock, index) on which the option's value is based.
  • Strike Price: The price at which the underlying asset can be bought (in the case of a call option) or sold (in the case of a put option) upon exercise of the option.
  • Expiration Date: The date by which the option must be exercised, after which it expires worthless if not exercised.
  • Premium: The price paid by the buyer to the seller for the right to buy (call or put option) the underlying asset. It represents the cost of the option.

Profit and Loss for Options

  • Buyer: A call option buyer profits if the price of the underlying asset rises above the strike price plus the premium paid. The maximum loss for the buyer is limited to the premium paid. Whereas, the buyer of the put option profits when the price of underlying goes below the strike price. That way, the put option buyer can exercise the right to sell at a higher price (strike price).
  • Seller (Writer): A call option seller profits if the price of the underlying asset remains below the strike price, as the option expires worthless. However, the seller's losses can be unlimited if the price of the underlying asset rises significantly above the strike price.

Here, a put option seller profits when the price of underlying goes above the strike price. That way the put option seller can pocket the premium. Since the  buyer of the option will not be going ahead with the contract, the option will expire worthlessly.

Factors Affecting Option Prices

The prices of call options and put options are influenced by several factors, including:

  • Underlying Asset Price: The current price of the underlying asset plays a significant role in determining the value of both call and put options. Generally, as the price of the underlying asset increases, the value of call options tends to increase, while the value of put options tends to decrease.
  • Strike Price: The strike price of the option contract is the price at which the underlying asset can be bought (for call options) or sold (for put options). The relationship between the strike price and the current price of the underlying asset affects the option's intrinsic value.
  • Time to Expiration: The time remaining until the option's expiration date impacts its value. Options with longer expiration periods have higher premiums, as they provide more time for the underlying asset to move in a favourable direction.
  • Volatility: Volatility refers to the magnitude of price fluctuations in the underlying asset. Higher volatility increases the likelihood of significant price movements, which tends to increase the value of both call and put options.
  • Interest Rates: Changes in interest rates can influence the cost of financing and impact the value of options. Generally, higher interest rates tend to increase option premiums, particularly for call options.
  • Dividends: For stocks, the timing and amount of dividends paid by the underlying company can affect option prices, especially for call options. Higher dividend payments reduce the value of call options, as they reduce the potential for stock price appreciation.

Understanding call options and put options and their basic mechanics is essential for investors looking to engage in options trading. Let us now gather some knowledge about covered calls.


Understanding covered calls

Covered calls is a strategy used in options trading where an investor holds a long position in an underlying asset (such as stocks) and simultaneously sells call options on the same asset. The call options sold are "covered" because the investor already owns the underlying asset, which can be delivered if the option is exercised.

Here's how it works:

Position: The investor holds a certain number of shares of a particular stock.

Sell Call Options: The investor sells call options on the same stock. Each call option typically represents a number of shares which can vary. In our examples in this blog, we will be assuming them to be 100 shares of the underlying stock. By selling call options, the investor receives a premium from the buyer of the option.

Expiration: The call options have a predetermined expiration date. Until this date, the buyer of the call option has the right to purchase the underlying shares from the investor at the specified strike price.

Outcome Scenarios:

  • If the stock price remains below the strike price of the call options until expiration, the call options expire worthless, and the investor keeps the premium received from selling the options.
  • If the stock price rises above the strike price, the buyer of the call option may exercise their right to purchase the shares at the strike price. In this case, the investor must sell the shares at the strike price, regardless of the current market price. The investor still keeps the premium received from selling the call options, which helps mitigate the loss from selling the shares at a lower price than the market price.

Example:

Let's say an investor owns 100 shares of XYZ Company, currently trading at $50 per share. The investor decides to sell one covered call option contract with a strike price of $55 and an expiration date one month from now. The premium received for selling this call option is $2 per share (total premium of $200).

Scenario 1: If the stock price remains below $55 at expiration, the call option expires worthless. The investor keeps the $200 premium received from selling the call option.

Scenario 2: If the stock price rises above $55 at expiration, let's say to $60 per share. The buyer of the call option exercises their right to buy the shares at $55 per share. The investor sells the shares at $55 per share, realising a profit of $5 per share ($55 - $50), but forgoes potential additional gains beyond the strike price. The investor still keeps the $200 premium received from selling the call option.

Moving forward, we can now dive deeper into the topic and learn about the machine learning in covered calls.


Machine Learning in covered calls

Covered call strategy can use Machine Learning in several ways to enhance decision-making, optimise strategies, and improve outcomes.

Here are some applications of machine learning in covered calls:

Machine learning covered call
  • Predictive Analytics: Machine learning models can analyse historical market data, including stock prices, volatility, and other relevant factors, to predict future price movements. By incorporating these predictions into covered call strategies, investors can make more informed decisions about strike prices and expiration dates.
  • Risk Management: Machine learning algorithms can assess the risk associated with covered call positions by analysing factors such as market volatility, correlation between the stock and the options, and potential downside scenarios. This helps investors adjust their strategies to minimise risk and maximise returns.
  • Portfolio Optimisation: Machine learning algorithms can optimise covered call strategies by identifying the most suitable combinations of stocks, strike prices, and expiration dates to achieve specific investment objectives. These algorithms can consider factors such as risk tolerance, return targets, and market conditions to tailor strategies to individual investor preferences.
  • Market Sentiment Analysis: Machine learning models can analyse news articles, social media posts, and other sources of unstructured data to gauge market sentiment and identify potential opportunities or risks. By incorporating sentiment analysis into covered call strategies, investors can adjust their positions in response to changing market conditions.
  • Dynamic Position Management: Machine learning algorithms can continuously monitor covered call positions and automatically adjust parameters such as strike prices and expiration dates based on real-time market data. This allows investors to adapt to changing market conditions and optimise their strategies over time.

Now that we know about covered calls and applications of machine learning in covered calls, let us move to the implementation of covered call strategy using machine learning.


Implementation of covered call strategy using Machine Learning

Let us now see an example, using the S&P 500. S&P 500 is a U.S. index that tracks the stock performance of 500 of the largest companies listed on stock exchanges in the United States of America.

To execute the strategy, we assume that we are holding the futures contract and then we try to write a call option on the same underlying. To do this, we train a machine learning algorithm on the past data consisting of various greeks, such as IV, delta, gamma, vega, and theta of the option as the input. And the dependent variable or the prediction would be made on the next day’s return. We write the call whenever the algorithm generates a sell signal.

To begin with, let us import the necessary libraries.

Step 1- Import the Libraries

First, let us import the data. I have two datasets, one with the continuous data of the Futures Contract and another with the continuous data of the 4600 strike call option. Here, by continuous we mean “across various expiries”.

Step 2 - Read the Data

The data in the csv file used in this blog is downloaded from the NASDAQ website. Let us print the data sets to visualise them.

Output:

Read data

Step 3 - Preprocess the Data

So, we need to preprocess the data to ensure that it is ready for the Machine learning model.

Output:

['Date', 'Opt_LTP', 'Fut_LTP', 'Time_to_Expiry']

Above, we have dropped the rows with missing values and have extracted features into ‘X’ by dropping specified columns.

Then, we set the target variable y to the 'Signal' column.

Step 4 - Split the data

Now, we will split the data into training and testing datasets. Next, we will use the first 95% of the data as the train data and the last 5% for prediction.

So, we will use the first 116 days data for training the algorithm and the last 7 days ( 1 week) of trading data to predict its performance.

Output:

((116, 5), (7, 5), (116,), (7,))

Step 5 - Fitting the Decision Tree

Next, we instantiate a sample decision tree and fit the train data to make predictions on the test data. We will evaluate the performance of the strategy by calculating the returns (in terms of call premium) of the strategy and then adding every day’s return for the data in the test dataset.

We will also print the accuracy and profit of the strategy.

Output:

X_train shape: (116, 5)
y_train shape: (116,)
Accuracy: 0.42857142857142855
Profit: 0.09999999999999999
Cumulative returns of covered call strategy

Depending on the random state of the algorithm, the profit results might vary, but the accuracy would be close to the value above. The graph plotted above represents the cumulative returns generated by the covered call strategy over time based on the signals predicted by the decision tree classifier.

It is important to note that backtesting results do not guarantee future performance. The presented strategy results are intended solely for educational purposes and should not be interpreted as investment advice. A comprehensive evaluation of the strategy across multiple parameters is necessary to assess its effectiveness.

Let us see one real world example of the successful covered call strategy ahead.


Real-world example of covered call strategy

Warren Buffett's Strategy

While not exclusively focused on covered calls, Warren Buffett's investment philosophy often involves selling put options, which is similar to covered call strategies. ⁽¹⁾

In 2008, Buffett famously entered into a covered call strategy on his holdings in Coca-Cola. By selling call options against his Coca-Cola shares, Buffett generated additional income while still maintaining his long-term investment in the company.

Going forward, there are some risks and considerations that we will see which will help you be prepared during your journey with covered call strategy in trading using machine learning models.


Risks & considerations with covered call strategy using machine learning

Below are some risks and considerations below that a trader should be aware of.

  • Model Risk: Machine learning models are subject to inherent limitations and uncertainties, leading to potential inaccuracies or biases in predictions.
  • Data Quality: The quality and reliability of input data can significantly impact the performance of machine learning models. Inaccurate or incomplete data may lead to flawed predictions and decision-making.
  • Overfitting: Machine learning models may be prone to overfitting, where the model learns noise in the training data rather than underlying patterns, resulting in poor generalisation to new data.
  • Regulatory Compliance: Compliance with regulatory requirements, such as data privacy laws (e.g., GDPR) and financial regulations (e.g., SEC rules), is essential when deploying machine learning models in finance.
  • Ethical Considerations: Machine learning algorithms may inadvertently perpetuate biases present in the data, leading to ethical concerns, such as discrimination or unfair treatment of certain groups.

Besides risks, there are considerable benefits that can help you with understanding the covered call strategy with machine learning.


Benefits & potentials with covered call strategy using machine learning

There are several benefits also which are as follows:

  • Improved Decision-Making: Machine learning enables more accurate and data-driven decision-making processes, leading to better investment strategies, risk management, and operational efficiency.
  • Enhanced Predictive Capabilities: Machine learning algorithms can analyse vast amounts of financial data to identify complex patterns and trends, providing insights into market behaviour and investment opportunities.
  • Automation: Machine learning enables automation of repetitive tasks, such as data analysis, portfolio management, and trade execution, leading to cost savings and increased productivity.
  • Risk Management: Machine learning models can assess and mitigate risks more effectively by identifying potential threats and vulnerabilities in financial markets, portfolios, and trading strategies.
  • Innovation: Machine learning fosters innovation in financial services, enabling the development of new products, services, and business models that cater to evolving customer needs and market demands.

Let us see the regulatory landscape around machine learning concerning finance for knowing and taking care of the legal framework.


Regulatory landscape surrounding Machine learning in finance

The regulatory landscape surrounding Machine Learning in finance is as follows: ⁽²⁾

  • Data Privacy: Financial institutions must comply with data privacy regulations, such as GDPR in the European Union and CCPA in California, to ensure the lawful processing and protection of personal data used in machine learning applications.
  • Model Validation: Regulators require financial institutions to validate and test machine learning models rigorously to ensure their accuracy, reliability, and compliance with regulatory standards.
  • Transparency & Explainability: There is growing regulatory scrutiny on the transparency and explainability of machine learning models, particularly in high-stakes applications such as credit scoring and algorithmic trading.
  • Fair Lending & Discrimination: Regulators are increasingly focusing on addressing potential biases and discrimination in machine learning algorithms used for lending and underwriting decisions to ensure fair treatment of consumers.
  • Cybersecurity: Regulators emphasise the importance of robust cybersecurity measures to protect sensitive financial data and systems from cyber threats and breaches associated with machine learning applications.

Now, we will find out answers to frequently asked questions so that you can be more clear regarding the covered call strategy using Machine Learning.


The following are some of the frequently asked questions regarding covered call strategy using machine learning:

Q: How does machine learning improve the effectiveness of covered call strategies?
A: Machine learning improves the effectiveness of covered call strategies by analysing vast amounts of historical market data and identifying complex patterns and trends that may not be apparent through traditional analysis methods. By leveraging advanced algorithms, machine learning models can:

  • Predict future stock price movements more accurately, enabling better selection of strike prices and expiration dates for call options.
  • Identify optimal entry and exit points for covered call positions based on real-time market conditions and risk factors.
  • Incorporate additional data sources, such as news sentiment analysis and economic indicators, to enhance decision-making and risk management.
  • Adaptively adjust strategy parameters in response to changing market dynamics, improving adaptability and performance over time.

Q: What are the key algorithms used in machine learning for covered call strategy?
A: Let us now find out the key algorithms used in machine learning for the covered call strategy:

  • Regression algorithms: Used for predicting future stock prices or option prices based on historical data.
  • Decision trees and ensemble methods (e.g., Random Forest, Gradient Boosting): Employed for classification tasks, such as predicting whether to buy or sell call options based on input features.
  • Neural networks: Deep learning models capable of capturing complex relationships in data, often used for advanced predictive analytics in finance.
  • Reinforcement learning: Applied to optimise trading strategies by learning from past experiences and rewards.

Q: Can machine learning adapt to changing market conditions in covered call trading?
A: Yes, machine learning can adapt to changing market conditions in covered call trading. Machine learning models are trained on historical data but can continuously learn and evolve over time as new data becomes available. By monitoring real-time market data and adjusting model parameters accordingly, machine learning algorithms can adapt to shifting market dynamics, volatility levels, and other factors affecting covered call strategies. This adaptability allows machine learning-enhanced covered call strategies to remain effective and competitive in dynamic market environments.

Q: How does the performance of machine learning-enhanced covered call strategies compare to traditional methods?
A: The performance of machine learning-enhanced covered call strategies might outperform traditional methods in several ways:

  • Enhanced risk management: Machine learning algorithms can identify and mitigate risks more effectively by analysing vast amounts of data and incorporating additional factors into decision-making processes.
  • Increased efficiency: Machine learning automation streamlines the process of strategy development, optimization, and execution, leading to higher efficiency and productivity compared to manual methods.
  • Adaptability: Machine learning models can adapt to changing market conditions and evolving investor preferences, allowing covered call strategies to remain competitive and resilient over time.

Conclusion

In the realm of covered call strategies, machine learning revolutionises trading by leveraging vast datasets to predict future price movements and optimise trades. Advanced algorithms enhance decision-making, adapt to market dynamics, and outperform traditional methods. By integrating machine learning, investors gain predictive insights, improve risk management, fostering innovation and efficiency in finance. Explore the power of machine learning in covered call strategies for maximum returns and informed decision-making.

If you wish to learn more about machine learning for options trading, you can explore the course on Machine Learning for Options Trading. With this course, you can unlock the power of machine learning to take your options trading to the next level and learn everything from model selection to forecasting options prices. Learn how to apply cutting-edge machine learning techniques to trade options strategies and analyse the performance. Enroll now!


File in the download

  • Covered call strategy using Machine learning - Python notebook

Author: Chainika Thakar (Originally written by Varun Divakar)


Note: The original post has been revamped on 15th April 2024 for recentness, and accuracy.

Disclaimer: All investments and trading in the stock market involve risk. Any decision 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.

 Advanced Momentum Trading: Machine Learning Strategies Course