Hello, 

I'm quite confused on how to make the Rolling windows work. Because every calculation of each stock just has to be done one time so I just put everything on OnSecuritiesChanged. With the code I have down below would it be smarter to do it another way and is it even possible to do it like this?

After the calculation I have to add the number to the Symbol, do I use SymbolData or just a dict?

def OnSecuritiesChanged(self, changes: SecurityChanges) -> None:
        for symbol in [x.Symbol for x in changes.AddedSecurities]:
            self.mappings[symbol] = self.AddData(SECReport10Q, symbol).Symbol
            history = self.History(SECReport10Q, self.mappings[symbol], 400, Resolution.Daily)
            self.Debug(f"We got {len(history)} items from our history request")
            a = history.drop(['datasourceid','report'], axis=1, inplace=True)
            a = history.index.droplevel('symbol')
            for date in a:


                #   1. history for date
                #   2. calculate time
                self.window = RollingWindow[TradeBar](30)
                history_std = self.History(symbol, 40, Resolution.Daily)
                self.Debug(history_std)      
                self.std = self.STD(self.mappings[symbol], 10)
                self.std.Updated += self.StdUpdated
                self.stdWin = RollingWindow[IndicatorDataPoint](30)
               
                self.window.Add(data[symbol])
                if not (self.stdWin.IsReady and self.window.IsReady): return       

Thanks in advancce!

 

 

Author