Backtesting is a very important part of the trading strategy creation cycle and one must spend an adequate amount of time testing their strategy and understanding the test results, as this builds confidence in one’s own system.
Streak has recently added expired contracts data to its arsenal. Previously, users could only test their Futures and Options strategies on active contract data(live contracts). But with this new addition, users can now test their strategies on historical expires. In this article, I am going to discuss how to test a strategy on historical/expired contract data using Streak.
Strategy Idea
I would be testing a well-known strategy used by many day traders- intraday Short Strangle on Nifty, which I would be entering at 9:30 AM and exiting the position at 3:15 PM.
What is a Short Strangle?
A Short Strangle involves taking a short position on an out-of-the-money(OTM) Call and Put. This is a delta-neutral strategy that is primarily used to take advantage of theta decay and also the decrease in implied volatility(IV). Basically, it means I am not betting on the direction but I am predicting that there would less volatile movement and thus trying to capture theta decay.
Strike Selection: I would be using the Dynamic Contract feature to select 5 strike up Call and 5 strikes down Put. So, if Nifty is at 15115, the ATM strike would be 15100 and I would be shorting 15350 CE and 14850 PE, giving us a 500 points range. The payoff graph of a short strangle looks like an inverted V with a plateau on top.
Essentially, I am betting that Nifty would move in-between this 500 point range. This range is sufficient for the majority of the days. But when the underlying, here Nifty, moves too quickly or when Nifty is too bullish and goes near the strikes, I would incur a loss on the legs. If Nifty moves in one direction I would incur a loss on the one leg, but I also might incur a loss on both the legs when Nifty would move like:
This is why I would keep an SL of 35% to reduce the amount of drawdown on such occasions. The chances of this SL getting hit is medium too low depending upon the volatility of the underlying. You need to backtest and can set your own stop loss as per your risk profile.
Strategy Condition
I will first select the scrip, here Nifty 50, and set the Dynamic contract as discussed above.
Note: You cannot search for historical contracts individually in the scrip field, you need to use Dynamic Contract for accessing the historical data.
Here is the strategy condition
The Stop Loss has been kept as discussed and the target has been kept as 100% since this is a short strategy, you can only gain a maximum of 100% from your selling price(Entry).
Also, I have set the “Day strategy cycle” as 1, which would ensure that we are entering only once in a day.
A Strategy cycle is basically and one full trade, meaning one entry followed by an exit. “Day strategy cycle” allows users to set the number of strategy cycles during a backtest for an MIS strategy. This is available under the Advanced section of the Create strategy page.
Backtest Result
Now let’s check the backtest result and see how this strategy would have performed.
On opening the backtest transaction details, I can also check the contract that was traded on. Here as you can see, the entry was taken on 11000 PE, 1st October Expiry at the close of 9:25 AM candle i.e 9:30 AM and exit at 3:15 PM.
As you can see the intraday strangle strategy has been profitable consistently 1st July 2020 to 27th December 2020. Even though this is a non-directional, theta eating strategy, it made a profit during trending periods as well.
I will backtest some more on Q3 2020 and Q1 2021 and then deploy it for paper trade. You can also start backtesting your option strategies on Historical data now, whether it is a price-action based strategy or an indicator.
Important
After reading this article, one of my colleagues had a concern as to what would happen if Nifty moves in one direction, and after addressing his concern, I thought I would update this article with the important points of the discussion.
Suppose Nifty moves in one single direction(assuming downside), the stop loss for the Put would get triggered and it would exit. But the Call option position will remain open. Now only three things can happen after this. Nifty will either
- Move further down (1)
- Consolidate at the current level (2)
- Bounce back (3)
And there is a 33.33% probability of either of the event taking place. So this is how the strategy will handle each of the situations
Nifty moves down (1) | Call side premium will keep decreasing reducing the loss from the Put side and eventually giving a profit |
Nifty consolidates (2) | Call side premium will keep decrease because of theta decay, reducing the loss from the Put side and eventually may give a profit |
Nifty bounces back (3) | The profit from the Call side will decrease and may hit Call side SL as well |
So there a 33.33% probability of this strategy incurring a loss, only if event (3) takes place, but a 66.66% probability of the strategy achieving breakeven to profit, which gives it an edge.
Disadvantage
This strategy has gamma risk, which means during a spike in volatility, the premium of the loss-making leg would inflate too quickly but the premium of the profit-making leg would not decrease as quickly showing a sudden net loss before the loss-making option SL getting triggered. The above 3 scenarios are then applicable.
Expired contracts would help you test your strategies on more periods than what was previously possible. This should help you build more robust trading strategies. Hope you liked reading this article. Let me know what you think in the comments below.
Note: Currently you can run backtest on expired contract data starting from 1st March 2020. Also, you cannot backtest on historical Open Interest data and Greek-based strategies at present. This would be available in the future.
If you have any queries about Expired contracts, please write to [email protected].
_________
Disclaimer: The information provided is solely for educational purposes and does not constitute a recommendation to buy, sell, or otherwise deal in investments.
entry time fixing is very complex ,we set entry time 9.25 then result shows 9.45
Hi Kamlesh,
Entry time fixing is very simple when you understand how to do this properly. Entry start-stop time is different from setting an entry time. Here, the Nth candle has been used for setting entry time. I will try to write something about this. Meanwhile, you can write [email protected] in case you have any specific strategies relates issues.
In your Exit condition, did you use close of 72nd candle of 5 min? That is 1:15 pm? For 3:15 om it should be 112, right?
Hi Ananth,
The equity market remains open for 6 Hrs and 15 mins. In an hour, there can be 60/5= 12 5min candles. Similarly, in 6 Hrs there can be 12×6= 72 candles plus the extra 15 mins which totals to 75 5min candles in a day. So how can there be more than 100 candles?
Read: https://tradingqna.com/t/how-to-exit-a-strategy-on-the-basis-of-time/80008
Pingback: Order flow of a strategy deployed using Streak - Streak Tech