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.pswp.cn/news/371024.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/371024.shtml
英文地址,請注明出處:http://en.pswp.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…