实时股票数据接口大全24页.docx

上传人:b****5 文档编号:7636806 上传时间:2023-05-11 格式:DOCX 页数:13 大小:27.17KB
下载 相关 举报
实时股票数据接口大全24页.docx_第1页
第1页 / 共13页
实时股票数据接口大全24页.docx_第2页
第2页 / 共13页
实时股票数据接口大全24页.docx_第3页
第3页 / 共13页
实时股票数据接口大全24页.docx_第4页
第4页 / 共13页
实时股票数据接口大全24页.docx_第5页
第5页 / 共13页
实时股票数据接口大全24页.docx_第6页
第6页 / 共13页
实时股票数据接口大全24页.docx_第7页
第7页 / 共13页
实时股票数据接口大全24页.docx_第8页
第8页 / 共13页
实时股票数据接口大全24页.docx_第9页
第9页 / 共13页
实时股票数据接口大全24页.docx_第10页
第10页 / 共13页
实时股票数据接口大全24页.docx_第11页
第11页 / 共13页
实时股票数据接口大全24页.docx_第12页
第12页 / 共13页
实时股票数据接口大全24页.docx_第13页
第13页 / 共13页
亲,该文档总共13页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

实时股票数据接口大全24页.docx

《实时股票数据接口大全24页.docx》由会员分享,可在线阅读,更多相关《实时股票数据接口大全24页.docx(13页珍藏版)》请在冰点文库上搜索。

实时股票数据接口大全24页.docx

实时股票数据接口大全24页

表單的頂端

披星戴月

C++博客   首页   新随笔   联系   聚合

   管理

posts-34, comments-5, trackbacks-0

实时股票数据接口大全[转]

实时股票数据接口大全

股票数据的获取目前有如下两种方法可以获取:

1.http/javascript接口取数据

2.web-service接口

1.http/javascript接口取数据

1.1Sina股票数据接口

以大秦铁路(股票代码:

601006)为例,如果要获取它的最新行情,只需访问新浪的股票数据

接口:

http:

//hq.sinajs/list=sh601006

这个url会返回一串文本,例如:

varhq_str_sh601006="大秦铁路,27.55,27.25,26.91,27.55,26.20,26.91,26.92,

22114263,589824680,4695,26.91,57590,26.90,14700,26.89,14300,

 26.88,15100,26.87,3100,26.92,8900,26.93,14230,26.94,25150,26.95,15220,26.96,2008-01-11,15:

05:

32";

这个字符串由许多数据拼接在一起,不同含义的数据用逗号隔开了,按照程序员的思路,顺序号从0开始。

0:

”大秦铁路”,股票名字;

1:

”27.55″,今日开盘价;

2:

”27.25″,昨日收盘价;

3:

”26.91″,当前价格;

4:

”27.55″,今日最高价;

5:

”26.20″,今日最低价;

6:

”26.91″,竞买价,即“买一”报价;

7:

”26.92″,竞卖价,即“卖一”报价;

8:

”22114263″,成交的股票数,由于股票交易以一百股为基本单位,所以在使用时,通常把该值除以一百;

9:

”589824680″,成交金额,单位为“元”,为了一目了然,通常以“万元”为成交金额的单位,所以通常把该值除以一万;

10:

”4695″,“买一”申请4695股,即47手;

11:

”26.91″,“买一”报价;

12:

”57590″,“买二”

13:

”26.90″,“买二”

14:

”14700″,“买三”

15:

”26.89″,“买三”

16:

”14300″,“买四”

17:

”26.88″,“买四”

18:

”15100″,“买五”

19:

”26.87″,“买五”

20:

”3100″,“卖一”申报3100股,即31手;

21:

”26.92″,“卖一”报价

(22,23),(24,25),(26,27),(28,29)分别为“卖二”至“卖四的情况”

30:

”2008-01-11″,日期;

31:

”15:

05:

32″,时间;

