pandas' datareader from yahoo finance is not working at the moment because yahoo changed the url pandas used to get the data from, yahoo changed it from 'http://ichart.yahoo.com/table.csv?...
to 'http://ichart.finance.yahoo.com/table.csv?...
.
The error I'm getting is
IOError: after 3 tries, Yahoo! did not return a 200 for url '...'
So, I tried editing data.py, according to this fix, but still no go. I'm using pandas 0.12, with Enthought Canopy. Do I need to compile something..? is there anything more required?
in (assuming that the user is using Enthought Canopy for Windows, and it's stored in the default location):
C:\Users\...\AppData\Local\Enthought\Canopy\System\Lib\site-packages\pandas\io
change yahoo_URL = 'http://ichart.yahoo.com/table.csv?'
to yahoo_URL = 'http://ichart.finance.yahoo.com/table.csv?'
Save and restart Canopy
Here is a current, working version of using Pandas datareader to fetch yahoo quotes:
from pandas.io.data import DataReader
from datetime import datetime
amd = DataReader('AMD', 'yahoo', datetime(2015,7,1), datetime(2015,7,1))
print(amd['Adj Close'][0])
Keep in mind that the returned dataset is an array. You need to enumerate said array to get the data, either by specifying your index, or with a for loop
The other keys you can use are Open, Close, High, Low, and Volume.
I have Pandas v 0.16.2
I hope this helps!
来源:https://stackoverflow.com/questions/20870956/fixing-pandas-datareader-from-yahoo-finance-with-enthought-canopy