python模块从google finance api获取实时(无延迟)股票数据
googlefinance的Python项目详细描述
从google finance api获取股票数据的python模块
本模块提供无延迟,实时纽交所股票数据; 纳斯达克。
又一个很棒的模块, yahoo-finance的 数据延迟15分钟,但它提供了方便的api来获取 历史逐日股价数据。
安装
来自带有pip的pypi:
$pip install googlefinance
来自开发回购(需要git)
$git clone https://github.com/hongtaocai/googlefinance.git $cd googlefinance $python setup.py install
用法示例
>>> from googlefinance import getQuotes >>> import json >>> print json.dumps(getQuotes('AAPL'), indent=2) [ { "Index": "NASDAQ", "LastTradeWithCurrency": "129.09", "LastTradeDateTime": "2015-03-02T16:04:29Z", "LastTradePrice": "129.09", "Yield": "1.46", "LastTradeTime": "4:04PM EST", "LastTradeDateTimeLong": "Mar 2, 4:04PM EST", "Dividend": "0.47", "StockSymbol": "AAPL", "ID": "22144" } ] >>> print json.dumps(getQuotes(['AAPL', 'VIE:BKS']), indent=2) [ { "Index": "NASDAQ", "LastTradeWithCurrency": "129.36", "LastTradeDateTime": "2015-03-03T16:02:36Z", "LastTradePrice": "129.36", "LastTradeTime": "4:02PM EST", "LastTradeDateTimeLong": "Mar 3, 4:02PM EST", "StockSymbol": "AAPL", "ID": "22144" }, { "Index": "VIE", "LastTradeWithCurrency": "17.10", "LastTradeDateTime": "2015-03-03T13:30:30Z", "LastTradePrice": "17.10", "LastTradeTime": "1:30PM GMT+1", "LastTradeDateTimeLong": "Mar 3, 1:30PM GMT+1", "StockSymbol": "BKS", "ID": "978541942832888" } ]