一个简单的JavaScript应用例子:

   varelements=hq_str_sh601006.split(",");

   document.write("currentprice:

"+elements[3]);

这段代码输出大秦铁路(股票代码:

601006)的当前股价

currentprice:

14.20

如果你要同时查询多个股票,那么在URL最后加上一个逗号,再加上股票代码就可以了;比如你要一次查询大秦铁路(601006)和大同煤业(601001)的行情,就这样使用URL:

http:

//hq.sinajs/list=sh601003,sh601001

查询大盘指数,比如查询上证综合指数(000001):

http:

//hq.sinajs/list=s_sh000001

服务器返回的数据为:

varhq_str_s_sh000001="上证指数,3094.668,-128.073,-3.97,436653,5458126";

数据含义分别为:

指数名称,当前点数,当前价格,涨跌率,成交量(手),成交额(万元);

查询深圳成指数:

http:

//hq.sinajs/list=s_sz399001

对于股票的K线图,日线图等的获取可以通过请求http:

//image.sinajs/…./…/*.gif此URL获取,其中*代表股票代码,详见如下:

查看日K线图:

http:

//image.sinajs/newchart/daily/n/sh601006.gif

分时线的查询:

http:

//image.sinajs/newchart/min/n/sh000001.gif

日K线查询:

http:

//image.sinajs/newchart/daily/n/sh000001.gif

周K线查询:

http:

//image.sinajs/newchart/weekly/n/sh000001.gif

月K线查询:

http:

//image.sinajs/newchart/monthly/n/sh000001.gif

1.2Baidu&Google的财经数据

在baidu,google中搜索某只股票代码时,将会在头条显示此股票的相关信息,例如在google搜索601006时,

第一条搜索结果如下图:

通过点击左边的图片我们发现会将此图片链接到sina财经频道上,也就是说google股票数据的获取也是从sina获取。

后经抓包分析,发现google也是采用1.1中介绍的接口。

Baidu的股票数据来自baidu的财经频道

http:

//stock.baidu/

1.3其他方式

除了sina,baidu等网站提供股票信息外,其他网站也有类似的接口。

我们分析了一款论坛上采用的股票插件,

其中有关于实时股票数据获取的介绍,详见如下代码,其中可以看到有些数据来自sina。

以下是ASP示例:

<%

‘==========================

‘file:

stock_getdata.asp

‘version:

1.0.0

‘copyright(c)czieallrightsreserved.

‘web:

http:

//czie

‘==========================

     functiongethttp(rurl)

          dimxml

          onerrorresumenext

          setxml=server.createobject("Microsoft.XMLHTTP")

          xml.open"get",rurl,false

          xml.send

          ifnotxml.readystate=4ornotxml.status=200orerrthengethttp="":

exitfunction

          gethttp=xml.responsetext

          setxml=nothing

     endfunction

     functiongetstockdata(code)

          ‘0=股票名称,1=开盘价格,2=昨收盘价格,3=当前价格,4=最高价,5=最低价,30,31=更新时间

          dimcheckcode,stockdata,stockdatasplit

          iflen(code)<5thenstockdata="0,0,0,0,0,0,0,0,0,0,0,0":

exitfunction

          checkcode=mid(code,len(code)-5,1)

          ifint(checkcode)<=4then

               stockdata=gethttp("http:

//hq.sinajs/list=sz"&code&"")

               ifnotlen(stockdata)=0thenstockdata=split(stockdata,chr(34))

(1)

          endif

          ifint(checkcode)>=5then

               stockdata=gethttp("http:

//hq.sinajs/list=sh"&code&"")

               ifnotlen(stockdata)=0thenstockdata=split(stockdata,chr(34))

(1)

          endif

          iflen(stockdata)=0then

               stockdata="0,0,0,0,0,0,0,0,0,0,0,0"

          else

              stockdatasplit=split(stockdata,",")         stockdata=""&exstock.checkstr(stockdatasplit(0))&","&stockdatasplit

(1)&","&stockdatasplit

(2)&","&stockdatasplit(3)&","&stockdatasplit(4)&","&stockdatasplit(5)&","&formatdatetime(""&stockdatasplit(30)&""&stockdatasplit(31)&"",0)&""

          endif

          ‘0=股票名称,1=开盘价格,2=昨收盘价格,3=当前价格,4=最高价,5=最低价,6=更新时间

          getstockdata=stockdata

     endfunction

     functiongetstockimg(code)

          dimrndnum,addnum,checkcode,imgsource

          iflen(code)<5thenexitfunction

          addnum=4

          randomize:

rndnum=cint(rnd*addnum)

          selectcaserndnum

               case0

                   getstockimg="http:

//10jqka/curve/kline/?

code="&code&""

                   imgsource="http:

//10jqka"

               case1

                   getstockimg="http:

//stock.jrj/htmdata/KLINE/"&code&".png"

                   imgsource="http:

//stock.jrj"

               case2

                   checkcode=mid(code,len(code)-5,1)

                   ifint(checkcode)<=4then

                        getstockimg="http:

//image.sinajs/newchart/daily/n/sz"&code&".gif"

                   endif

                   ifint(checkcode)>=5then

                        getstockimg="http:

//image.sinajs/newchart/daily/n/sh"&code&".gif"

                   endif

                   imgsource="http:

//finance.sina"

               case3

                   getstockimg="http:

//hq.gazxfe/stockchart/realline.chart?

"&code&"&1003&SZ500330"

                   imgsource="http:

//hq.gazxfe"

               case4

                   getstockimg="http:

//chartse.stockstar/chartserver?

code="&code&""

                   imgsource="http:

//stockstar/"

          endselect

          getstockimg=split(""&getstockimg&"||"&imgsource&"","||")

     endfunction

     functiongetastockimg()

          dimrndnum,addnum,checkcode

          dimgetastockimgb,imgsource

          addnum=6

          randomize:

rndnum=cint(rnd*addnum)

          selectcaserndnum

               case0

                   getastockimg="http:

//202.109.106.1/gifchartse/gif/000001.gif"

                   getastockimgb="http:

//202.109.106.1/gifchartse/gif/399001.gif"

                   imgsource="http:

//stockstar/"

               case1

                   getastockimg="http:

//money.163/special/100.gif?

C39"

                   getastockimgb="http:

//money.163/special/101.gif?

HrS"

                   imgsource="http:

//163"

               case2

                   getastockimg="http:

//10jqka/curve/realtime/index2.php?

code=1a0001&w=180&h=140"

                   getastockimgb="http:

//10jqka/curve/realtime/index2.php?

code=399001&w=180&h=140"

                   imgsource="http:

//10jqka"

               case3

                   getastockimg="http:

//chartlist/stockchart/realline.chart?

1a0001&1002&SZ180140"

                   getastockimgb="http:

//chartlist/stockchart/realline.chart?

399001&1002&SZ180140"

                   imgsource="http:

//chartlist/"

               case4

                   getastockimg="http:

//image.sinajs/newchart/small/ish000001.gif?

1189176558328"

                   getastockimgb="http:

//image.sinajs/newchart/small/isz399001.gif?

1189176558328"

                   imgsource="http:

//sinajs"

               case5

                   getastockimg="http:

//218.1.72.66/cgi/pic/sh/realtime/JA000001164143.png"

                   getastockimgb="http:

//218.1.72.66/cgi/pic/sz/realtime/JA399001164143.png"

                   imgsource="http:

//cnstock/"

               case6

                   getastockimg="http:

//222.73.29.85/img/000001.png"

                   getastockimgb="http:

//222.73.29.85/img/399001.png"

                   imgsource="http:

//eastmoney/"

          endselect

          getastockimg=split(""&getastockimg&"||"&getastockimgb&"||"&imgsource&"","||")

     endfunction

%>

2.web-service接口

2.1CHINAstock的web-service:

http:

//webxml/WebServices/ChinaStockWebService.asmx

中国股票行情数据WEB服务(支持深圳和上海股市的全部基金、债券和股票),数据即时更新。

输出GIF分时走势图、日/周/月K线图、及时行情数据(股票名称、行情时间、最新价、昨收盘、今开盘、涨跌额、最低、最高、涨跌幅、成交量、成交额、竞买价、竞卖价、委比、买一-买五、卖一-卖五)。

此WEB服务提供了如下几个接口:

2.1.1getStockImageByCode

GET股票GIF分时走势图

INput:

theStockCode=股票代号,如:

sh000001

POST/WebServices/ChinaStockWebService.asmxHTTP/1.1

Host:

webxml

Content-Type:

text/xml;charset=utf-8

Content-Length:

length

SOAPAction:

"http:

//WebXml/getStockImageByCode"

xmlversion="1.0"encoding="utf-8"?

>

Envelopexmlns:

xsi="http:

//w3.org/2001/XMLSchema-instance"xmlns:

xsd="http:

//w3.org/2001/XMLSchema"xmlns:

soap="http:

//schemas.xmlsoap.org/soap/envelope/">

 

Body>

   

//WebXml/">

   

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 幼儿教育 > 幼儿读物

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2