How to test 0 DTE iron condors on SPY

Back

Suppose I want to run a test over a (say) one year period for the following strategy:

If "today" is Mon or Wed or Frid and the time is "30 minutes after market open" (eg 10AM EST), then sell an iron condor on SPY where the options expire at the end of today, and where the short options have between 12-16 delta. and the long options are 3 point farther out. For example, the OnData function should do something like this:

1. Check the current day of week and time of day. If the current day of week is Mon or Wed or Fri and current time is 10:00AM EST, then proceed to step 2, otherwise return

2. Select the option chain for SPY options that expire today (I'm not sure ho wto do this)

3. Loop through the option chain and find the highest priced call that has a delta between 12 and 16. Also find the lowest priced put that has a delta between 12-16. Save these options as self.short_call and self.short_put.

4. Set self.long_call to be the call that is 3 points higher in strike than self.short_call. Set self.long_put to be the call that is 3 points lower in strike than self.short_put.

5. Sell this iron condor (self.long_put, self.short_put, self.short_call, self.long_call)

Does anyone have an example of how this would done?

Also is data available for SPX as well as for SPY?

Update Backtest







 
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Marc,

I recommend checking out our Iron Condor tutorial, which includes an example algorithm. To trade 30 after the open, create a scheduled event.

Yes, data is available for SPX and SPY. Check the data library whenever in doubt.

Best,
Derek Melchin

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed