如何获得'使用 pandas 和雅虎金融的USDJPY'(汇率)? [英] How can get ' USDJPY'(currency rates) with pandas and yahoo finance?

查看:138
本文介绍了如何获得'使用 pandas 和雅虎金融的USDJPY'(汇率)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习和使用熊猫和python.

I am learning and using the pandas and python.

今天,我正在尝试制作汇率表, 但是我在获取'USDJPY'的价格时遇到了麻烦.

Today, I am trying to make a fx rate table, but I got a trouble with getting the pricess of 'USDJPY'.

当我得到'EUR/USD'的价格时,我会像这样编码.

When I get a prices of 'EUR/USD', i code like this.

eur = web.DataReader('EURUSD=X','yahoo')['Adj Close']

有效.

但是当我写信

jpy = web.DataReader('USDJPY=X','yahoo')['Adj Close']

错误消息如下:

--------------------------------------------------- ---------------------------- IOError Traceback(最近的呼叫 最后)在() ----> 1个jpy = web.DataReader('USDJPY = X','yahoo')['Adj Close']

--------------------------------------------------------------------------- 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(name, data_source,开始,结束,重试计数,暂停) 70 return get_data_yahoo(symbols = name,start = start,end = end, 71 Adjust_price = False,chunksize = 25, ---> 72 retry_count = retry_count,暂停=暂停) 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 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在 get_data_yahoo(符号,开始,结束,retry_count,暂停,adjust_price, ret_index,chunksize,名称) 388" 389 return _get_data_from(symbols,start,end,retry_count,pause, -> 390 Adjust_price,ret_index,chunksize,'yahoo',名称) 391 392

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在 _get_data_from(符号,开始,结束,retry_count,暂停,adjust_price,ret_index,chunksize,源,名称) 334#如果是单个符号(例如'GOOG') 第335章,你是我的老公 -> 336 hist_data = src_fn(符号,开始,结束,重试计数,暂停) 337#或多个符号(例如['GOOG','AAPL','MSFT']) 338 elif isinstance(symbols,DataFrame):

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 a 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在 _get_hist_yahoo(符号,开始,结束,重试计数,暂停) 188'& g = d'+ 189'& ignore = .csv') -> 190 return _retry_read_url(URL,retry_count,暂停,'Yahoo!') 191 192

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在 _retry_read_url(URL,retry_count,暂停,名称) 167 168提高IOError(%d尝试后,%s没有" -> 169为URL%r返回200"%(retry_count,名称,URL) 170 171

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 a 200 for url %r" % (retry_count, name, url)) 170 171

IOError:尝试3次后,Yahoo!没有为网址返回200 '

IOError: after 3 tries, Yahoo! did not return a 200 for 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'

"GBPUSD"等其他货币也有相同的问题.

Other currencies like 'GBPUSD' also have same problem.

您能解决这个问题吗?

您是否有从Yahoo或google获取"USDJPY"的想法?

Do you have any idea of getting 'USDJPY' from yahoo or google???

推荐答案

Yahoo Finance不提供汇率的历史数据(即页面左上方没有历史价格"链接,就像股票一样) ,索引等...)

Yahoo Finance doesn't provide historical data on exchange rates (i.e. there's no "Historical Prices" link in the top left of the page like there would be for stocks, indices, etc...)

您可以使用FRED(圣路易斯联邦储备银行数据)获取这些汇率...

You can use FRED (Federal Reserve of St. Louis data) to get these exchange rates...

import pandas.io.data as web

jpy = web.DataReader('DEXJPUS', 'fred')

更新:已移动熊猫数据读取器

UPDATE: hase moved the pandas-datareader

from pandas_datareader import data
jpy = data.DataReader('DEXJPUS', 'fred')

或更直接的方法...

or the more direct way...

jpy = web.get_data_fred('DEXJPUS')

FRED每天都有其汇率的所有汇率的列表可以在这里找到: http://research.stlouisfed.org/fred2/categories/94

A list of all of the exchange rate that FRED has daily data for can be found here: http://research.stlouisfed.org/fred2/categories/94

这篇关于如何获得'使用 pandas 和雅虎金融的USDJPY'(汇率)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