BIGI Quote - Quote data source interface access method websocket

BIGI Quote - Real-time market data source interface socket access method
1, the international futures, the domestic futures, foreign exchange, precious metals, spot, options, stock, currency and digital A shares real-time quotes and historical quotes
2, push there: socket, websocket, http reception, with active http get requests or post way
3, free calls K-line, real-time push K line
4, stable, without delay
5, exchange: New York NYMEX, New York COMEX, Chicago, CME, Chicago CBOE, US ICE, Europe ICE, Switzerland EUREX, London LME, Hong Kong HKEX, Singapore SGX, Jingdong TOCOM, Malaysia BMD, gold in the CFFEX, the period of the SHFE, DCE DCE, ZCE CZCE, the energy INE
3.WebSocket connection
according BIGI provided the IP, port connections made, return the string "ok" even after, and then may send a log-in request.
3.1.WebSocket landing
3.1.1 login request
sending login request string: Login = 0 |. 1 = 10002 | abcde25oem5f6 2 =
0 indicates Login Login =;
. 1 = 10002 BIGI assigned account;
token 2 = abcde25oem5f6 BIGI distribution;
" | "(0x7C) for each data element is delimiter, into key = value form;
the login request issued in response waiting.
3.1.2 log-in response
log-in response is returned: 0 = login | 1 = 1 | 2 = invalid token or account has expired
0 = login representation landing;
1 = 1 (0) 0 indicates a successful landing, 1 landing error;
2 = invalid token or account has expired, landing the success or failure of the description (successful landing, landing accounts expired, unauthorized landing accounts, unauthorized ip address);
"|" (0x7C) for each data element delimiter, into a key = value form;
after successful receipt of login information may initiate a subscription request.
3.2.WebSocket subscription products market
. 3.2.1 subscription request
send a subscription request string without line k: = 0 Subscribe | = 6BML. 1, HSIML, ngml
0 = represents Subscribe Feed;
. 1 = 6BML, HSIML, representing the ngml to subscribe products can also be a separate product subscriptions.
"|" (0x7C) for each data element is delimiter, into key = value form;
after waiting for a request issued subscription response.

