-
Notifications
You must be signed in to change notification settings - Fork 0
Websocket Market Data
githubdev2020 edited this page Mar 16, 2020
·
2 revisions
wss://www.bitforex.com/mkapi/coinGroup1/ws
- This service supports standard websocket heartbeat modes, namely ping and pong
- Due to the differences in the implementation of each version of the browser, in order to ensure that the server and client are active, the system requires the client to send heartbeats to the server regularly. It supports two modes:
- Standard websocket heartbeat mode
- String ping mode websocket.send ("ping_p"); server returns "pong_p"
- Subscribe to Topic:
[
{
"type": "subHq",
"event": "ticker",
"param": {
"symbol": "coin-usdt-eth"
}
}
]
- Unsubscribe
[
{
"type": "subHq_cancel",
"event": "ticker",
"symbol": "coin-usdt-eth"
}
},
]
- Unsubscribe All
[
{
"type": "subHq_cancel_all",
"param": {
}
},
]
- websocket.send(“[{"type":"subHq","event":"ticker","param":{"businessType":"coin-usdt-btc"}}]”);
Get the latest product Market data
Parameter
Parameter | Type | Is it required? | Defaults | description |
---|---|---|---|---|
businessType | String | yes | - | Symbol code e.g. coin-usdt-btc |
Response (json)
Example:
{
"success": true,
"code": 200,
"version": "0.0.1",
"event": "ticker",
"param": {"businessType":"coin-usdt-btc"},
"data": {
"high":<highest price>,
"last":<last price>,
"low":<lowest price>,
"open":<open price>,
"productvol":<quantity>,
"currencyvol": <transaction amount>,
"rate": <24-hour change>
}
}
- websocket.send(“[{"type":"subHq","event":"depth10","param":{"businessType":"coin-usdt-btc", "dType":0}}]”);
Subscribe to real-time market depth
Parameter
Parameter | Type | Is it required? | Defaults | description |
---|---|---|---|---|
businessType | String | yes | - | Symbol code e.g. coin-usdt-btc |
dType | int | yes | - | Depth type e.g. 0,1 |
Response (json)
Explanation:
1、 Example of returning 150 orders each time
Example:
{
"success": true,
"code": 200,
"version": "0.0.1",
"event": "depth10",
"param": {"businessType":"coin-usdt-btc", "dType":0},
"data": {
"asks":[
{"price":<price>,"amount",<Number of digital currencies>},
{"price":<price>,"amount",<Number of digital currencies>},
{"price":<price>,"amount",<Number of digital currencies>},
...
],
"bids":[
{"price":<price>,"amount",<Number of digital currencies>},
{"price":<price>,"amount",<Number of digital currencies>},
{"price":<price>,"amount",<Number of digital currencies>},
...
]
}
}
asks for selling, bids for buying
- websocket.send(“[{"type":"subHq","event":"trade","param":{"businessType":"coin-usdt-btc", "size":20}}]”);
Push the latest transaction data of the product
Parameter
Parameter | Type | Is it required? | Defaults | description |
---|---|---|---|---|
businessType | String | yes | - | Symbol code e.g. coin-usdt-btc |
size | int | yes | - | Number of first returns e.g. 20 Max. 1000 |
Response (json)
Note: The first return, the number of sizes required by the parameter, and subsequent incremental returns, the data format is consistent
Example:
{
"success": true,
"code": 200,
"version": "0.0.1",
"event": "trade",
"param": {"businessType":"coin-usdt-btc"},
"data":[
{
"price":<transaction price>,
"amount",<volume (digital currency)>,
"direction",<transaction direction>,
"time",<transaction time>
},
{
"price":<transaction price>,
"amount",<volume (digital currency)>,
"direction",<transaction direction>,
"time",<transaction time>
},
...
]
}
Direction: 1 buy 2 sell , time is long
Description: The latest size push data is returned for the first time and the latest 50 data is returned.
- websocket.send(“[{"type":"subHq","event":"kline","param":{"businessType":"coin-usdt-btc", "kType":"1min", "size":20}}]”);
Retrieve the candlestick data
Parameter
Parameter | Type | Is it required? | Defaults | description |
---|---|---|---|---|
businessType | String | yes | - | Symbol code e.g. coin-usdt-btc |
size | int | yes | - | Number of first returns e.g. 20 MAX. 1500 |
kType | String | yes | - | candlestick type |
kType:
- 1min:1mins candlestick ,
- 5min:5mins candlestick ,
- 15min:15mins candlestick ,
- 30min:30mins candlestick ,
- 1hour:1hour candlestick ,
- 2hour:2hour candlestick ,
- 4hour:4hour candlestick ,
- 12hour:12hour candlestick ,
- 1day:1day candlestick,
Response (json)
Example:
{
"success": true,
"code": 200,
"version": "0.0.1",
"event": "kline",
"param": {"businessType":"coin-usdt-btc", "kType":"1min"},
"data":[
{
"time":<timestamp>,
"open",<Open price>,
"high",<Highest price>,
"close",<Close price>,
"low",<Lowest price>,
"vol",<Trading volume>
},
{
"time":<timestamp>,
"open",<Open price>,
"high",<Highest price>,
"close",<Close price>,
"low",<Lowest price>,
"vol",<Trading volume>
},
...
]
}
{
"success": false,
"code": 20002,
"version": "0.0.1",
"msg": "Request params not valid"
}
public static final String[] PARAM_ERROR = {"MK100", "param is invalid"};
public static final String[] PARAM_BUSS_TYPE = {"MK101", "business type is invalid"};
public static final String[] PARAM_DTYPE_PARAM = {"MK102", "dType type is invalid"};
public static final String[] PARAM_KTYPE_PARAM = {"MK103", "kType type is invalid"};
public static final String[] PARAM_SIZE_PARAM = {"MK103", "SIZE type is invalid"};