I'm experimenting with the Alpha Framework and some consolidated (5 day) indicators.  I'm building an AlphaModel that should work with weekly PPO to generate insights.

I'm having trouble properly warming up my indicators, even manually in OnSecuritiesChanged.  I think this should work, but the indicators are not warming up until the needed amount of time has actually elapsed in the backtest (i.e. they are not warming up ahead of time as I would wish). 

Another, unrelated problem, is that I have set:

self.UniverseSettings.Resolution = Resolution.Daily

in my algo, and, farther on.:

symbols = [ Symbol.Create(ticker, SecurityType.Equity, Market.USA) for ticker in tickers ] # set algorithm framework models self.SetUniverseSelection(ManualUniverseSelectionModel(symbols))

and despite what I think should result in daily resolution setting for all my data, my alpha model's Update method is called every minute.  I can't figure out why, I'd think with daily resolution for the data, I would only have my AlphaModel's Update called once a day.  I can work around this but wonder why I need to.

Here is a summary of what I am doing to try to warm up the 5 day indicators within the AlphaModel  - 1)subscribing the consolidator with the symbol using the SubscriptionManager, 2) making sure the consolidator DataConsolidated calls the SymbolData OnWeeklyData which updates the weekly PPO and 3) manually Updating the consolidator with history data to warmup the data (and hopefully the PPO by extension):

def OnSecuritiesChanged(self, algorithm, changes): '''Event fired each time the we add/remove securities from the data feed Args: algorithm: The algorithm instance that experienced the change in securities changes: The security additions and removals from the algorithm''' for added in changes.AddedSecurities: symbolData = self.symbolDataBySymbol.get(added.Symbol) if symbolData is None: symbolData = SymbolData(added) symbolData.PPO = PercentagePriceOscillator(self.fastPeriod, self.slowPeriod) weeklyConsolidator = TradeBarConsolidator(timedelta(days=5)) weeklyConsolidator.DataConsolidated += symbolData.OnWeeklyData algorithm.SubscriptionManager.AddConsolidator (added.Symbol.Value, weeklyConsolidator) tradeBarHistory = algorithm.History([added.Symbol.Value], 150, Resolution.Daily) for index, tradeBar in tradeBarHistory.loc[added.Symbol.Value].iterrows(): typedBar = TradeBar() typedBar.High = tradeBar.high typedBar.Low = tradeBar.low typedBar.Close = tradeBar.close typedBar.Open = tradeBar.open typedBar.Volume = tradeBar.volume typedBar.EndTime = index algorithm.Debug(str(typedBar.EndTime)) weeklyConsolidator.Update(typedBar) #TODO: PPO is not initializing self.symbolDataBySymbol[added.Symbol] = symbolData

 

...and farther on in SymbolData...

def OnWeeklyData(self, sender, bar): self.PPO.Update(bar.EndTime, bar.Close)

My assumption is that by: 1)subscribing the consolidator with the symbol using the SubscriptionManager, 2) making sure the consolidator DataConsolidated calls the SymbolData OnWeeklyUpdate to update the PPO and 3) manually Updating the consolidator to warmup the data, that my PPO should be warmed up at the proper period via manual updates to the consolidator.  It doesn't work.  How should I be manually warming up a consolidated indicator within the Alpha Framework? 

 

Thanks!

Author