Hi All,
I have noticed some strange behaviour in the "self.Schedule.On" method that I am unable to pinpoint. I checked the logs and found this for 2018-01-02:
"The security does not have an accurate price as it has not yet received a bar of data. Before placing a trade (or using SetHoldings) warm up your algorithm with SetWarmup, or use slice.Contains(symbol) to confirm the Slice object has price before using the data. Data does not necessarily all arrive at the same time so your algorithm should confirm the data is ready before using it."
Ok, so I can implement a check in the rebalance function to see if a symbol has data before executing the code, HOWEVER, this is where it gets weird, the trigger of the Rebalance function came from the OnSchedule function, which took a Symbol as an argument.
So why is OnSchedule function firing on 2018-01-02, when the markets were closed and this symbol was not trading?
Rahul Chowdhury
Hey Mark,
The markets were open on 01-02-2018 because it was not a weekend or a holiday. There isn't any data on that day because daily resolution data is available at midnight after the end of the trading day. However, because the scheduled event fires at 4 PM, the bar data is not yet available to make trades. One solution is to use higher resolution data, like minute data, which will let your algorithm access the latest price data at 4 PM.
Mark Reeve
Hi Rahul Chowdhury,
Thanks for that. That wasn't how I expected the OnSchedule function to operate with daily data - managed to fix it with a simple WarmUp of single day...
self.SetWarmUp(1)
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!