Get Data source of stock data

Get stock data sources are: Data supermarkets, Yahoo, Sina, Google, and hearing, Sohu, ChinaStockWebService, Eastern wealth clients, Securities Star, NetEase.

Data supermarkets

Updated May 6, 2016. According to the supermarket recently frequent, unrestricted access to relevant data, eliminating the need to use other means to obtain reptiles, which not only saves a great deal of resources, but also conducive to traverse data.

The specific procedure is omitted, listed a list of sites related to these developers can invoke methods on their own website.

Aggregate data https://www.juhe.cn/

Baidu API data http://apistore.baidu.com/

Birthplace http://www.finndy.com/

Here I recommend using aggregate data, followed with Baidu API to use.

Yahoo

Cons: Some American holidays will be a shortage of data; the number of calls should not exceed 200 beats per minute, otherwise they will be warned and blocked IP addresses; custom columns can only get US stocks data acquisition method.

Pros: most data standardization, market data can be acquired in other countries; the return data type can be customized combination.

Method 1: http:? //Table.finance.yahoo.com/table.csv s = ticker

Return results: CSV format file, returns the column followed by "date, open, high, low, close, volume, complex right price."

Its stock symbol to be marked at the end of your market, the Shanghai Composite Index above the ticker symbol 600000.ss, Shenzhen Component Index was 399001.sz.

Method 2: http:? //Finance.yahoo.com/d/quotes.csv s = ticker & f = [custom column]

Return: CSV format, data of the last trading day, based on the set of custom column column returns.

For example: http: //finance.yahoo.com/d/quotes.csv s = TWTR & f = nt1, return TWTR stock name and the last trading time?.

Method 3: http:? //Quote.yahoo.com/d/quotes.csv s = ticker & f = [custom column]

2 and similar methods.

Customize columns

Market code and description

China Stock webservice

缺点:不稳定,经常出现维护停止服务;只能获取当前行情和历史走势图。

优点:国内数据提供商,以XML响应,速度较快。

方法参考:http://www.webxml.com.cn/WebServices/ChinaStockWebService.asmx

东方财富客户端

缺点:手动操作导出;没有历史数据。

优点:数据全面,速度较快。

方法:通过东方财富网客户端自带的功能,导出数据。

相对于其他获取方式,这种获取速度非常快,出错率非常低,而且数据非常全面,如果定期整理可以作为非常有效的数据使用。

新浪

缺点:历史股价数据不够完整,只能获取最近1023个数据节点。

优点:速度非常快;可以获取行情图片;返回JSON,容易处理;可以获取历史的分价图数据和分时买卖交易列。

方法1:HTTP://HQ.SINAJS.CN/LIST=[股票代码]

返回结果:JSON实时数据,以逗号隔开相关数据,数据依次是“股票名称、今日开盘价、昨日收盘价、当前价格、今日最高价、今日最低价、竞买价、竞卖价、成交股数、成交金额、买1手、买1报价、买2手、买2报价、…、买5报价、…、卖5报价、日期、时间”。

获取当前的股票行情,如http://hq.sinajs.cn/list=sh601006,注意新浪区分沪深是以sh和sz区分。

方法2:获取各个时间段行情图。

查看日K线图:http://image.sinajs.cn/newchart/daily/n/sh601006.gif分时线的查询:http://image.sinajs.cn/newchart/min/n/sh000001.gif日K线查询:http://image.sinajs.cn/newchart/daily/n/sh000001.gif周K线查询:http://image.sinajs.cn/newchart/weekly/n/sh000001.gif月K线查询:http://image.sinajs.cn/newchart/monthly/n/sh000001.gif

方法3:http://money.finance.sina.com.cn/quotes_service/api/json_v2.php/CN_MarketData.getKLineData?symbol=[市场][股票代码]&scale=[周期]&ma=no&datalen=[长度]

返回结果:获取5、10、30、60分钟JSON数据;day日期、open开盘价、high最高价、low最低价、close收盘价、volume成交量;向前复权的数据。

注意,最多只能获取最近的1023个数据节点。

例如,http://money.finance.sina.com.cn/quotes_service/api/json_v2.php/CN_MarketData.getKLineData?symbol=sz002095&scale=60&ma=no&datalen=1023,获取深圳市场002095股票的60分钟数据,获取最近的1023个节点。

方法4:http://finance.sina.com.cn/realstock/company/[市场][股票代码]/[复权].js?d=[日期]

[复权]:qianfuquan-前复权;houfuquan-后复权。

返回结果:股票日期的股价JSON数据。

例如,http://finance.sina.com.cn/realstock/company/sz002095/qianfuquan.js?d=2015-06-16,获取深圳市场002095股票的前复权2015-06-16的数据。

注意,无法获取未复权的数据。

注意,需要对返回数据进行处理才能使用,新浪会在末尾加入注释语句,打乱日期数据,key值需要自行加入双引号,否则无法解析JSON。

注意,由于新浪的周线和月线数据,是以股票日线所有数据直接计算得到的,所以无法直接通过API获取周线和月线数据,需要自行处理。

方法5:http://market.finance.sina.com.cn/downxls.php?date=[日期]&symbol=[市场][股票代码]

返回数据:XLS文件;股票历史成交明细。

例如,http://market.finance.sina.com.cn/downxls.php?date=2015-06-15&symbol=sz002095,获取2015-06-15日期的深圳市长002095数据。

方法6:http://market.finance.sina.com.cn/pricehis.php?symbol=[市场][股票代码]&startdate=[开始日期]&enddate=[结束日期]

返回数据:HTML文本;指定日期范围内的股票分价表。

