Hi
I got the following error when I tried to import requests or to use urllib packages.
42 | 20:42:56:
Build Warning: File: n/a Line:0 Column:0 - Sorry, 'open(' is not whitelisted within QuantConnect. Remove this code statement
43 | 20:42:57:
Build Warning: File: n/a Line:0 Column:0 - Sorry, 'open(' is not whitelisted within QuantConnect. Remove this code statement
44 | 20:43:00:
Build Warning: File: n/a Line:0 Column:0 - Sorry, 'open(' is not whitelisted within QuantConnect. Remove this code statement
45 | 20:43:18:
Build Error: File: test.py Line:1 Column:0 - ImportError: No module named requests
46 | 20:43:38:
Build Error: File: test.py Line:1 Column:0 - ImportError: No module named requests
47 | 20:45:24:
Build Error: File: test.py Line:1 Column:0 - ImportError: No module named requests
Are Python packages requests and urllib not allowed to use on QuantConnect cloud servers?
Also, any plans to support Python 3.x ?
Thanks
Alexandre Catarino
What is the file format? If it is csv, you can use pandas.read_csv:
import pandas as pd url = "https://www.dropbox.com/s/2az14r5xbx4w5j6/daily-stock-picker-live.csv?dl=1" df = pd.read_csv(url, header = None)
We have no plans to support Python 3.x. Our focus is on making the current python implementation better.
CloudTrader
Hi Alexandre,
Thanks. Format is JSON. What I want to do is a REST API call like this:
url = "https://<sentiment analysis web service>" response = requests.get(url, auth=(user, token))
response is returned by REST API endpoint as JSON data.
Alexandre Catarino
For security reasons, we cannot whitelist urllib nor requests. Since pandas.read_csv or pandas.read_json will not work for your case, you can try to implement a custom data data feed.
However, we know that in some cases none of the above will suffice, therefore we will work on a feature that implement enable us to fetch data from an url. Something like:
url = "https://<sentiment analysis web service>" response = self.Download(url, user, token)
CloudTrader
Alexandre, this would be really very useful to have such implementation added to LEAN. Many thanks!
Alexandre Catarino
We have merged the solution. It works like this:
url = "https://<sentiment analysis web service>" auth = {"user": "CloudTrader", "token": "mysupersecrettoken"} response = self.Download(url, auth)
where response is a string.
CloudTrader
Alexandre, this is awesome! Is this the C# method declaration, which it was named before Fetch?
public string Download(string address, PyObject headers = null, string userName = null, string password = null)
Alexandre Catarino
Yes, this is it. We rename me for clarity.
CloudTrader
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!