so I have something very simple to ask but I can't get my head around it. I'm trying to import some stock data from yahoo finance, nothing fancy. I used to do this via:
import pandas.io.data as web
import pandas as pd
import datetime
start=datetime.datetime(2000,1,1)
end=datetime.date.today()
SLB=web.DataReader("SLB","yahoo",start,end)
Everything used to work lovely like this. However, I'm well aware of the changes that have taken place. The import method is now:
from pandas_datareader import data,wb
However, using this method, (and I'm still using the same start,end data etc), I receive:
SLB=wb.DataReader("SLB","yahoo",start,end)
Traceback (most recent call last):
File "<ipython-input-218-6633f366e2cb>", line 1, in <module>
SLB=wb.DataReader("SLB","yahoo",start,end)
AttributeError: module 'pandas_datareader.wb' has no attribute
'DataReader'
I've had a look online (obviously) for more information, and I've seen in some cases people have put:
SLB=data.DataReader('SLB','yahoo',start,end)
which leads to an even longer error altogether regarding issues connecting to the URL.
If anyone has come across this before, or can see errors in my code, It would be great if you could shed some light!
cheers
p.s.
the longer error message I got using:
SLB=data.DataReader("SLB","yahoo",start,end)
is:
SLB=data.DataReader("SLB","yahoo",start,end)
Traceback (most recent call last):
File "<ipython-input-226-0cd57c0d4cbe>", line 1, in <module>
SLB=data.DataReader("SLB","yahoo",start,end)
File "C:\Users\User\Anaconda3\lib\site-
packages\pandas_datareader\data.py", line 116, in DataReader
retry_count=retry_count, pause=pause,
File "C:\Users\User\Anaconda3\lib\site-
packages\pandas_datareader\yahoo\daily.py", line 76, in read
""" read one data from specified URL """
File "C:\Users\User\Anaconda3\lib\site-
packages\pandas_datareader\base.py", line 155, in read
if isinstance(self.symbols, (compat.string_types, int)):
File "C:\Users\User\Anaconda3\lib\site-
packages\pandas_datareader\base.py", line 74, in _read_one_data
out = self._read_url_as_StringIO(url, params=params)
File "C:\Users\User\Anaconda3\lib\site-
packages\pandas_datareader\base.py", line 85, in _read_url_as_StringIO
response = self._get_response(url, params=params)
File "C:\Users\User\Anaconda3\lib\site-
packages\pandas_datareader\base.py", line 120, in _get_response
raise RemoteDataError('Unable to read URL: {0}'.format(url))
RemoteDataError: Unable to read URL:
http://ichart.finance.yahoo.com/table.csv?
s=SLB&a=0&b=1&c=2000&d=5&e=16&f=2017&g=d&ignore=.csv
Hope this helps a little bit more.
Related
I have been using pandas_datareader to retrieve stock prices from the IEX and Robinhood APIs for some time without any hitches. However, recently (early this week), my code started failing.
Here's the code and the error:
IEX API
import pandas_datareader.data as web
import datetime as dt
end = dt.datetime.today()
start = end - relativedelta(months=20)
data = web.DataReader('MSFT', 'iex', start, end)
And the error:
web.DataReader('MSFT', 'iex', start, end)
Traceback (most recent call last):
File "<ipython-input-88-2781d4515d5c>", line 1, in <module>
web.DataReader('MSFT', 'iex', start, end)
File "/anaconda3/lib/python3.7/site-packages/pandas_datareader/data.py", line 322, in DataReader
session=session).read()
File "/anaconda3/lib/python3.7/site-packages/pandas_datareader/iex/daily.py", line 91, in read
self._get_params(self.symbols))
File "/anaconda3/lib/python3.7/site-packages/pandas_datareader/base.py", line 84, in _read_one_data
out = self._read_url_as_StringIO(url, params=params)
File "/anaconda3/lib/python3.7/site-packages/pandas_datareader/base.py", line 95, in _read_url_as_StringIO
response = self._get_response(url, params=params)
File "/anaconda3/lib/python3.7/site-packages/pandas_datareader/base.py", line 155, in _get_response
raise RemoteDataError(msg)
RemoteDataError: Unable to read URL: https://api.iextrading.com/1.0/stock/market/batch?symbols=MSFT&types=chart&range=2y
Response Text:
b'Forbidden'
Robinhood API
import pandas_datareader.data as web
import datetime as dt
end = dt.datetime.today()
start = end - relativedelta(months=20)
data = web.DataReader('MSFT', 'robinhood', start, end)
And the error:
web.DataReader('MSFT', 'robinhood', start, end)
Traceback (most recent call last):
File "<ipython-input-90-0a0fc1b0d4ce>", line 1, in <module>
web.DataReader('MSFT', 'robinhood', start, end)
File "/anaconda3/lib/python3.7/site-packages/pandas_datareader/data.py", line 391, in DataReader
session=session).read()
File "/anaconda3/lib/python3.7/site-packages/pandas_datareader/base.py", line 77, in read
return self._read_one_data(self.url, self.params)
File "/anaconda3/lib/python3.7/site-packages/pandas_datareader/base.py", line 86, in _read_one_data
out = self._get_response(url, params=params).json()
File "/anaconda3/lib/python3.7/site-packages/pandas_datareader/base.py", line 136, in _get_response
last_response_text = response.text.encode(response.encoding)
TypeError: encode() argument 1 must be str, not None
The exact code was working fine until recently. I wonder what changed, and what I can do to correct it.
Most APIs listed on the pandas_datareader documentation have been deprecated and are no longer effective through the pandas_datareader framework (Yahoo, Google, etc).
However, Tiingo works just fine, at least for now.
To use Tiingo API, you'll first need to sign up for a free account (or paid if you want premium features). You can do that here. After activating your Tiingo account, you'll receive an API key which you can use to retrieve stock historical data with pandas_datareader (find details here).
From https://iextrading.com/developer/docs/#stocks
"On June 1, 2019, IEX Group removed all non-IEX data, and certain functionality, according to the schedule. IEX Cloud, a non-Exchange platform, will continue to provide access to third-party data sources."
Looks like you'll need access and secret keys to call their API. I'm looking into this for my python app stock_quote that hit this issue.
You can use the efficient Python library for Yahoo Finance, yfinance (GitHub link).
You can also find example codes here and here.
I'm trying to fetch some plain text from a WARC dataset (yahoo!webscope L2), and keep meeting ValueError: Search for pattern exhausted when using load() function in python3 module warcat. Have tried some random WARC example files and everything worked well.
The dataset did ask for a further license to commit(and then a password would be provide, according to the readme file;do WARC files come with passwords?) but for now I'm not equipped to send a fax.
I also checked out warcat source code, and found that the ValueError would be raised when file_obj.read(size) is False. It seems making no sense to me so I'm asking here...
The code:
>>> import warcat
>>> import warcat.model
>>> warc = warcat.model.WARC()
>>> warc.load('ydata-embedded-metadata-v1_0.warc')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/site-packages/warcat/model/warc.py", line 32, in load
self.read_file_object(f)
File "/usr/local/lib/python3.4/site-packages/warcat/model/warc.py", line 39, in read_file_object
record, has_more = self.read_record(file_object)
File "/usr/local/lib/python3.4/site-packages/warcat/model/warc.py", line 75, in read_record
check_block_length=check_block_length)
File "/usr/local/lib/python3.4/site-packages/warcat/model/record.py", line 59, in load
inclusive=True)
File "/usr/local/lib/python3.4/site-packages/warcat/util.py", line 66, in find_file_pattern
raise ValueError('Search for pattern exhausted')
ValueError: Search for pattern exhausted
Thanks in advance.
I'm getting an occasional error when trying to fetch a list of worksheets from gdata. This does not happen for all spreadsheets, but will consistently happen to the same spreadsheet for a period of several days to weeks. I suspected permissions, but was unable to find any special permissions for the spreadsheets that cause the error. I'm using OAuth2, gdata 2.0.18, and Python 2.6.8.
Traceback (most recent call last):
File "/mnt/shared_from_host/snake/base/fetchers/google_spreadsheet/common.py", line 176, in get_worksheet_list
feed = client.get_worksheets(spreadsheet_id)
File "/home/ubuntu/.virtualenvs/snakeenv/lib/python2.6/site-packages/gdata/spreadsheets/client.py", line 108, in get_worksheets
**kwargs)
File "/home/ubuntu/.virtualenvs/snakeenv/lib/python2.6/site-packages/gdata/client.py", line 640, in get_feed
**kwargs)
File "/home/ubuntu/.virtualenvs/snakeenv/lib/python2.6/site-packages/gdata/client.py", line 278, in request
version=get_xml_version(self.api_version))
File "/home/ubuntu/.virtualenvs/snakeenv/lib/python2.6/site-packages/atom/core.py", line 520, in parse
tree = ElementTree.fromstring(xml_string)
File "<string>", line 86, in XML
SyntaxError: no element found: line 1, column 0
This seems to be from the request getting an empty string as the response.
Does anybody have any idea on why this might not work, or troubleshooting ideas? Thanks.
I am new to python. I am trying to use track_from_file method in pyechonest to create a track object. This is the code I wrote:
from pyechonest import config
from pyechonest.track import track_from_file
config.ECHO_NEST_API_KEY = "KRZG4XOVUQRKI45DP"
f = open("ShayneWard-NoPromises.mp3")
t = track_from_file(f, 'mp3')
But this is not working. I got an EchoNestIOError. This is the full error Traceback that i got.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/pyechonest/track.py", line 243, in track_from_file
File "build/bdist.linux-x86_64/egg/pyechonest/track.py", line 331, in track_from_md5
File "build/bdist.linux-x86_64/egg/pyechonest/track.py", line 209, in _profile
File "build/bdist.linux-x86_64/egg/pyechonest/util.py", line 257, in callm pyechonest.util.
EchoNestIOError: Echo Nest Unknown Error
Can anyone tell me what have I done wrong?
I finally figured it out. It seems that the upload does not take place through the proxy server of my university network which uses NAT.
Has anybody had any recent success with accessing the Crowd SOAP API via the Suds Python library?
I've found a few people successfully doing it in the past but Atlassian seems to have changed their WSDL since then to make the existing advice not entirely helpful.
Below is the simplest example I've been trying:
from suds.client import Client
url = 'https://crowd.hugeinc.com/services/SecurityServer?wsdl'
client = Client(url)
Unfortunately that generates the following error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Users/soconnor/.virtualenvs/hugeface/lib/python2.6/site-packages/suds/client.py", line 116, in __init__
sd = ServiceDefinition(self.wsdl, s)
File "/Users/soconnor/.virtualenvs/hugeface/lib/python2.6/site-packages/suds/servicedefinition.py", line 58, in __init__
self.paramtypes()
File "/Users/soconnor/.virtualenvs/hugeface/lib/python2.6/site-packages/suds/servicedefinition.py", line 137, in paramtypes
item = (pd[1], pd[1].resolve())
File "/Users/soconnor/.virtualenvs/hugeface/lib/python2.6/site-packages/suds/xsd/sxbasic.py", line 63, in resolve
raise TypeNotFound(qref)
TypeNotFound: Type not found: '(AuthenticatedToken, http://authentication.integration.crowd.atlassian.com, )'
I've tried to both binding and doctors to fix this problem to no avail. Neither approach resulted in any change. Any further recommendations or suggestions would be incredibly helpful.
There is a patch for the Crowd WSDL here:
http://jira.atlassian.com/browse/CWD-159