腾讯股票API相关章节
腾讯股票接口API(1)——根据股票代码获取详情腾讯股票接口API(2)——根据股票代码获取K线数据腾讯股票接口API(3)——根据股票代码获取分时数据腾讯股票接口API(4)——计算分时线平均值补充:根据股票代码特征分类
一、使用腾讯股票API:
参考:腾讯股票API获取上证指数
// 1. https://web./appstock/app/fqkline/get 固定访问链接// 2. param=代码,日k,开始日期,结束日期,获取多少个交易日,前复权// 2.1 usAAPL.OQ 股票代码,这里是us是美股,AAPL是苹果,“.OQ”是美股拼接后缀,其他不需要拼接// 2.2 500代表获取多少个交易日,500实际查出来的是501条数据,多一条// 2.3 qfq前复权// 美股,苹果【usAAPL】,需要拼接“.OQ”https://web./appstock/app/fqkline/get?param=usAAPL.OQ,day,-3-1,-3-1,500,qfq// 上海,茅台【sh600519】,不需要拼接“.OQ”https://web./appstock/app/fqkline/get?param=sh600519,day,-3-1,-3-1,500,qfq// 港股,小米【hk01810】,不需要拼接“.OQ”https://web./appstock/app/fqkline/get?param=hk01810,day,-3-1,-3-1,500,qfq
返回标准的json格式数据,没有任何前缀后缀等信息,推荐使用:
{"code":0,"msg":"","data":{"usAAPL.OQ":{"day":[["-02-26","122.590","121.260","124.850","121.200","164560394.000"],["-03-01","123.750","127.790","127.930","122.790","116307892.000"]],"qt":{"usAAPL.OQ":["delay","\u82f9\u679c","AAPL.OQ","121.09","116.36","119.03","129525780","14220762302068.5","14219341089103.5","121.02","12","0","0","0","0","0","0","0","0","121.09","13","0","0","0","0","0","0","0","0","","-03-09 16:00:02","4.73","4.06","122.06","118.79","USD","129525780","15640486261","0.77","32.64","","36.92","","2.81","","20327.86604","Apple Inc","3.71","144.89","52.33","-1","30.70","0.68","20327.86604","-8.60","","SHARE","82.09","18.41",""],"market":["-03-10 16:56:01|HK_close_\u5df2\u6536\u76d8|SH_close_\u5df2\u6536\u76d8|SZ_close_\u5df2\u6536\u76d8|US_close_\u672a\u5f00\u76d8|SQ_close_\u5df2\u4f11\u5e02|DS_close_\u5df2\u4f11\u5e02|ZS_close_\u5df2\u4f11\u5e02|NEWSH_close_\u5df2\u6536\u76d8|NEWSZ_close_\u5df2\u6536\u76d8|NEWHK_close_\u5df2\u6536\u76d8|NEWUS_close_\u672a\u5f00\u76d8|REPO_close_\u5df2\u6536\u76d8|UK_open_\u4ea4\u6613\u4e2d|KCB_close_\u5df2\u6536\u76d8|IT_open_\u4ea4\u6613\u4e2d|MY_open_\u6536\u5e02\u7ade\u4ef7\u4e2d|EU_open_\u4ea4\u6613\u4e2d|AH_close_\u5df2\u6536\u76d8|DE_open_\u4ea4\u6613\u4e2d|JW_close_\u5df2\u6536\u76d8|CYB_close_\u5df2\u6536\u76d8|USA_close_\u672a\u5f00\u76d8|USB_close_\u672a\u5f00\u76d8"]},"pandata":{"last":-1,"volume":"","pct":"","netchange":"","time":"","tag":"","season":"EST"},"prec":"120.990","version":"12"}}}
其中K线数据对应字段如下:
["-03-10",// 0-交易日"1977.000",// 1-开盘价"1970.010",// 2-收盘价"1999.870",// 3-最高价"1967.000",// 4-最低价"51172.000"// 5-总手]
二、另一个接口:
参考:股票历史数据
// 日K 后复权// 320代表查询几天的历史数据 初步推断 1年为320 两年为640,这里填几条就是几条数据,和上面不同。// 股票代码和上面方式一样,美股需要拼接“.OQ”https://web./appstock/app/fqkline/get?_var=kline_dayhfq¶m=sh600519,day,,,320,hfq&r=0.9860043111257255
这个接口返回来的数据不是标准的json格式,有拼接信息(前面有“kline_dayhfq=”),需要自己处理一下,为了节省空间,结果取了2条:
kline_dayhfq={"code":0,"msg":"","data":{"usAAPL.OQ":{"day":[["-03-08","120.930","116.360","121.000","116.210","154376610.000"],["-03-09","119.030","121.090","122.060","118.790","129525780.000"]],"qt":{"usAAPL.OQ":["delay","\u82f9\u679c","AAPL.OQ","121.09","116.36","119.03","129525780","14220762302068.5","14219341089103.5","121.02","12","0","0","0","0","0","0","0","0","121.09","13","0","0","0","0","0","0","0","0","","-03-09 16:00:02","4.73","4.06","122.06","118.79","USD","129525780","15640486261","0.77","32.64","","36.92","","2.81","","20327.86604","Apple Inc","3.71","144.89","52.33","-1","30.70","0.68","20327.86604","-8.60","","SHARE","82.09","18.41",""],"market":["-03-10 17:12:02|HK_close_\u5df2\u6536\u76d8|SH_close_\u5df2\u6536\u76d8|SZ_close_\u5df2\u6536\u76d8|US_close_\u672a\u5f00\u76d8|SQ_close_\u5df2\u4f11\u5e02|DS_close_\u5df2\u4f11\u5e02|ZS_close_\u5df2\u4f11\u5e02|NEWSH_close_\u5df2\u6536\u76d8|NEWSZ_close_\u5df2\u6536\u76d8|NEWHK_close_\u5df2\u6536\u76d8|NEWUS_close_\u672a\u5f00\u76d8|REPO_close_\u5df2\u6536\u76d8|UK_open_\u4ea4\u6613\u4e2d|KCB_close_\u5df2\u6536\u76d8|IT_open_\u4ea4\u6613\u4e2d|MY_close_\u5df2\u6536\u76d8|EU_open_\u4ea4\u6613\u4e2d|AH_close_\u5df2\u6536\u76d8|DE_open_\u4ea4\u6613\u4e2d|JW_close_\u5df2\u6536\u76d8|CYB_close_\u5df2\u6536\u76d8|USA_close_\u672a\u5f00\u76d8|USB_open_\u76d8\u524d\u4ea4\u6613"]},"pandata":{"last":"120.21","volume":"116058","pct":"-0.72","netchange":"-0.88","time":"-03-10 04:12:32","tag":"before","season":"EST"},"prec":"121.420","version":"12"}}}
PS补充:
还有一些接口博客做参考,来来回回找不到点新鲜的东西,都是那么几篇复制粘贴来的,有些接口已经被调整后无法获取数据:
股票接口获取A股行情数据方法网页股票期货历史数据(API)