Hello,
How do you set the end date for current the one in the documentation keeps getting an error?
self.SetEndDate(datetime.now() - timedelta(1))
QUANTCONNECT COMMUNITY
Hello,
How do you set the end date for current the one in the documentation keeps getting an error?
self.SetEndDate(datetime.now() - timedelta(1))
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.
Derek Tishler
Only supplying a 'self.SetStartDate' should work. You can comment out the SetEndDate line to get it working this way.
Dustin C
Thanks,
Dustin
Abco Janssens
I discovered when I comment out the self.SetEndDate to today's date, the backtest skips the previous day. I use OnEndOfDay method and it does not show the previous day in plots when I do not set the end date to today. When I do not comment out it shows the previous day. Is this normal behavior? It does not seem correct to me.
Abco Janssens
I have now included below code and then always previous day is included in the backtest (including a log of the current date time in the algorithm timezone).
Today = datetime.now().date()
TodayTime = Â datetime.now()
self.Log(TodayTime)
self.SetEndDate(Today)
Abco Janssens
Above statement ‘(including a log of the current date time in the algorithm timezone).’ is not correct. It should be (including a log of the current date time in the UTC timezone). To avoid confusion I adapted the code to include the UTC Time description.
Today = datetime.now().date()
TodayTime = Â datetime.now()
self.Log(f'{TodayTime} UTC_Time')
self.SetEndDate(Today)
Louis Szeto
Hi Abco
We tested both daily and minute resolution data and they do not reproduce your problem. Is there any possibility that the "previous day" is not a trading day? Please attach your code snippet for further assistant.
Best
Louis Szeto
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.
Dustin C
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!