python - How can get ' USDJPY'(currency rates) with pandas and yahoo finance? -
i learning , using pandas , python.
today, trying make fx rate table, got trouble getting pricess of 'usdjpy'.
when prices of 'eur/usd', code this.
eur = web.datareader('eurusd=x','yahoo')['adj close']
it works.
but when wrote
jpy = web.datareader('usdjpy=x','yahoo')['adj close']
the error message comes this:
--------------------------------------------------------------------------- ioerror traceback (most recent call last) in () ----> 1 jpy = web.datareader('usdjpy=x','yahoo')['adj close']
c:\anaconda\lib\site-packages\pandas\io\data.pyc in datareader(name, data_source, start, end, retry_count, pause) 70 return get_data_yahoo(symbols=name, start=start, end=end, 71 adjust_price=false, chunksize=25, ---> 72 retry_count=retry_count, pause=pause) 73 elif data_source == "google": 74 return get_data_google(symbols=name, start=start, end=end,
c:\anaconda\lib\site-packages\pandas\io\data.pyc in get_data_yahoo(symbols, start, end, retry_count, pause, adjust_price, ret_index, chunksize, name) 388 """ 389 return _get_data_from(symbols, start, end, retry_count, pause, --> 390 adjust_price, ret_index, chunksize, 'yahoo', name) 391 392
c:\anaconda\lib\site-packages\pandas\io\data.pyc in _get_data_from(symbols, start, end, retry_count, pause, adjust_price, ret_index, chunksize, source, name) 334 # if single symbol, (e.g., 'goog') 335 if isinstance(symbols, (basestring, int)): --> 336 hist_data = src_fn(symbols, start, end, retry_count, pause) 337 # or multiple symbols, (e.g., ['goog', 'aapl', 'msft']) 338 elif isinstance(symbols, dataframe):
c:\anaconda\lib\site-packages\pandas\io\data.pyc in _get_hist_yahoo(sym, start, end, retry_count, pause) 188 '&g=d' + 189 '&ignore=.csv') --> 190 return _retry_read_url(url, retry_count, pause, 'yahoo!') 191 192
c:\anaconda\lib\site-packages\pandas\io\data.pyc in _retry_read_url(url, retry_count, pause, name) 167 168 raise ioerror("after %d tries, %s did not " --> 169 "return 200 url %r" % (retry_count, name, url)) 170 171
ioerror: after 3 tries, yahoo! did not return 200 url 'http://ichart.yahoo.com/table.csv?s=usdjpy=x&a=0&b=1&c=2010&d=1&e=1&f=2014&g=d&ignore=.csv'
other currencies 'gbpusd' have same problem.
can solve problem?
do have idea of getting 'usdjpy' yahoo or google???
yahoo finance doesn't provide historical data on exchange rates (i.e. there's no "historical prices" link in top left of page there stocks, indices, etc...)
you can use fred (federal reserve of st. louis data) these exchange rates...
import pandas.io.data web jpy = web.datareader('dexjpus', 'fred')
or more direct way...
jpy = web.get_data_fred('dexjpus')
a list of of exchange rate fred has daily data can found here: http://research.stlouisfed.org/fred2/categories/94
Comments
Post a Comment