Noobish question here but I've searched and had no luck.
I'm going through the bootcamp but it's proving a bit difficult. There doesn't appear to be much in the way of python documentation or example code usage.
For example there's a part of the forex bootcamp that asks you do something at 10am using the self.Time property. However I couldn't find anything in https://www.quantconnect.com/lean/docs that would have helped me easily figure out what self.Time returned or how to get check if it's 10am. The way I ended finding out what to do was searching for self.Time in the github repo and found an example usage. But that hasn't worked for all the questions I've had. Any suggestions?
Serge d'Adesky
I had a lot of issues with this as well. Recently though, QC started offering Debugging in the IDE. By combining these with breakpoints it allows you to inspect certain variables. In the case of the self.Time variable, you could place a breakpoint in the first line of the OnData function, then write "dir(self)" as your variable. This would expose all the functions and properties of that object. You can also use "type(self)" to get object types etc.
Finally, I suggest you use the Research tool for debugging purposes. Not all functions are identical with the runtime environment, but most are.
Good luck to you.
Hello
Thanks very much for your suggestions! I haven't managed to figure out the debugging yet but being able to inspect variables without rerunning a backtest each time will be very time saving. I've been using a lot of "type(variable)" calls which has been useful. And I'll check out the research tool soon. Cheers!
Jared Broad
Thanks "Hello" - we'll look into making the lesson text more intuitive and highlighting the python hour/minute properties on the time object!
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.
Douglas Stridsberg
Hi,
It can be tricky indeed. I recommend using the code completion (Ctrl+Space) in the actual editor - it helps you see what the type is you're looking at. As an example, this is what it showed me for self.Time:
Hello
Hey Douglas Stridsberg is that code completion in the online editor or a local one? I'm on mac and it said somewhere possibly that code completion for python doesn't work in the mac editor, but I could be wrong.
Douglas Stridsberg
Online editor. It should be cross-browser compatible - not sure why it wouldn't work on your end.
Hello
This is interesting, I haven't been able to get either the debug or the code completion working in the browser. I'm using the latest version of Chrome on a Mac. Jared Broad do you know if this is a known mac / chrome issue or am I just really bad at figuring this stuff out?
Hello
Ok, the code complete is working this morning! Looks like debug is still out of action though.
Hello
Ok, so to be clear debug only works in the sense that you can set break points and watch variables. The whole time I've been typing in the console expecting something like PDB but kept getting errors.
Is there anyway around the issue where if the variable name is too long you can't view the value?
Hello
Alright, hovering over the variable shows the hidden value.
Hello
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!