Hi There,

I have spent the last couple of months building up my algo to get it ready for deployment and bought a live node last week in order to get it running with paper trading. However I have been running it for the last week live and it has not made any moves at all, I have backtested this algo hundreds of times and it works fine so I was initially a little perplexed.

anyway long story short I have run Logs all the way through it when it's running live and found that when the system runs through slice.OptionChains using the code below (works in backtest fine), the length of slice.OptionChains is 0 (no option chains are loaded into this???)

    def sell_put(self,slice,underlying):
            self.Log("attempting to Sell Put")
            self.Graph()
            putchain = None
            self.Log(str(len(slice.OptionChains)))
            for i in slice.OptionChains:
                if str(i.Value.Symbol.Underlying) == str(underlying):
                    putchain = i.Value
                    self.Log("found put chain")
                    break
            if putchain is None: return

So I'm left thinking that when its running live, for some reason slice.OptionChains is not being populated with data.

I don't want to share too much of the code, but here is what im running as my initialize to load the options as well as the universe function:

def Initialize(self):
        
        self.SetStartDate(2016, 1, 15)
        self.SetEndDate(2021, 3,21)
        self.SetCash(10000)
        self.resolution = Resolution.Minute
        self.stocks = ["AMD"]
        self.symbols = []
        self.sell_options = True
        self.Leverage = 1.0

        
        self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage,AccountType.Margin)
        
        for ticker in self.stocks:
            equity = self.AddEquity(ticker, self.resolution) #Adding
            self.Securities[ticker].SetDataNormalizationMode(DataNormalizationMode.Raw)
            option = self.AddOption(ticker, self.resolution) #Adding Options Chain
            #option.SetFilter(self.UniverseFunc)
            option.SetFilter(timedelta(0), timedelta(180))
            option.PriceModel = OptionPriceModels.CrankNicolsonFD()
            self.symbols.append(option)

        #assigns the first stock to a variable so it can be used in the date time scheduler to turn on the system at times of the day
        self.symbol = self.stocks[0]
        
        self.SetWarmUp(timedelta(2))
        
        self.Schedule.On(self.DateRules.EveryDay(),self.TimeRules.At(9, 40),self.Graph)
        
        #self.Schedule.On(self.DateRules.EveryDay(self.symbol),self.TimeRules.AfterMarketOpen(self.symbol, 10),self.trade)
        #self.Schedule.On(self.DateRules.EveryDay(self.symbol),self.TimeRules.AfterMarketOpen(self.symbol, 240),self.trade)
        #self.Schedule.On(self.DateRules.EveryDay(self.symbol),self.TimeRules.BeforeMarketClose(self.symbol, 10),self.trade)
        
        self.Schedule.On(self.DateRules.EveryDay(self.symbol),self.TimeRules.Every(TimeSpan.FromMinutes(2)),self.trade)

    def UniverseFunc(self, universe):
        # include weekly contracts
        return universe.Expiration(TimeSpan.FromDays(5),TimeSpan.FromDays(15))

Any help would be wonderful

 

Cheers

Author