I've made two algorithems that shoud function the same, with the only difference being that one uses a consolidator to get daily close price from hour data, and one uses daily data directly. They give very different results due to the time that the consolidator takes the daily close. Is there any way to make the consolidated data match the standard daily data? Both backtests are attached.
Richard Mannschreck
Here is the same algorithem using daily data directly:
Alexandre Catarino
Hi Richard Mannschreck, sorry about the wait.
The discrepancy is due to the difference between the data time zone (UTC) and data exchange time zone (New York). Daily data is aggregated accordingly to the data timezone while daily consolidators to the data exchange time zone, so the consolidator is using 04 am to 04 am data.
Is there any way to make the consolidated data match the standard daily data?
Yes, we need to manage the consolidator manually in three steps
#In Initialize: self.Schedule.On(self.DateRules.EveryDay("USDCAD"), self.TimeRules.At(1, 0, TimeZones.Utc), self.OnDailyData); # Add WorkingData to window and reset the consolidator def OnDailyData(self): self.window.Add(self.consolidator.WorkingData) self.consolidator = QuoteBarConsolidator(timedelta(1)) # In OnData: Update the consolidator manually self.consolidator.Update(data["USDCAD"])
Richard Mannschreck
Very helpful, thanks!
Richard Mannschreck
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!