qb = QuantBook()
qqq = qb.AddEquity("QQQ")
start_time = datetime(2020, 12, 1) # start datetime for history call
end_time = datetime(2021, 1, 7) # end datetime for history call
# Returns daily historical data between January 1st 2019 and January 1st 2020
history = qb.History(qqq.Symbol, start_time, end_time, Resolution.Daily)
history.loc["QQQ"]
I tried the previous code in Research and the result is in the table below. The result is not accurate at all. For example, the market was closed on Jan 01, but there is still data for that date
close high low open volume
time
2020-12-02 303.46 305.1400 300.830 301.97 25607635.0
2020-12-03 303.85 304.2000 300.350 302.25 22008272.0
2020-12-04 304.28 305.8800 303.531 304.17 21082085.0
2020-12-05 305.52 305.6700 303.630 304.33 17540116.0
2020-12-08 307.25 307.6300 305.520 305.72 15799078.0
2020-12-09 308.29 308.6100 304.960 306.76 16698225.0
2020-12-10 301.31 308.3600 300.210 308.13 43692846.0
2020-12-11 302.52 303.6800 298.090 299.21 25113732.0
2020-12-12 301.85 301.9800 298.470 300.77 24711707.0
2020-12-15 304.04 306.0500 303.010 303.05 25957392.0
2020-12-16 307.29 307.3636 304.110 306.40 23074931.0
2020-12-17 308.98 309.7810 306.620 307.75 22970435.0
2020-12-18 311.00 311.2400 309.380 310.70 20697627.0
2020-12-19 310.06 311.9700 307.610 311.60 36636019.0
2020-12-22 308.92 309.4700 303.600 306.51 32463534.0
2020-12-23 309.76 310.7200 306.850 309.77 24534478.0
2020-12-24 308.20 310.3500 308.040 309.88 19091918.0
2020-12-25 309.56 310.0200 308.390 308.53 11876055.0
2020-12-29 312.68 313.1690 310.360 312.31 20724335.0
2020-12-30 312.96 314.6900 312.030 314.09 24384741.0
2020-12-31 312.97 314.4900 312.330 314.20 16742560.0
2021-01-01 313.74 314.2400 311.770 312.92 19472357.0
2021-01-05 309.31 315.2900 305.180 315.18 41715635.0
2021-01-06 311.86 312.1400 308.290 308.44 26190005.0
2021-01-07 307.54 311.8900 305.980 306.82 48330659.0
I am just wondering what I could have done wrong?
Arthur Asenheimer
Data are shifted by one day because the closing price of a day is set at midnight on the following day. Therefore, for example, the time stamp 2021-01-01 belongs to the trading day 2020-12-31 etc.
Quote from the docs:Â
"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. "
Â
Â
Vincent Vu
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!