例如,http://market.finance.sina.com.cn/pricehis.php?symbol=sh600900&startdate=2011-08-17&enddate=2011-08-19,获取上证600900股票2011-08-17到2011-08-19日期的分价数据。

和讯

(待续)

Google

Google数据其实是从新浪获取的,所以可以优先考虑从新浪获取,如果喜欢google的API,再考虑。

优点:数据可靠。

缺点:历史数据只能通过分解HTML页面获取;国外数据源速度慢。

方法1:从股票历史数据中获取相关数据。

方法2:https://www.google.com.hk/finance/getprices?q=[股票代码]&x=[市场]&i=[间隔]&p=[周期]

例如,https://www.google.com.hk/finance/getprices?q=002673&x=SHE&i=1800&p=30d,意思就是获取上证002673的股票,周期为30天,间隔1800。

搜狐

优点:JSON数据结果容易处理;获取速度快。

缺点:每次只能获取100个节点的数据;API经常变动。

方法1:http://q.stock.sohu.com/hisHq?code=[股票市场和代码]8&start=[开始日期]&end=[结束日期]&stat=1&order=D&period=d&callback=historySearchHandler&rt=jsonp

返回结果:JSON;时间段内的100个数据节点。

例如,http://q.stock.sohu.com/hisHq?code=cn_300228&start=20130930&end=20131231&stat=1&order=D&period=d&callback=historySearchHandler&rt=jsonp,返回30022股票20130930到20131231时间段内的日线数据。

证券之星

缺点:只能获取80条数据。

优点:国内速度快;JSON返回容易解析。

方法1:HTTP://CQ.SSAJAX.CN/INTERACT/GETTRADEDATA.ASHX?PIC=QLPIC_[股票代码]_[市场]_[周期]

其中股票代码如000001;市场1表示沪,2表示深;周期6表示日,7表示周,8表示月。如:http://cq.ssajax.cn/interact/getTradedata.ashx?pic=qlpic_000001_1_6,获取上证指数的日线行情数据。

返回结果:JSON数据。

方法2:HTTP://CQ.SSAJAX.CN/INTERACT/GETTRADEDATA.ASHX?PIC=QMPIC_600308_1_6_N80

网易财经

优点:速度快;JSON容易处理。

缺点:不能获取分钟线数据。

方法1:http://img1.money.126.net/data/[沪深拼音]/time/today/[股票代码].json

返回结果:当日分时图数据;JSON数据;分时图获取数据依次是count节点数量、symbol股票代码、name股票名称、data数据,其中数据依次是小时分钟时间、价格、均价、成交量。

注意,沪深拼音为简写hs,以此可以推断出其他市场也可以获取,具体请自行判断研究。

例如,http://img1.money.126.net/data/hs/time/today/1399001.json,返回深证成指当日分时图数据。

方法2:http://img1.money.126.net/data/hs/time/4days/[股票代码].json

返回结果:获取4天分时数据;和上述分时图相似,但数据是连续4天的数据,不包括当天的数据。

方法3:http://img1.money.126.net/data/[沪深拼音]/[是否复权]/day/history/[年份]/[股票代码].json

返回结果:获取日线数据。

其中,是否复权,不复权为kline,复权为klinederc。

例如,http://img1.money.126.net/data/hs/kline/day/history/2015/1399001.json,获取深证成指2015年所有日线数据。

方法4:http://img1.money.126.net/data/[沪深拼音]/[是否复权]/[周期]/times/[股票代码].json

返回结果:获取日线所有时间节点和收盘价。

其中,[是否复权],不复权为kline,复权为klinederc。

其中,[周期],day为日数据,week周数据,month月数据。

例如,http://img1.money.126.net/data/hs/kline/day/times/1399001.json,获取深证成指所有时间节点数据。

方法5:http://quotes.money.163.com/cjmx/[今年年份]/[日期]/[股票代码].xls

返回结果:获取历史成交明细;XLS文件。

注意,只能获取5日内的数据,再之前的数据不会存在。

注意,该方法为网易公开获取数据方法,推荐使用。

例如,http://quotes.money.163.com/cjmx/2015/20150611/0601857.xls,获取0601857股票的2015年6月11日历史成交明细XLS文件。

方法6:http://quotes.money.163.com/service/chddata.html?code=[股票代码]&start=[开始日期]&end=[结束日期]&fields=[自定义列]

返回结果:历史股价及相关情况;CSV文件。

注意,该方法为网易公开方法,推荐使用。

其中,自定义列可定义TCLOSE收盘价 ;HIGH最高价;LOW最低价;TOPEN开盘价;LCLOSE前收盘价;CHG涨跌额;PCHG涨跌幅;TURNOVER换手率;VOTURNOVER成交量;VATURNOVER成交金额;TCAP总市值;MCAP流通市值这些值。

例如,http://quotes.money.163.com/service/chddata.html?code=0601857&start=20071105&end=20150618&fields=TCLOSE;HIGH;LOW;TOPEN;LCLOSE;CHG;PCHG;TURNOVER;VOTURNOVER;VATURNOVER;TCAP;MCAP,获取0601857从2007-11-05到2015-06-18区间的数据。

参考文献

http://www.jarloo.com/yahoo_finance/

http://blog.sina.com.cn/s/blog_54fae2350101c7ye.html

http://blog.sina.com.cn/s/blog_7ed3ed3d0102v5y7.html

http://blog.sina.com.cn/s/articlelist_2127818045_10_1.html

http://www.webxml.com.cn/WebServices/ChinaStockWebService.asmx

http://blog.sina.com.cn/s/blog_7ed3ed3d010146ti.html

http://www.cnblogs.com/me115/archive/2011/05/09/2040826.html

Guess you like

Origin www.cnblogs.com/onetwo/p/12106848.html
Recommended