from datetime import datetime, timedelta
Code such as the above works for external libraries. But doesn't seem to allow me to pull additional files I've defined in the web editor, such as pivots.py, into main.py.
Previous discussion question suggests an answer, but unsure how to "add to root level" as he discusses here. Assuming he is running the desktop implementation:
https://www.quantconnect.com/forum/discussion/3708/python-libraries-and-directories/p1
How does one go about doing this, or is it even possible? Previously the capability has been shut down:
https://www.quantconnect.com/forum/discussion/1920/can-python-projects-can-only-use-main-py-now/p1
Douglas Stridsberg
Hi Ian,
This is what I do when I want to create and include new libraries, adapted for Python:
The library files will now appear inside your project but they will still be linked to your library. This is good in case you have multiple algos sharing the same library - any changes to the library files will propagate across to all other algos.
Ian Larson
Thanks a lot Douglas!!
Ian Larson
By playing with the Algorithm Wizard 2.0 I've discovered that this is quite straightforward, modules added are listed as additional tabs and imported in the standard way:
Keep code modular and import into main.py (if using Python) with: "from module import class/function as class/function" Omit the .py on the end of the module. I didn't do this the first time and thus couldn't successfully import. Noob mistake
--------------
Bonus, the documentation mentions creating virtual folders to organize code first paragraph here:
https://www.quantconnect.com/docs/key-concepts/developing-in-the-ideThat looks like:
Create a folder for projects by adding "Title/" in front of the file name in the IDE. Don't include the quotes. All projects with the same title will end up in a virtual folder by that title, allowing for better organization.
---------------
Both of the above are going to go a long way for me, personally, in keeping the code readible and maintainable
Ian Larson
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!