Hello All,

First of all, I'd like to appologize for being an absolute noob. I am trying my best to learn by doing the Bootcamp and manipulating existing algorithms. A promising idea I have involves winnowing the universe down to only those equities that have increased over 4% from previous day's close to current day's open.

 

In order to do this AND keep the universe small and not time out with "OnData," I need to call prev close and current open as indicators run through SelectionData, correct? Is there anyway to do this? I'd like to select for these gappers in the coarse filter if at all possible.

 

I've combined two of the BootCamp algos, but obviously I'm missing the mark. Any help would be appreciated.

 

Thanks!!

## EMA ALGO, modified class EMAMomentumUniverse(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 1, 7) self.SetEndDate(2019, 1, 9) self.SetCash(100000) self.UniverseSettings.Resolution = Resolution.Minute self.AddUniverse(self.CoarseSelectionFunction) #1. Create our dictionary and save it to self.averages self.averages = { } def CoarseSelectionFunction(self, universe): selected = [] universe = sorted(universe, key=lambda c: c.DollarVolume, reverse=True) universe = [c for c in universe if c.Price > 1][:100] # Create loop to use all the coarse data for coarse in universe: symbol = coarse.Symbol if symbol not in self.averages: # 1. Call history to get an array of 1 days of history data history = self.History(symbol, 1, Resolution.Daily) #2. Adjust SelectionData to pass in the history result self.averages[symbol] = SelectionData() #(history) self.averages[symbol].update(self.Time, coarse.AdjustedPrice) if self.averages[symbol].is_ready() and self.percentgap > .04: selected.append(symbol) return selected[:20] def OnSecuritiesChanged(self, changes): for security in changes.RemovedSecurities: self.Liquidate(security.Symbol) for security in changes.AddedSecurities: self.SetHoldings(security.Symbol, 0.10) class SelectionData(object, data): def __init__(self): #self.slow = ExponentialMovingAverage(200) #self.fast = ExponentialMovingAverage(50) #HOHOHOHOHOHOHOHOHOHOHOHO #VARIABLE IS EQUAL TO OPEN/CLOSE - 1 ...AKA THE GAP self.openz = data[symbol].Open self.closez = data[symbol].Close self.percentgap = self.openz / self.closez -1 def is_ready(self): return self.percentgap.IsReady

 

Thanks!!