首页 > 编程知识 正文

股票行情数据接口,新浪股票接口1秒2次会封吗

时间:2023-05-06 01:55:02 阅读:55742 作者:1619

这两天,创建了调用新浪股票接口获取实时和历史股票数据的APP应用。 新浪没有公开关于其界面的官方文档,因此在新浪股票界面的使用方面通过各种百度存在很多差距,但大家几乎都是转载或直接复制的。 我们详细讨论了实时数据的获取,但缺乏获取历史数据的方法。 关于实时数据的获取,请访问这里的博客。 实时股票数据接口经过不懈努力,发现了腾讯股票接口、和信网股票接口、新浪股票接口、雪人股票数据、网络股票数据关于如何获取新浪股票历史数据

最近二十天左右的每五分钟数据http://money.finance.Sina.com.cn/quotes _ service/API/JSON _ v2.PHP/cn _ market data.getklinedata symbol=SZ 000001 scale=5ma=5datalen=1023 (参数:股票编号、分钟间隔(5、15、30、60 )、平均值) )

获取的数据为日期、初始值、最高值、最低价、收盘价、成交量等json数组。

获取的数据有很多。 然后,根据自己的需要进行分析。 我需要的是每天的收盘价,股市工作日下午3点收盘,所以只要找到每天下午3点的数据进行过滤就可以了。 1、新建历史数据对象类。 publicclasshistorymodel {公共字符串日; 公共字符串关闭; publichistorymodel (字符串日期,字符串关闭) { this.day=day; this.close=close; ) 2、新股票的多次历史数据类(与前一个不同的是这里包含了所有的历史数据。 参数包括股票名称、代码、当前价格、历史数据) Publicclasshistorymodels ) Publicstringname; 公共字符串代码; 公共字符串新; 公共列表列表; publichistorymodels (字符串名称,字符串代码,字符串now,listhistorymodellist (this.name=name; this.code=代码; this.now=now; this.list=list; }

3、将需要查询的股票代码带入url,通过HTTP请求json数据。 我在这里使用的Volley要求的是:

其中,过滤时间点小于15:00:00的数据,将List组合相乘后,所有赋值在一个历史模型中存储股票信息和股票的所有历史数据。

//instantiatetherequestqueue.requestqueue=volley.newrequestqueue (home.context ); string URL1=' http://money.finance.Sina.com.cn/quotes _ service/API/JSON _ v2.PHP/cn _ market data.getklilis //requestastringresponsefromtheprovidedurl.stringrequeststringrequest1=new string request (request.method.get, URL1new response.listenerstring ((overridepublicvoidonresponse ) stringresponse ) ) listhistorymodelhistorylist=convert ) listhistorymodelhistorylist2=new ArrayList (; 历史列表!=null(for ) intj=0; j historyList.size (; j ) (if ) historylist.get ) j ).day.split ) (1).equals ) (15336000:00 ) ) historylist2.add ) ) history list historymodelsmodel=newhistorymodels (home.mychoicemodellist.get (ii ).name,home.mychoicemodellist.get ) ) hois CLL list.add (模型; 消息消息msg=new消息(; msg.what=0x002; Handler.sendmessage(msg; },new response.error listener { @ overridepublicvoidonerrorresponse { } }; queue.add (字符串请求1;

4、其中json数据的处理,即从json转换为数据对象的方法如下: /** Json转换通用型*/publicstatictconvert (stringjsonstring,Type cls ) { T t=null; try { if (JSON字符串!=空! jsonString.equals (' ' ) { Gson gson=new Gson; t=gson.from JSON (JSON字符串,cls ); }catch(exceptione ) { e.printStackTrace ); }返回t; }虽然这里没有提到股票的实时数据,但是正如开头连接的博客所看到的那样,写得很详细。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。