Stock API ---- Sina financial channel

Source: Internet
Author: User

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?sh601006this urlwill return a string of records, 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;

This interface is very convenient for javascript programs. It is usually used to insert static or dynamic pages:

<SCRIPT type = "text/JavaScript" src = "http://hq.sinajs.cn/list=sh601006" charset = "gb2312">

</SCRIPT>

<SCRIPT type = "text/JavaScript">

VaR elements = hq_str_sh601006.split (",");

Document. Write ("current price:" + elements [3]);

</SCRIPT>

This code outputs the current stock price of Daqin Railway (stock code: 601006)

Current Price: 14.20

If you want to query multiple stocks at the same time, add a comma at the end of the URL and the stock code. For example, you need to query Daqin Railway (601006) and Datong coal (601001) at a time) the URL is used as follows:
Http://hq.sinajs.cn/list=sh601003,sh601001

However, if you want to query the index of the dashboard, the situation may be different. For example, to query the Shanghai Composite Index (000001), use the following URL:
Data returned by the http://hq.sinajs.cn/list=s_sh000001 server is:

VaR hq_str_s_sh000001 = "Shanghai Stock Index, 3094.668,-128.073,-3.97, 436653,5458126 ";

The data meanings are: Index name, current points, current price, rise/fall rate, transaction volume (hand), and transaction amount (10 million RMB );

The URL of the Shenzhen index is:
Http://hq.sinajs.cn/list=s_sz399001

 

You can request http://image.sinajs.cn/… to obtain the K-line and daily-line charts of a stock /.... /... /*. GIF: This URL is obtained. * indicates the stock code. For details, see the following:

View the daily K-line chart:

Http://image.sinajs.cn/newchart/daily/n/sh601006.gif

Time-sharing line query:

Http://image.sinajs.cn/newchart/min/n/sh000001.gif

Query the daily data records:

Http://image.sinajs.cn/newchart/daily/n/sh000001.gif

Weekly k query:

Http://image.sinajs.cn/newchart/weekly/n/sh000001.gif

Monthly kill query:

Http://image.sinajs.cn/newchart/monthly/n/sh000001.gif

(Note: This article is from reprinted S)

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.