Hey Quant Community!
I have created a simple algorithm that is just supposed to grab the previous week's high at the beginning of every week. I have also made it so that it logs the previous week's high every time spy price crosses above it. I have noticed some problems and I have no idea what is happening:
Sometimes it will log the previous week's high on a Tuesday instead of the Monday
The order logs seem to be a week behind.
When comparing the numbers on TradingView, I sometimes get different answers, some just a few cents off, and some up to a few dollars.
Can someone please tell me what I am doing wrong?
Louis Szeto
Hi Jesse
Since you set the time rule of the consolidator as timedelta(weeks=1), the start date of the bar will be on Tuesday if Monday is a holiday (17/1/2022 is a US Holiday), so the end date will also be delayed for a day, making subsequent consolidated bars has the same delay. You could implement below for weekly bar:
The order log looks fine to me. Why do you think it is a week behind?
For price discrepancy issue, we timestamp our data to the time when the period ends (e.g. 2/1/2022 00:00 for 1/1/2022's daily data). Many other platforms timestamp to the beginning of the candle. Please make sure you're comparing to the same bar.
Best
Louis
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.
Jesse Fleming
Louis Szeto Thank you so much for your helpful and timely response, brother! I have just posted another forum on something much less complicated in my opinion. Will you please save me once again and impart some of your insight into the problem I am having now?
Jesse Fleming
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!