We have a patch in the open-source project that changes the python version Lean/QuantConnect supports:
Upgrades python support to 3.6 from 2.7 #1526
Now Lean/QuantConnect supports Python 3.6.
We have to make minor corrections in our algorithms, so you might need to do it to yours too:
- Leading zeros: SetStartDate(2017, 01, 01) to SetStartDate(2017, 1, 1);
- filter is not a list: filter(lambda ... ) to list(filter(lambda ... ))
- usage of SecuritiesChanged.None not allowed. We can use changes.Count > 0 instead
All third party libraries that were supported until now remain available.
Jing Wu
In Python2 dictionaries have the methods iterkeys(), itervalues() and iteritems() that return iterators instead of lists. In Python 3 the values() and items() return dictionary iterview object.
For example
# Python 2 for key, value in my_dict.iteritems(): # Python 3 for key, value in my_dict.items():
# Python 2 for value in my_dict.itervalues(): # Python 3 for value in my_dict.values():
Rodrigo Nader
How do I update it?
Huy Hoang
Sweet! I was checking a script by Jing yesterday and knew the Lab is now updated to 3.6 when it threw an error because of leading zero.
Rodrigo Nader the online platform is updated and you just need to fix the errors it produces for old script. If you're asking about local development environment then I guess the best way to do it is to do a full download of the project folder from github and rebuild the project files (?)
Rodrigo Nader
Thank’s Huy Hoang. But in research it appears to me that I’m using Python 2. Is that normal?
Huy Hoang
Rodrigo Nader the research environment is actually running on python 2 kernel. But the lab where we write algo is python 3.6. I also look forward to an update in Research too.
Jing Wu will we move to jupyter lab when version 1.0 is released? I really look forward to that. Playing with the lab is exciting.
Alexandre Catarino
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!