Hi team,
I am new to the platform and struggling to understand it. I've searched extensively through examples and previous discussions to no avail.
I do not understand how time zones work - both how to set them and what I should expect to get back. I need this to validate that I am consolidating data correctly for indicators.
I have attached some simple code where I have used the SetTimeZone function to set it to Chicago time. I have done this in the Initialize() method. (There are no orders placed in my sample.)
Then, in the OnData() function, I have created an if statement → if tradebar.Time.Hour == 21 then Log the tradebar.Time, and OHLC of the bar. I was trying to get the values for 9:00-9:59PM Chicago Time. The resulting log shows rows like:
2021-09-16 16:01:00 :9/16/2021 9:00:00 PM Open:3498.13 High:3503.71 Low:3490.83 Close:3503.71Notice that the timestamp hours do not align. tradebar.Time actually returned UTC time so I got the values for 4:00-4:59PM Chicago Time.
Why is this happening when I set the TimeZone earlier? Will tradebar.Time.Hour always be in UTC, so the values should always be adjusted?
Thanks for your help in advance!
-D
Varad Kabade
Hi Deyan Dimov,
Yes, we can perform the above using API, but we recommend using the cloud Optimization functionality. Refer to the following thread for more information on using the tool.
Best,
Varad Kabade
Deyan Dimov
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!