Hi, I have been doing a lot of programming on Quantconnect. I recently realised the data on ETF's such as 'SPY' and ‘QQQ’ even a stock such as ‘AAPL’ don't match up with data on Trading View. This creates a problem where I can't be sure about my strategies which reference previous Bars data such as High,Low or Close to generate trading signals or insights! Has anyonelse experienced a similar issue and have you found a solution? Here is some simple code for anyone wanting to see the LOG Output printed with the OHLC data themselves and check themselves regarding the data mismatch.
Mia Alissi
The issue you're experiencing might be due to the fact that QuantConnect adjusts the data for splits and dividends. This is mentioned in one of the forum discussions here. This means that the historical price of a security in QuantConnect's data might not match the historical price on other platforms if they don't adjust for splits and dividends in the same way.
As for the code you provided, it seems to be incomplete. The
OnData
method doesn't contain any logic after checking if the current bar data is not None. You might want to add code to log the OHLC data, like so:This will print the OHLC data for each bar to the algorithm's logs. You can then compare this data with the data from Trading View to see if there are any discrepancies.
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.
Akira
Thank you for the reply. I do find an issue with the data however. I ran ‘SPY’ with your amended “OnData” method. I got the log results. There is a data point for February 10th 2024, which is a Saturday (NOT A TRADING DAY). The data on that Time Stamp however correlates to the Data for February 9th 2024, which is the previous day, a Friday!
How can this be resolved? Any help would be Greatly Appreciated!
Mia Alissi
The issue you're experiencing is due to the way QuantConnect handles daily data. As mentioned in several forum discussions (here, here, and here), the close of a daily bar is not known until the start of the next bar. This means that 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.
This is why you're seeing data for February 10th 2024, which is a Saturday. The data you're seeing is actually the data for February 9th 2024, but it's timestamped as February 10th because that's when the bar was emitted to your algorithm.
As for the code you provided, it seems to be incomplete. The
OnData
method doesn't contain any logic after checking if the current bar data is not None. You might want to add code to log the OHLC data, like so:This will print the OHLC data for each bar to the algorithm's logs. You can then compare this data with the data from Trading View to see if there are any discrepancies.
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.
Akira
Thank you, i will read the forum disucssions but I believe I understand what you've explained.
Mia Alissi
I'm glad to hear that you found the explanation helpful, 'Akira'. If you have any more questions or need further clarification, don't hesitate to ask. Happy coding!
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.
Akira
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!