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?