Created the “CustomReference” Library and added reference data to “Library.py”. Can't seem to import via any of these import commands. What am I doing wrong? Thanks in advance.
from CustomReference import Library
from CustomReference import *
from CustomReference.Library import *
Louis Szeto
Hi Postbio
The correct way would be
Note that the notebook will not refresh and load instantaneous changes, so you should always terminate your notebook instance first, create/edit the python file, rebuild the project and restart the notebook afterwards to load the latest changes.
Best
Louis
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.
Postbio
Hi Louis,
Thanks for the response.
I'm still unable to import with that syntax (I've tried before via “CustomLibrary import * “), even when closing down the notebook and re-starting.
Also tried clicking ”Restart” in the top, along with, clearing cell outputs.
Thanks in advance if you can shed light on this.
Thanks!
Louis Szeto
Hi Postbio
We can't reproduce your issue. May you attach a backtest with the library file and notebook here?
Best
Louis
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.
Postbio
Hi Louis,
Sure thing. Here's the project.
EDIT: I have no backtests in dropdown, but it's just what you see in the screenshot above and here.
Postbio
ps. It's just the most basic importing.
Mr. B.
I am having the same issue, same error and setup looks the same. Library import works in main.py but not in any notebook.
Louis Szeto
Hi Postbio and Mr. B
The custom files/folders were outside the project directory, so they won't get compiled. Please put them under `\project`.
Best
Louis
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.
Postbio
Hi Louis,
Works!
Didn't know it was possible to create & use a folder at the project level like that.
Also thought we had to import by choosing from the dropdown on the left column.
Kevin
Postbio
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!