基于Matlab给出了sina即时股票数据获取分析的算法,便于用户开展数据获取和分析工作。

代码如下:

function stockinfo = queryprice(stocktype, stockid)

%stocktype 股票类型:sh和sz

%stockid 股票编码:

url = sprintf('=%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'}

matlab抓取股票数据,Matlab通过sina web接口获取个数即时股票数据函数实现代码相关推荐

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

    Matlab通过sina web接口获取个数即时股票数据函数实现代码 代码如下: function stockinfo = queryprice(stocktype, stockid) %stockt ...

  2. matlab抓取网页信息,如何利用Matlab抓取网页数据

    如何利用Matlab抓取网页数据 2019-01-01 %朋友需要做金融方面的分析,要求从网站上下载大量的数据,一个一个复制粘贴太费事.我写了一个简单的网络爬虫,主要用到正则表达式,可以自动下载网页源 ...

  3. matlab抓取指定网址图片

    Matlab实现抓取图片非常的容易,基本思路为 1.使用urlread函数得到网页Html页面以字符串的形式储存网页 2.再使用函数搭配正则表达式匹配到图片的网址 3.根据得到的图片网址,用函数,下载 ...

  4. 抓取了1400家科技公司的招聘信息,我发现数据工程师比数据科学家更有市场

    来源:机器之心本文约2300字,建议阅读6分钟掌握工程技能可能是更重要的. 「作为数据科学家,我还有机会吗?」不,你更应该成为数据工程师. 数据无处不在,而且只会越来越多.在过去的 5-10 年内,数 ...

  5. 5-随机抓取易烊千玺置顶100万+转发微博的转发数据,并分析真假粉丝比例

    说明: 项目主要随机抓取易烊千玺100万+转发的微博置顶的100万条转发数据,并利用数据可视化的方式分析易烊千玺真假粉丝比例. 分为:爬虫+数据分析 一.爬虫[爬取易烊千玺100万条的转发数据] #爬 ...

  6. 抓取近千分领英资料后,我们发现了数据科学家的秘密……

    全文共4090字,预计学习时长8分钟 获取数据,以洞悉自己想成为的样子 图片来源:David S.A/Pixabay 一个数据科学家是不是非得成为一个Kaggler大师?神经网络究竟该用于图像识别还是 ...

  7. 获取淘宝商品分类详情API,抓取淘宝全品类目API接口分享(代码展示、参数说明)

    商品分类技巧 淘宝店铺分类怎么设置?我们登录卖家账号的时候,我们看到自己的商品,会想要给商品进行分类,一个好的分类可以帮助提高商品的曝光率.那么在给商品分类前,如果您毫无头绪,以下几点可以给您带来一点 ...

  8. python新闻关键词次数_使用python抓取百度搜索、百度新闻搜索的关键词个数

    由于实验的要求,需要统计一系列的字符串通过百度搜索得到的关键词个数,于是使用python写了一个相关的脚本. 在写这个脚本的过程中遇到了很多的问题,下面会一一道来. ps:我并没有系统地学习过pyth ...

  9. php抓取搜狗图片,搜狗美图 API 接口请求调用

    原标题:搜狗美图 API 接口请求调用 搜狗美图 API 接口在网上已经很多且大都封装成了 API 供别人调用.支持前台跨域请求,以POST方式提交图片即可.搜狗美图 API 接口每日都会更新一张美图 ...

最新文章

  1. 基于神经网络的溶解度预测和回归分析
  2. java定时扫描_springmvc 定时扫描
  3. CrazyWing:Python自动化运维开发实战 九、Python数据类型之列表
  4. android 关于内存优化的一些总结
  5. C++ Iterators(迭代器)
  6. FastAdmin 极速后台管理框架(三周年)V1.0.0.20190410_beta
  7. Android之封装倒计时页面
  8. Hadoop学习笔记
  9. android 拍照 比例,Android全屏摄像头 – 同时保持摄像头选择的比例
  10. block(块元素)、inline(内联元素)的差别是什么?
  11. python绝对值编程_python求绝对值的三种方法小结
  12. β-VAE:学习具有约束框架的基本视觉概念--附件
  13. android svg 线条动画教程,SVG技术入门:线条动画实现原理
  14. 30岁程序媛在一家公司工作八年后,告别“体制化”终于跳槽,别再妄想靠公司养老了!
  15. 论文笔记:3D-CVF(ECCV 2020)
  16. Linux学习推荐书籍
  17. Error -27796: Failed to connect to server ip地址: [10060] Connection timed out
  18. 凸包旋转卡壳(andrew)
  19. sco的意思_HIV检测中的SCO值意义-3页word资料
  20. 传奇创世孙大宁:2016年H5将井喷,新传播途径是突破口

热门文章

  1. hibernate数据库连接池
  2. hibernate基本类型映射
  3. 搜索引擎的那些事(摘取价格数据)
  4. mysql创建表设置数值范围,MySQL创建数据表时设定引擎MyISAM/InnoDB操作
  5. java string.format_如果性能很重要,我应该使用Java的String.format()吗?
  6. pcie usb3.0 驱动 for linux_Linux 中的虚拟网络
  7. createbitmap 旋转90度_解决某些机型调用系统相机照片旋转的问题
  8. canvas 擦除动画_帧动画的多种实现方式与性能对比
  9. c++ list排序_排序(二)交换排序
  10. python 获取用户的一个输入值_Python中,用于获取用户输入的命令为: