Backtesting Short Butterfly Strategy
In this post, we will see how to do options backtesting, i.e., test an options trading strategy’s performance. Before we begin, one should note that options trading is risky and majority of traders lose money. Backtesting an options trading strategy and also trading systematically with appropriate risk management measures will help you trade in an effective manner.
Ingredients
- One option strategy
- One asset option
- One underlying asset
- Some Python libraries
Preparation
First, let us select an options strategy. Of all the names fluttering inside our minds, let us pick the butterfly options strategy. While the strategy can be used on any option, we will select the NIFTY index as the option and NIFTY Futures as the underlying asset.
Short Butterfly strategy
Let’s take a slight detour and understand what the butterfly strategy is. While there are various ways to set up a butterfly strategy, we will pick the short butterfly strategy.
This strategy consists of four legs,
- Buy At the money (ATM) call
- Buy ATM put
- Sell Out of the money (OTM) call
- Sell OTM put
Hold on! Buying and selling ATMs is simple. You just need the current price of the underlying asset.
For example, if the E-mini S&P 500 Index Futures is at 4000, you will buy the option closest to this price, i.e. the index put and call with a strike price of 4000. Let’s assume you paid a total premium of $100 for it.
But how do you decide on the OTM call and put?
In simple terms, you can calculate the total premium you paid for buying the ATM put and call. Here, the premium was $100. So you will sell an OTM call at a strike price of $4100. And an OTM put is sold at $3900.
Great! You have set up a butterfly strategy.
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.
Should you set up the butterfly strategy at any time? And when do you exit?
The idea of backtesting is to create definite entry and exit rules.
You can start with a simple entry rule of setting up a butterfly at the start of the month and let it expire at the expiry date of options.
But that might not give good results. So you can use technical indicators, like ADX, and the implied volatility percentile (IVP).
What is ADX?
The Average Directional Movement Index (ADX) indicator is a technical indicator which determines the strength of a trend. The ADX indicator value is between 0 and 100 and a value greater than 25 is generally interpreted as a strong trend. The higher the value of the ADX indicator, the stronger the trend.
What is the implied volatility percentile (IVP)?
The implied volatility percentile is a measure used in trading options to evaluate the current implied volatility of an underlying asset in relation to its historical implied volatility. It is a metric that compares the current level of implied volatility to its historical range over a certain time period.
The implied volatility percentile is expressed as a percentage, with 0% representing the lowest implied volatility level and 100% representing the highest implied volatility level over the specified time frame. For example, if the implied volatility percentile is 50%, it means that the current implied volatility level is higher than 50% of the levels observed in the past.
Now that you know how ADX and IVP can be interpreted, you can frame the entry rule as-
- ADX < 30
- IVP between 50 and 95.
This is done so that we can enter when the asset is not trending in the past (hence the ADX value is less than 30) but the expected volatility is high, which is given by the IVP value.
Why is IVP only considered till 95 and not 100?
An IVP higher than 95 implies that the market is highly volatile and we cannot be reasonably sure of the direction of the market.
For the time being, you will exit when the take profit is 30% and the stop loss is also at 30%. Otherwise, you will exit at expiry.
Now that we have set up the entry and exit rules, let us use the historical data of Nifty futures and Nifty options and test out the strategy.
Testing the strategy
The performance of this strategy for the period 2019 to June 2022 on NIFTY index options is as shown below. The Python code for this strategy can be found in Section 17, Unit 10 of the paid course Systematic Options Trading on Quantra.
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.
You can see that the cumulative returns of the strategy are shown as the green line. It starts at 1 at the beginning of the time period and ends at 1.29 at the end of the backtesting period. The blue line is the underlying index. The stars marked in red are the times when we have entered the market and set up our short butterfly option strategy.
The cumulative returns are 1.29x. This means that if you had invested 1 unit in January 2019, it would have given you 1.29 by June 2022. 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.
Of course, you can tweak this strategy further by changing the entry and exit rule parameters. Maybe you can backtest the performance if you exit a few days before expiry.
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.
Summary
In this manner, you can test the performance of any options trading strategy, in a systematic manner. If you are interested, you can enrol for the Systematic Options Trading Course on Quantra and learn as well as paper trade/live trade different options trading strategies using Python.
IMPORTANT DISCLAIMER: This email is for educational purposes only and is not a solicitation or recommendation to buy or sell any securities. Investing in financial markets involves risks and you should seek the advice of a licensed financial advisor before making any investment decisions. Your investment decisions are solely your responsibility. The information provided is based on publicly available data and our own analysis, and we do not guarantee its accuracy or completeness. By no means is this communication sent as the licensed equity analysts or financial advisors and it should not be construed as professional advice or a recommendation to buy or sell any securities or any other kind of asset.