Help Warming Up Consolidated Indicators within the Alpha Framework

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

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
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 =
typedBar.Volume = tradeBar.volume
typedBar.EndTime = index
#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? 



Update Backtest

Please check the algorithm below as a reference on how to manually warm up a consolidated indicator within the Alpha Framework. In this example, the indicator is saved in SymbolData and has RegisterIndicators and WarmUpIndicators methods, which are both called while the symbol is being added to the Universe. The indicator is registered via the consolidator in order to automatically trigger the update method. Warmup retrieves downloaded historical data as a dataframe and iterates through it. It is conceptually easier than trying to update weeklyConsolidator with historical data. The following code should provide a good template; it uses the ROC indicator with the past 20 days historical data to determine its insights.


Thank you for your help!  This successfully warmed up the Daily indicator used in your example.

Attached I modified your example to create and warmup a weekly consolidated indicator to show how this can be done.  I've attached the updated code for reference.  Instead of using a Daily ROC, I've created a 20 week ROC indicator and warmed it up manually.  It warms up using modifications to the SymbolData self.Conslidator initialization and changes to the WarmUp method (to update the consolidator vs the indicator directly and requiring more history than before).  See attached.



Update Backtest


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


This discussion is closed