Hey everyone. I am really struggling with self.Time in the Forex bootcamp. The objective for lesson 3 is:
Save the close price of ask price of the "EURUSD" hourly bar at 05/01/2017 10am.
I have completed the Securities bootcamp and have read through the documentation including “understanding time” and various others which had to do with time, but there is no documentation for self.Time plainly so I can't figure out how to set it to a specific date and hour. I am intermediate with python, but I feel like the answer must be super basic if it isn't even in the docs, I just have no idea where to look. Thank you!
LE
From what I understood. I think self.Time is equivalent to the datetime module. In my algorithm I use self.Time.hour (datetime.hour) and self.Time.minute (datetime.minute) attributes to get the current time integers.
If the start and end date is already 5/01/17, you can do (in your data slice):
If it's across a range of dates you could use .date() class to make sure it's the right day, though I assume that will be more complicated.
I agree, it's a bit tough to figure out these little things. I'm not sure if the above is best practice or not, but that's what I use and it's been working.
Fred Painchaud
Hi Joseph,
self.Time, as in the Time attribute in QCAlgorithm, is of type datetime in Python, indeed (as mentioned by LE).
But you cannot change it, re “I can't figure out how to set it to a specific date and hour”.
It gives you the current time of the algo/backtest. Changing it would certainly mean a huge mess…
Fred
Joseph Gibbons
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!