matlab抓取股票数据,Matlab经过sina web接口获取个数即时股票数据函数实现代码

Matlab通过sina web接口获取个数即时股票数据函数实现代码

代码如下:

function stockinfo = queryprice(stocktype, stockid)

%stocktype 股票类型:sh和sz

%stockid 股票编码:

url = sprintf('http://hq.sinajs.cn/list=%s%d', stocktype, stockid);

[sourcefile, status] = urlread(url);

if (~status)

disp('无法获取数据');

else

%取出字符串

str = javaObject('java.lang.String', sourcefile);

str = str.replaceAll('var ', '');

strs = str.split('=');

str = strs(2);

str = str.replaceFirst('"', '{''');

str = str.replaceFirst('"', '''};');

str = str.replaceAll(',', ''', ''');

str = strcat('stock=', char(str));

eval(str);

stockinfo = {};

stockinfo.name = stock(1);

stockinfo.today_start_price = str2double(stock(2));

stockinfo.yestoday_end_price = str2double(stock(3));

stockinfo.current_price = str2double(stock(4));

stockinfo.today_highest_price = str2double(stock(5));

stockinfo.today_lowest_price = str2double(stock(6));

stockinfo.today_first_buy_price = str2double(stock(7));

stockinfo.today_first_sale_price = str2double(stock(8));

stockinfo.today_success_stock_mount = str2double(stock(9))/100; %单位:手

stockinfo.today_success_money = str2double(stock(10)); %单位:万

stockinfo.today_first_buy_price = str2double(stock(11));

stockinfo.today_first_sale_price = str2double(stock(12));

stockinfo.buy_stock_mount1 = str2double(stock(13)) / 100; %单位:手

stockinfo.buy_stock_price1 = str2double(stock(14)); %单位:万

stockinfo.buy_stock_mount2 = str2double(stock(15));

stockinfo.buy_stock_price2 = str2double(stock(16));

stockinfo.buy_stock_mount3 = str2double(stock(17));

stockinfo.buy_stock_price3 = str2double(stock(18));

stockinfo.buy_stock_mount4 = str2double(stock(19));

stockinfo.buy_stock_price4 = str2double(stock(20));

stockinfo.buy_stock_mount5 = str2double(stock(21));

stockinfo.buy_stock_price5 = str2double(stock(22));

stockinfo.sale_stock_mount1 = str2double(stock(23));

stockinfo.sale_stock_price1 = str2double(stock(24));

stockinfo.sale_stock_mount2 = str2double(stock(25));

stockinfo.sale_stock_price2 = str2double(stock(26));

stockinfo.sale_stock_mount3 = str2double(stock(27));

stockinfo.sale_stock_price3 = str2double(stock(28));

stockinfo.sale_stock_mount4 = str2double(stock(29));

stockinfo.sale_stock_price4 = str2double(stock(30));

stockinfo.date = stock(31);

stockinfo.time = stock(32);

end

end

示例使用:

info = queryprice('sh', 601006)  %大秦铁路

结果为:

info =

name: {'大秦铁路'}

today_start_price: 10.5800

yestoday_end_price: 10.6300

current_price: 10.8500

today_highest_price: 10.9500

today_lowest_price: 10.5000

today_first_buy_price: 272852

today_first_sale_price: 10.8500

today_success_stock_mount: 1.1826e+06

today_success_money: 1.2708e+09

buy_stock_mount1: 410

buy_stock_price1: 10.8400

buy_stock_mount2: 43000

buy_stock_price2: 10.8300

buy_stock_mount3: 61300

buy_stock_price3: 10.8200

buy_stock_mount4: 67700

buy_stock_price4: 10.8100

buy_stock_mount5: 109038

buy_stock_price5: 10.8600

sale_stock_mount1: 86015

sale_stock_price1: 10.8700

sale_stock_mount2: 273900

sale_stock_price2: 10.8800

sale_stock_mount3: 180878

sale_stock_price3: 10.8900

sale_stock_mount4: 313838

sale_stock_price4: 10.9000

date: {'2014-12-26'}

time: {'15:03:06'}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/371024.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

虚幻4毛发系统_虚幻引擎复活!苹果与Epic对决,有哪些游戏险些中枪?

最近,苹果和Epic的官司闹得沸沸扬扬。随着Epic旗下热门手游《堡垒之夜》遭苹果火速下架,两大巨头之间的冲突愈演愈烈。苹果似乎并不满足于此,由于Epic公开违反自家规定,苹果计划进一步封禁Epic维护虚幻引擎的开发者账户&#xff0…

史上最全的HTML和CSS标签常用命名规则

文件夹主要建立以下文件夹:  1、Images 存放一些网站常用的图片;  2、Css 存放一些CSS文件;  3、Flash 存放一些Flash文件;  4、PSD 存放一些PSD源文件;  5、Temp 存放所有临时图片和其它文件; …

01-JAVA语言基础

1.设计思想: 先以字符串的形式输入两个数字,然后将他们转化为int类型,再对两数进行相加,最后输出结果。 2.程序流程图: 3.源程序代码: import java.util.Scanner;public class Addition2 {public static vo…

与JodaTime的DateTime和Google Guava的供应商嘲笑

介绍 如果您是经验丰富的单元测试人员,那么当您看到任何与时间 , 并发性 , 随机性 , 持久性和磁盘I / O协同工作的代码时,您就会学会做笔记。 原因是测试可能非常脆弱,有时完全无法正确测试。 这篇文章将展…

栈实现 C语言

最近上来写了一下栈&#xff0c;理解数据结构的栈。 头文件&#xff1a;stack.h 初始化栈结构与函数定义&#xff1a; #include<stdlib.h> #include <stdio.h> #include<memory.h> #define N 100struct stack {int data[N];int top;//标识栈顶 }; typedef s…

php签名墙,肺功能检查质量控制网

2017年12月2日&#xff0c;由中华医学会呼吸病学分会/儿科分会、国家呼吸系统疾病临床医学研究中心、国家呼吸疾病医疗质量控制中心、中国肺功能联盟、中国儿童肺功能协作组主办&#xff0c;浙江省中医院承办的"2017年中国肺功能检查规范化培训及应用推广学习班暨肺功能检…

餐饮水单打印软件_开发一款餐饮手机app系统软件什么价格?有哪些方面需要考虑?...

开发一款餐饮手机app系统软件什么价格&#xff1f;有哪些方面需要考虑&#xff1f;近年来&#xff0c;餐饮类的APP如雨后春笋般快速增长&#xff0c;无论是上档次的酒店&#xff0c;还是各大餐厅&#xff0c;都有各自的专属APP。餐饮APP的开发能让大型酒店/餐厅获得更多盈利、销…

html5中如何去掉input type date默认

html5中如何去掉input type date默认样式 2.对日期时间控件的样式进行修改目前WebKit下有如下9个伪元素可以改变日期控件的UI&#xff1a;::-webkit-datetime-edit – 控制编辑区域的::-webkit-datetime-edit-fields-wrapper – 控制年月日这个区域的::-webkit-datetime-edit-…

Spring-framework应用程序启动loadtime源码分析笔记(二)——@Transactional

Transactional标识类或方法&#xff0c;使方法被执行时使用事务方式执行&#xff0c;这里只讨论PROXY方法增强方法。使用EnableTransactionManagement&#xff0c;默认modelAdviceMode.PROXY&#xff0c;通过Import(TransactionManagementConfigurationSelector.class)来判断在…

具有Spring的简单工作流引擎

几个月前&#xff0c;在处理一个公司项目时&#xff0c;我们需要开发REST服务&#xff0c;该服务用于根据客户端应用程序发送的数据发送电子邮件。 在开发此服务期间&#xff0c;我们决定创建简单的工作流引擎&#xff0c;该引擎将为发送电子邮件收费&#xff0c;但该引擎也可用…

php put 参数,php – 如何在Guzzle 5中发送PUT请求的参数?

根据the manual,The body option is used to control the body of an entity enclosingrequest (e.g., PUT, POST, PATCH).记录的put’ing方法是&#xff1a;$client new GuzzleHttp\Client();$client->put(http://httpbin.org, [headers > [X-Foo > Bar],body > …

TypeScript学习笔记归纳(持续更新ing)

文章目录 前言 二、TypeScript的优势体现在哪里&#xff1f; 1、执行时间上的区别 2、基础数据类型区别 3、TS优势 三、TypeScript的关键特性 四、TypeScript的类型系统 1、什么是类型注释&#xff1f; 2、类型系统核心 - 常用类型 1&#xff09; 基本类型&#xff0…

组态王 6.55 启停plc_永宏PLC在远程控制系统中的应用

一、行业介绍本远程控制系统是给石药集团的下属子公司设计的一个控制方案。主要是配套GPRS-DTU产品实现远程plc与plc之间的数据共享。从而达到远程无线数据写入控制和读取监控的目的。二、客户需求(1) 客户可以在监控室控制至少2-3公里外的井上两个水泵的启动和停止。(2) 客户可…

Vue表格中,对数据进行转换、处理

众所周知&#xff0c;后端从Mysql取出的数据&#xff0c;一般是很难单独处理某一个Key的数据的&#xff08;需要处理的话&#xff0c;可能会浪费大量的性能。而且对页面加载时间有很大的影响&#xff09;&#xff0c;所以&#xff0c;从数据库取出的数据。只能由前端进行处理。…

Java应用程序中的SQL注入

在本文中&#xff0c;我们将讨论什么是SQL注入攻击。 以及它如何影响任何Web应用程序使用后端数据库。 在这里&#xff0c;我专注于Java Web应用程序。 开放Web应用程序安全项目&#xff08;OWAP&#xff09;列出了SQL注入是Web应用程序的主要漏洞攻击。 黑客将Web请求中的SQL代…

【转】ReactNativeweexDeviceOne对比

React Native出来有一段时间了&#xff0c;国内的weex和deviceone是近期发布的&#xff0c;我可以说从2011年就开始关注快速开发的跨平台平台技术了&#xff0c;接触过phoneGap、数字天堂、appcan等早期的移动中间件技术&#xff0c;也跟朋友也讨论过这类的轻量级框架。这些年通…

bluetooth射频已关闭请打开bluetooth射频_希杰大功率射频放大器烧了维修诊断步骤...

如果电阻值过低&#xff0c;说明电源内部存在短路&#xff0c;正常时其阻值应能达到100千欧以上;电容器应能够充放电&#xff0c;如果损坏&#xff0c;则表现为AC电源线两端阻值低&#xff0c;呈短路状态&#xff0c;否则可能是开关管击穿。然后检查直流输出部分脱开负载&#…

java中整数如何表示,在Java中如何在位级别上内部表示整数?

慕瓜9086354Java整数为32位&#xff0c;并且总是带符号的。这意味着&#xff0c;最高有效位(MSB)用作符号位。用an表示的整数int不过是位的加权和。权重分配如下&#xff1a;Bit# Weight31 -2^3130 2^3029 2^29... ...2 2^21 2^10 …

洛谷-P1160 队列安排

题目 Problem Description 一个学校里老师要将班上N个同学排成一列&#xff0c;同学被编号为1&#xff5e;N&#xff0c;他采取如下的方法&#xff1a; 1.先将1号同学安排进队列&#xff0c;这时队列中只有他一个人&#xff1b; 2.2&#xff5e;N号同学依次入列&#xff0c;编号…

1.HTML小结

HTML 基本文档 <!DOCTYPE html> <html> <head> <meta charset"UTF-8"> <title>文档标题</title> </head> <body> 可见文本... </body> </html> <!DOCTYPE html>html文件声明。charset"UTF-8…