Hello! I am using the MIN indicator like this:
#Initialize
spy = self.AddEquity('SPY', Resolution.Hour)
self.minimum = self.MIN('SPY', 50, Resolution.Daily, Field.Low)
In my OnData function I have these asserts:
#OnData
if data["SPY"] == None: return
if not self.minimum.IsReady: return
During the backtest it seems like the minimum indicator isn't ready until 50 days after the algorithm is started. WIll this happen when I live trade as well? Is there a way to backfill an indicator?
Thanks!
Derek Melchin
Hi Sachinahj,
We can specify a warm up period in Initialize to backfill the indicator.
lookback = 50 self.AddEquity("SPY", Resolution.Hour) self.minimum = self.MIN('SPY', lookback, Resolution.Daily, Field.Low) self.SetWarmUp(lookback, Resolution.Daily)
While the algorithm is warming up, we just need to ensure we stop it from sending orders in OnData with
if self.IsWarmingUp or not data.ContainsKey("SPY"): return
See the attached backtest for a full example algorithm.
Best,
Derek Melchin
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.
Sachinahj
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!