Sending a subscription request string line with k: = 0 Subscribe | = 6BML. 1, HSIML, ngml | = 2 k
. 3.2.2 subscription response
sends a subscription request string: 0 = Subscribe | 1 = 1 | 2 = invalid token or account has expired
0 = subscribe Subscribe to represent;
1 = 1 (0) 0 indicates a successful landing, 1 landing error.
2 = invalid token or account has expired, landing describe the success or failure of (unauthorized login account or access ip, product xxx "already subscribed to, you do not have permission to subscribe to product xxx, xxx subscription success). "
| " (0x7C) for each data element is delimiter, into key = value form;
. (0x0A) transmits "\ n" terminator content, each request or command to the server response are \ n terminator to
receive the subscription is successful . a server to start the normal reception of the latest position information
3.3.WebSocket market push
3.3.1 Quotes service push over (without line k)
0 = HQ | =. 17. 1 | 2 = ngml | = 4.577. 3 |. 4 = 1542614598 | . 5 = 1 |. 6 = 4.574 |. 7 = 4.577 |. 8 = 1 |. 9 =. 3 | 10 = 9232 |. 11 = 4.625 | 12 is = 4.737 | 13 is = 4.550 | 14 = 4.390
0 = HQ denotes market;
1 = 17 order code , not the unique code;
2 = ngml products, unique code;
3 = 4.577 latest price;
4 = 1,542,614,598 time, prices time (UTC + 8) and 1970-1-10: 0: 0 seconds past;
5 = 1 now the hand;
6 = 4.574 purchase price;
7 = 4.577 selling price;
8 = 1 an amount to buy;
9 sales volume = 3;
10 = Volume 9232;
11 = 4.625 opening price;
12 = 4.737 highest price;
13 = 4.550 lowest;
14 = 4.390 Zuoshou valence;
"|" (0x7C) is each data element is delimiter, into key = value form;
3.3.2 push over service market (with k lines)
0 = HQ |. 4. 1 = | 2 = CLML | = 62.94. 3 |. 4 = 1556512732 | = 2. 5 | 6 = 62.93 | 7 = 62.94 | 8 = 46 | 9 = 22 | 10 = 34112 | 11 = 62.95 | 12 = 63.11 | 13 = 62.79 | 14 = 62.80 | M1 = 62.94,62.94,62.93,62.94,76,1904291238 | M5 = 62.95,62.95,62.93,62.94,266,1904291235 | M15 = 62.96,62.95,62.93,62.94,799,1904291230 | M30 = 62.96,62.95,62.93,62.94,799,1904291230 | H1 = 62.99,62.95,62.92, 62.94,4190,1904291200 | 63.11,62.83,62.83,62.94,57264,1904290800 Dl = \ n-
0 = HQ denotes market;
1 = 4 order code, the code is not unique;
2 = CLML products, unique code;
3 = 62.94 latest price ; 4
= 1,556,512,732 time, prices time (UTC + 0) and 1970-1-10: 0: 0 seconds past;
5 = 2 now hands;
6 = 62.93 purchase price;
7 = 62.94 selling price;
8 = 46 Buy amount;
9 sales volume = 22;
10 = 34112 daily;
11 = 62.95 opening price;
12 = 63.11 highest price;
13 = 62.79 lowest;
14 = 62.80 Zuoshou price;
Ml = 62.94,62.94,62.93,62.94,76,1904291238, at time 19 at 12:38 on April 29 k line 1 minute, followed by a comma-separated were high, open, low, close, volume, k line time.
M5 = 62.95,62.95,62.93,62.94,266,1904291235, at time 19 at 12:35 on April 29 k line 5 minutes, followed by a comma-separated were high, open, low, close, volume, k line time.
M15 = 62.96,62.95,62.93,62.94,799,1904291230, at time 19 at 12:30 on April 29 k lines 15 minutes, followed by a comma-separated were high, open, low, close, volume, k line time.
M30 = 62.96,62.95,62.93,62.94,799,1904291230, at time 19 at 12:30 on April 29 k lines 30 minutes, followed by a comma-separated were high, open, low, close, volume, k line time.
H1 = 62.99,62.95,62.92,62.94,4190,1904291200, at time 19 at 12:01 on April 29 hours k line, separated by commas later were high, open, low, close, volume, k line time.
D1 = 63.11,62.83,62.83,62.94,57264,1904290800, at time 19 on April 29 k line, behind the comma-separated were high, open, low, close, volume, k line time.

"|" (0x7C) for each data element is delimiter, into key = value form;

3.4.WebSocket receiving market summary
7. market server connected to the client;
After successfully connecting the server returns "OK";
8. The client sends a login request:
0 = Login |. 1 = 10002 | 2 = abcde25oem5f6
9. The server login request response , successfully landed returned to the client:
0 = the login | 1 = 0 | 2 = successful landing
10. the client receives a request to send a subscription products market after the successful landing:
real-time quotes request without k line: 0 = subscribe | 1 = 6BML , HSIML
real-time quotes request lines with k: = 0 Subscribe | = 6BML. 1, HSIML, ngml | k 2 =
11. the end of the service subscription is successful response back to the client:
0 = Subscribe |. 1 = 0 | 2 = successful subscription 6BML \ the n-
0 = the Subscribe | 1 = 0 | 2 = Subscribe HSIML success \ the n-
12. server officially push the latest market to clients
0 = hq | 1 = 1 | 2 = 6BML | 3 = 1.2841 | 4 = 1542610107 | 5 = 2 |. 6 = 1.2830 |. 7 = 1.2880 |. 8 =. 1 |. 9 =. 1 | 10 = 0 |. 11 = 1.2781 | 12 is = 1.2895 | 13 is = 1.2777 | 14 = 1.2841 \ n-
0 = HQ |. 1 = 2 | 2 = HSIML | 3 = 26128 | 4 = 1542617107 | 5 = 1 | 6 = 26125 | 7 = 26168 | 8 = 1 | 9 = 1 | 10 = 43903 | 11 = 26107 | 12 = 26239 | 13 = 25958 | 14 = 26115 \ n
the above is without pushing the line k.
The following is a push belt line k:
0 = hq | 1 = 4 | 2 = CLML | 3 = 62.94 | 4 = 1556512732 | 5 = 2 | 6 = 62.93 | 7 = 62.94 | 8 = 46 | 9 = 22 | 10 = 34112 | 11 = 62.95 | 12 = 63.11 | 13 = 62.79 | 14 = 62.80 | M1 = 62.94,62.94,62.93,62.94,76,1904291238 | M5 = 62.95,62.95,62.93,62.94,266,1904291235 | M15 = 62.96,62.95,62.93,62.94,799, 1904291230 | M30 = 62.96,62.95,62.93,62.94,799,1904291230 | H1 = 62.99,62.95,62.92,62.94,4190,1904291200 | D1 63.11,62.83,62.83,62.94,57264,1904290800 =
all requests or responses are brought \ n, because the communication protocol to inherit Socket, websocket relatively simple, without treatment packets, each message received by the client are websocket complete information.
3.4.1.WebSocket market receiving pseudocode
WebSocket websocket = new WebSocket ( "ws : // ip: port / xxxx"); // Create a global socket object
websocket.OnClose + = new EventHandler (OnClose) ; // OFF open connection event
websocket.OnError + = new EventHandler <WebSocketSharp.ErrorEventArgs> (OnError); // error handling
websocket.OnMessage + = new EventHandler (OnMessage) / / receiving event information to the server
websocket.OnOpen += new EventHandler(OnOpen);//连上
void OnOpen(object sender, EventArgs e)
{

}
Void the OnMessage (Object SENDER, MessageEventArgs E)
{
. 1
2
. 3
// split strings to "|" as a separator, press enter key-value Dictionary.
If msg == "ok" connection is successful, may initiate landing
{
// send login request
_client.send ( "Login = 0 |. 1 = 10002 | 2 = abcde25oem5f6 \ n-");
}
Else IF Dictionary.Contain (0) and dictionary [ "0"] "login" and dictionary [ ". 1"] "0"
{
// return a successful landing, without initiating subscription k line
_client.send ( "0 = subscribe | 1 = 6BML, HSIML");

// landing successfully returned, launched a subscription line with k
1
//_client.send("0=subscribe|1=6BML,HSIML|2=k ");
}

IF Dictionary.Contain Else (0) and the Dictionary [ "0"] == "HQ"
. 1
{
// market reception, processing market
-------- Quotes service logic processing ----
}

}
. 1
void the OnError (Object SENDER, WebSocketSharp.ErrorEventArgs E)
{
Reconnection (); // to disconnect and reconnect the connector
}

websocket_OnClose void (Object SENDER, CloseEventArgs E)
{
Reconnection (); // reconnect after disconnecting
}
---------------------
OF: BIGI Quote
Source: CSDN
original: https: //blog.csdn.net/vguiwang/article/details/91037990
copyright: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/bigi/p/11141475.html