I'm subscribed to hourly data, but I also want daily data. I'm using a Consolidate object to do this, but I noticed that the data is shifted later by one day. For example, in the log below, the daily high for 2021-01-06 should actually be 774.00 (using TradingView as a reference), but the script outputs this price on 2021-01-07:
2021-01-04 00:00:00 Launching analysis for 6d856067e72dddddea13fd74f9cd6b34 with LEAN Engine v2.4.0.0.10608
2021-01-05 10:00:00 Current daily high: 744.47
2021-01-06 10:00:00 Current daily high: 740.84
2021-01-07 10:00:00 Current daily high: 774.00
2021-01-08 10:00:00 Current daily high: 817.00
2021-01-08 16:00:00 Algorithm Id:(6d856067e72dddddea13fd74f9cd6b34) completed in 0.45 seconds at 0k data points per second. Processing total of 78 data points.
I also noticed that the timestamp in the log is for 10:00 AM, which makes me think the Consolidator is being executed on the next day, rather than at the end of the day when I would expect. This seems counterintuitive to me.
Am I correct in thinking the Consolidator is being run on the next period? Is there some way of looking at this that will help me this more intuitive for me? It just seems like a pain that I'll need to remember there's an n+1 time shift anytime I use a Consolidator function.
Derek Melchin
Hi Nick,
To align the consolidated bar's timestamp with TradingView's, we need to access the starting timestamp of the consolidated bar. This is done with `bar.Time`.
Consolidated bars are produced when the algorithm receives a bar that is timestamped outside the consolidation window. In other words, if we are consolidating hourly bars into daily bars, the bar for 2021-01-06 is passed to our consolidation handler when the first hourly bar of 2021-01-07 is received. Before that moment, the last timestamped bar that we are aware of is 2021-01-06 4PM EST (market close). Since the timestamp of this bar hasn't passed midnight, the consolidated bar can't be generated.
See the attached backtest for further understanding. In addition, consider reviewing our docs on Understanding Time.
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.
Nick C
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!