Hi Guys,
I am new to quantconnect and, while doing some tests, I've found a intriguing "issue" that you may help me to find out the reason. In the documentation it says
"The close of a bar is not known until the start of the next bar, which can sometimes be confusing. For example, a price bar for Friday will include all the ticks from Friday 00:00 to Friday 23:59.99999, but it will actually be emitted to your algorithm on Saturday at midnight. Because of this, any orders you create after analyzing the Friday data will be sent to your brokerage on Saturday, when most markets are closed."
To test it I loaded an equity in the research notebook and logged the same equity during a dummy backtest.
These are OHLC values for EWA from the notebook:
qb = QuantBook()
spy = qb.AddEquity("EWA")
qb.History(qb.Securities.Keys, datetime(2007,1,1), datetime(2007,1,5), Resolution.Daily)
And here is the Log for the same Symbol:
OnData - 2007-01-04 00:00:00 EWA: Close=12.431563452 -Open=12.558308364
OnData - 2007-01-05 00:00:00 EWA: Close=12.215040894 -Open=12.257289198
In my opinion, according to the documentation, the data fed on 2007-01-04 00:00 should correspond to the bar of the previous day (2007-01-03), And normally, the value for the history should correspond to the open and close of day 2007-01-04. Am I doing anything wrong or there is just a "shift" in both data? I also tested the algorithm using AfterMarketOpen, and the values are the same for day 2007-01-04, so according to the time frontier concept, these values are from the day before.. Thanks in advance, and congratulations for the great platform. Mauricio
Derek Melchin
Hi Maurício,
The timestamp given to each bar is the same between research and the backtesting environments. Each daily bar is timestamped to the end of its period. That is, the bar that spans to 2021-04-01 00:00:00 to 2021-04-02 00:00:00 is given the timestamp 2021-04-02 00:00:00.
See the attached backtest logs and notebook for reference.
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.
Maurício Cordeiro
Thanks for the clarification Derek.
Maurício Cordeiro
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!