Python 熊猫数据阅读器谷歌金融澳大利亚证券交易所

Python 熊猫数据阅读器谷歌金融澳大利亚证券交易所,python,pandas,Python,Pandas,无法使用pandas和新的数据阅读器模块从谷歌金融(google finance)获取澳大利亚证券交易所的报价 每个股票的相关谷歌金融页面将其列为: 联邦银行asx:cba 比拉邦国际澳大利亚证券交易所:bbg等 但是,pandas datareader不以asx:stock_代码(如asx:cba)格式显示股票代码 import pandas from pandas_datareader import data import datetime start = datetime.datetime

无法使用pandas和新的数据阅读器模块从谷歌金融(google finance)获取澳大利亚证券交易所的报价

每个股票的相关谷歌金融页面将其列为: 联邦银行asx:cba 比拉邦国际澳大利亚证券交易所:bbg等

但是,pandas datareader不以asx:stock_代码(如asx:cba)格式显示股票代码

import pandas
from pandas_datareader import data
import datetime
start = datetime.datetime(2016, 5, 27)
end = datetime.datetime(2016, 5, 27)
f = web.DataReader('bbg:asx', 'google', start, end)
pandas datareader功能现在与pandas库本身分离


pandas datareader的google finance模块必须使用什么语法才能在ASX上返回澳大利亚股票的pandas股价数据框?

google finance与Yahoo finance一样,对通过其网站提供的数据进行了一些限制,这些数据可通过
GET
请求获得。您可以看到,对于
ASX:BBG
(以及其他
ASX
股票),
历史价格
网站上缺少
'export to spreadsheet'
选项(例如,与
NASDAQ:GOOGL
相比)

您还可以使用以下方法检查股票代码语法ASX:BBG是否正确:

import pandas as pd
url = 'https://www.google.com/finance/historical'
params = {'q': 'ASX:BBG'}
r = requests.get(url=url, params=params)

pd.read_html(r.content)[2]
这将产生分页结果的前30个:

               0     1     2     3      4       5
0           Date  Open  High   Low  Close  Volume
1   May 27, 2016  1.44  1.46  1.40   1.46       0
2   May 26, 2016  1.36  1.48  1.36   1.46       0
3   May 25, 2016  1.38  1.40  1.36   1.38       0
4   May 24, 2016  1.38  1.39  1.35   1.38       0
5   May 23, 2016  1.33  1.42  1.32   1.42       0
6   May 20, 2016  1.33  1.35  1.32   1.33       0
7   May 19, 2016  1.39  1.40  1.33   1.34       0
8   May 18, 2016  1.38  1.40  1.37   1.39       0
9   May 17, 2016  1.36  1.38  1.36   1.38       0
10  May 16, 2016  1.38  1.38  1.32   1.36       0
11  May 13, 2016  1.36  1.40  1.35   1.38       0
12  May 12, 2016  1.33  1.38  1.33   1.36       0
13  May 11, 2016  1.32  1.39  1.32   1.35       0
14  May 10, 2016  1.26  1.33  1.26   1.32       0
15   May 9, 2016  1.30  1.32  1.27   1.27       0
16   May 6, 2016  1.30  1.32  1.28   1.32       0
17   May 5, 2016  1.31  1.31  1.28   1.30       0
18   May 4, 2016  1.30  1.32  1.26   1.30       0
19   May 3, 2016  1.32  1.33  1.24   1.32       0
20   May 2, 2016  1.36  1.36  1.29   1.33       0
21  Apr 29, 2016  1.32  1.37  1.30   1.36       0
22  Apr 28, 2016  1.35  1.36  1.28   1.30       0
23  Apr 27, 2016  1.38  1.40  1.34   1.36       0
24  Apr 26, 2016  1.40  1.41  1.37   1.38       0
25  Apr 22, 2016  1.42  1.43  1.41   1.42       0
26  Apr 21, 2016  1.44  1.46  1.42   1.42       0
27  Apr 20, 2016  1.48  1.48  1.42   1.46       0
28  Apr 19, 2016  1.48  1.52  1.44   1.46       0
29  Apr 18, 2016  1.50  1.52  1.48   1.48       0
30  Apr 15, 2016  1.50  1.54  1.49   1.50       0
因此,您可以这样修改
params

from datetime import date
params = {'q': 'ASX:BBG', 'startdate':date(2016,4,1), 'enddate':date(2016,5,1)}
要遍历不同的时间段,请执行以下操作:

               0     1     2     3      4       5
0           Date  Open  High   Low  Close  Volume
1   Apr 29, 2016  1.32  1.37  1.30   1.36       0
2   Apr 28, 2016  1.35  1.36  1.28   1.30       0
3   Apr 27, 2016  1.38  1.40  1.34   1.36       0
4   Apr 26, 2016  1.40  1.41  1.37   1.38       0
5   Apr 22, 2016  1.42  1.43  1.41   1.42       0
6   Apr 21, 2016  1.44  1.46  1.42   1.42       0
7   Apr 20, 2016  1.48  1.48  1.42   1.46       0
8   Apr 19, 2016  1.48  1.52  1.44   1.46       0
9   Apr 18, 2016  1.50  1.52  1.48   1.48       0
10  Apr 15, 2016  1.50  1.54  1.49   1.50       0
11  Apr 14, 2016  1.50  1.54  1.48   1.52       0
12  Apr 13, 2016  1.47  1.52  1.47   1.48       0
13  Apr 12, 2016  1.49  1.54  1.46   1.48       0
14  Apr 11, 2016  1.50  1.54  1.46   1.54       0
15   Apr 8, 2016  1.51  1.52  1.48   1.50       0
16   Apr 7, 2016  1.52  1.56  1.52   1.54       0
17   Apr 6, 2016  1.59  1.60  1.51   1.52       0
18   Apr 5, 2016  1.66  1.66  1.58   1.60       0
19   Apr 4, 2016  1.78  1.80  1.66   1.68       0
20   Apr 1, 2016  1.81  1.82  1.76   1.77       0