In the main.py I'm able to successfully pull in a csv file from my google drive. However in the research environment the QCAlgorithm().Download(feature_path) doesn't work, I get a NullReferenceExeception:
NullReferenceException Traceback (most recent call last)
Cell In[10], line 1
----> 1 results = QCAlgorithm().Download(feature_path)
NullReferenceException: Object reference not set to an instance of an object.
at QuantConnect.Algorithm.QCAlgorithm.Download(String address, IEnumerable`1 headers, String userName, String password) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/Algorithm/QCAlgorithm.cs:line 2998
at QuantConnect.Algorithm.QCAlgorithm.Download(String address, IEnumerable`1 headers) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/Algorithm/QCAlgorithm.cs:line 2983
at QuantConnect.Algorithm.QCAlgorithm.Download(String address) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/LeanEnterprise/Algorithm/QCAlgorithm.cs:line 2972
How can I pull in an external .csv file into the cloud research environment?
Mia Alissi
In the research environment, you should use the
QuantBook
class to download data instead ofQCAlgorithm
. TheQuantBook
class is designed for use in the research environment, whileQCAlgorithm
is used in backtests.Here is an example of how you can download a CSV file in the research environment:
In this example,
qb.Download(url)
is used to download the data from the specified URL. The downloaded data is a string, which is then converted into a pandas DataFrame for further use.Please replace the
url
with your Google Drive CSV file link. Make sure the link is publicly accessible, otherwise, the download will fail.For more information, you can refer to the QuantConnect Research Environment Documentation.
Sources:
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.
Dsherman
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!