Real-time stock data example

Source: Internet
Author: User

Real-time stock data example

 

<SCRIPT type = "text/JavaScript" src = "http://hq.sinajs.cn/list=sh000001" charset = "gb2312"> </SCRIPT> <SCRIPT type = "text/JavaScript">
VaR elements = hq_str_sh000001.split (",");
VaR scope = parsefloat (elements [3])-parsefloat (elements [2]);
VaR per = scope/parsefloat (elements [2]) * 100
If (scope> 0)
{
Document. write (elements [0] + elements [3] + ", sums" + scope. tofixed (2) + ',' + per. tofixed (2) + "%," + elements [30]);

}
Else
{
Document. write (elements [0] + elements [3] + ", sums" + scope. tofixed (2) + ',' + per. tofixed (2) + "%," + elements [30]);
}
</SCRIPT>

 

Effect: http://www.51-ba.com/html/wuyi/wuyi.html

 

 

Reference

Sina stock data interface

Take the Daqin Railway (stock code: 601006) as an example. To get its latest market, you only need to access Sina's stock data.
Interface:

Http://hq.sinajs.cn/list=sh601006

This URL returns a string of text, for example:

VaR hq_str_sh601006 = "Daqin railway, 27.55, 27.25, 26.91, 27.55, 26.20, 26.91, 26.92,
22114263,589 listen 680, 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, 15:05:32 ";

This string is concatenated by many pieces of data. Data of different meanings are separated by commas. According to the programmer's idea, the sequence number starts from 0.

0: "Daqin Railway", stock name;
1: "27.55", available today;
2: "27.25", closing price yesterday;
3: "26.91", current price;
4: "27.55", the highest price today;
5: "26.20", the lowest price today;
6: "26.91", bidding price, that is, "buy one" quotation;
7: "26.92", competitive price, that is, "sell one" quotation;
8: "22114263". The number of votes in the transaction. Because the stock transaction uses one hundred shares as the basic unit, this value is usually divided by one hundred during use;
9: "589824680", deal amount, unit: "Yuan", in order to be clear, usually "10 thousand yuan" as the unit of deal amount, so usually divide the value;
10: "4695", "buy one" apply for 4695 shares, that is, 47;
11: "26.91", "buy one" quotation;
12: "57590", "Buy two"
13: "26.90", "Buy two"
14: "14700", "Buy three"
15: "26.89", "Buy three"
16: "14300", "Buy Four"
17: "26.88", "Buy Four"
18: "15100", "Buy five"
19: "26.87", "Buy five"
20: "3100", "sell one", declare 3100 shares, that is, 31 hands;
21: "26.92", "buy one" quotation
(22, 23), (24, 25), (26, 27), (28, 29) are the situations from "selling two" to "selling four" respectively"
30: "2008-01-11", date;
31: "15:05:32", time;

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.