Hi all,
I have found that SetWarmUP is NOT working for my consolidated bar Indicators. Instead, I would like to try warming them up with a history request but cant seem to make that work either. I have not been abloe to find a way in the documentation to implement a history request for consolidated bars. Any help appreciated...
thirtyMinuteConsolidator = TradeBarConsolidator(timedelta(minutes=30))
thirtyMinuteConsolidator.DataConsolidated += self.ThirtyMinuteHandler
self.SubscriptionManager.AddConsolidator(symbol, thirtyMinuteConsolidator)
self.short_ema = ExponentialMovingAverage(10)
self.RegisterIndicator(symbol, self.short_ema, thirtyMinuteConsolidator)
history = self.History(symbol, 10*30, Resolution.Minute).loc[symbol]
.... How do I update my thirtyMinuteConsolidator with the history?
... Which I believe will automatically update my registered indicators, no?
Mark Reeve
CORRECTION: I can make the WarmUp request work... but how would I achieve the samething with History?
Cole S
self.WarmupIndicator() will do this for you. There are multiple overloads, I'm not sure if it's documented or not, but I have used it before. You can see it in the source in QCAlgorithm.Indicators.cs
Shile Wen
Hi Mark,
To warm up our algorithm with consolidated bars, we can construct TradeBars from the historical data and pass them through our conslidator's Update method. I've shown this in the attached backtest. Note: the try-except is necessary for this issue.
Best,
Shile Wen
Victor Goujon
Hi Shile Wen,
I also have this problem but can't find your backtest?
Best,
Victor
Mark Reeve
Hi Shile,
That sounds ideal but I can't see any backtest attached?
Additionally I am trying to create a rolling window of 15minute bars within the SymbolData class. I am having the same issue - trying to populate the rolling window with historical data so it is ready to use on algo start up.
Thanks Shile Wen
class SymbolData: def __init__(self, symbol, algorithm): self.algorithm = algorithm self.symbol = symbol self.m15_open = 0 self.m15_high = 0 self.m15_low = 0 self.m15_close = 0 # Build our 15min consolidator and pre-populate the RollingWindow with TradeBar data self.m15_window = RollingWindow[TradeBar](2) fifteenMinuteConsolidator = TradeBarConsolidator(timedelta(minutes=15)) fifteenMinuteConsolidator.DataConsolidated += self.FifteenMinuteHandler algorithm.SubscriptionManager.AddConsolidator(self.symbol, fifteenMinuteConsolidator) self.fifteenMinuteBarUpdated = False def FifteenMinuteHandler(self, sender, consolidated): self.m15_open = consolidated.Open self.m15_high = consolidated.High self.m15_low = consolidated.Low self.m15_close = consolidated.Close self.fifteenMinuteBarUpdated = True
Shile Wen
Hi Victor and Mark,
Sorry about that, I've updated my previous comment to include the backtest. Furthermore, here I've attached another backtest which also includes the RollingWindow.
Best,
Shile Wen
Victor Goujon
Thank you Shile !
What about for multi symbols? Activating line 63 yields an error, deactivating it doesn't update the consolidator with the history;
Best,
Victor
Shile Wen
Hi Victor,
The issue is we need to access the DataFrame with .loc[symbol] before iterating over it to create TradeBars.
I've shown this fix in the attached backtest.
Best,
Shile Wen
Mark Reeve
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!