Hi All,

In the code below I have it set up to be trading on Wednesday the 1st of June and i would like it to trade contract on Friday the 3rd of June (2 days) where am i going wrong in the code for it to not give me any options at all to trade. Do i need to subscribe to my own interactive brokers data for better data with equity options? Seems to not make a difference which dates I set in the .Expiration() it never brings me back the contracts i would want to trade.

Thanks

from AlgorithmImports import *
from math import floor

class NSDQOPTIONSSTRAT1(QCAlgorithm):
    UnderlyingTicker = "QQQ"
    def Initialize(self):
        self.SetStartDate(2022, 6, 1)
        self.SetEndDate(2022, 6, 1)
        self.SetCash(5000)

        equity = self.AddEquity(self.UnderlyingTicker)
        equity.VolatilityModel = StandardDeviationOfReturnsVolatilityModel(30)
        option = self.AddOption(self.UnderlyingTicker, Resolution.Minute)
        self.option_symbol = option.Symbol
        
     # set our strike/expiry filter for this option chain
        option.SetFilter(lambda u: (u.Strikes(-2, +2)
                                     # Expiration method accepts TimeSpan objects or integer for days.
                                     # The following statements yield the same filtering criteria
                                      .Expiration(0, 2)))
    
        #Benchmark
        self.SetBenchmark(equity.Symbol)

        #Warm Up
        self.SetWarmup(30, Resolution.Daily)

    def OnData(self,slice):
        
        if self.Portfolio.Invested or not self.IsMarketOpen(self.option_symbol): return

        chain = slice.OptionChains.GetValue(self.option_symbol)
        if chain is None:
            return

        # we sort the contracts to find at the money (ATM) contract with farthest expiration
        contracts = sorted(sorted(sorted(chain, \
            key = lambda x: abs(chain.Underlying.Price - x.Strike)), \
            key = lambda x: x.Expiry, reverse=True), \
            key = lambda x: x.Right, reverse=False)

        # if found, trade it
        if len(contracts) == 0: return
        symbol = contracts[0].Symbol
        self.MarketOrder(symbol, 1)
        self.MarketOnCloseOrder(symbol, -1)

    def OnOrderEvent(self, orderEvent):
        self.Log(str(orderEvent))