hollaex-node-lib 1.2.0 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.drone.yml +59 -0
- package/.editorconfig +10 -0
- package/.eslintrc.json +3 -0
- package/README.md +255 -290
- package/example/hollaex.js +7 -16
- package/index.js +7 -464
- package/kit.js +895 -0
- package/package.json +19 -8
- package/utils.js +49 -4
- package/.prettierignore.json +0 -1
- package/.prettierrc.json +0 -8
package/README.md
CHANGED
|
@@ -1,47 +1,53 @@
|
|
|
1
1
|
# hollaex-node-lib
|
|
2
2
|
|
|
3
|
-
HollaEx
|
|
3
|
+
Nodejs library for HollaEx Kit enabled exchanges.
|
|
4
|
+
|
|
5
|
+
**This library is specifically for end users and traders to connect to HollaEx Kit exchanges. It connects to [HollaEx Pro](https://pro.hollaex.com/trade/xht-usdt) by default.**
|
|
4
6
|
|
|
5
7
|
## Usage
|
|
6
8
|
|
|
7
|
-
```
|
|
8
|
-
const
|
|
9
|
+
```javascript
|
|
10
|
+
const hollaex = require('hollaex-node-lib');
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
const client = new hollaex();
|
|
11
13
|
```
|
|
12
14
|
|
|
13
15
|
You can pass the `apiURL` and `baseURL` of the HollaEx-Enabled exchange to connect to. You can also pass your `apiKey` and `apiSecret` generated from the HollaEx-Enabled exchange.
|
|
14
16
|
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
apiURL: <EXCHANGE_API_URL
|
|
18
|
-
baseURL: <EXCHANGE_BASE_URL
|
|
19
|
-
apiKey: <MY_API_KEY
|
|
20
|
-
apiSecret: <MY_API_SECRET>
|
|
17
|
+
```javascript
|
|
18
|
+
const client = new hollaex({
|
|
19
|
+
apiURL: '<EXCHANGE_API_URL>',
|
|
20
|
+
baseURL: '<EXCHANGE_BASE_URL>',
|
|
21
|
+
apiKey: '<MY_API_KEY>',
|
|
22
|
+
apiSecret: '<MY_API_SECRET>'
|
|
21
23
|
});
|
|
22
24
|
```
|
|
23
25
|
|
|
24
26
|
You can also pass the field `apiExpiresAfter` which is the length of time in seconds each request is valid for. The default value is `60`.
|
|
25
27
|
|
|
26
|
-
There is a list of functions you can call which will be added later and they are not at this point implemented yet.
|
|
27
|
-
|
|
28
|
-
> - **Note**: v1 has a new authentication mechanism using HMAC signature. HollaEx previously was using JSON Web Token (JWT) which is now changed to HMAC authentication.
|
|
29
|
-
|
|
30
28
|
### Example:
|
|
31
29
|
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
apiURL: <EXCHANGE_API_URL
|
|
35
|
-
baseURL: <EXCHANGE_BASE_URL
|
|
36
|
-
apiKey: <MY_API_KEY
|
|
37
|
-
apiSecret: <MY_API_SECRET>
|
|
30
|
+
```javascript
|
|
31
|
+
const client = new hollaex({
|
|
32
|
+
apiURL: '<EXCHANGE_API_URL>',
|
|
33
|
+
baseURL: '<EXCHANGE_BASE_URL>',
|
|
34
|
+
apiKey: '<MY_API_KEY>',
|
|
35
|
+
apiSecret: '<MY_API_SECRET>'
|
|
38
36
|
});
|
|
39
37
|
|
|
40
38
|
client
|
|
41
39
|
.getTicker('xht-usdt')
|
|
42
40
|
.then((res) => {
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
console.log('The volume is: ', res.volume);
|
|
42
|
+
})
|
|
43
|
+
.catch((err) => {
|
|
44
|
+
console.log(err);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
client
|
|
48
|
+
.getTrades({ symbol: 'xht-usdt' })
|
|
49
|
+
.then((res) => {
|
|
50
|
+
console.log('Public trades: ', res);
|
|
45
51
|
})
|
|
46
52
|
.catch((err) => {
|
|
47
53
|
console.log(err);
|
|
@@ -50,305 +56,264 @@ client
|
|
|
50
56
|
|
|
51
57
|
### Available functions:
|
|
52
58
|
|
|
53
|
-
| Command
|
|
54
|
-
|
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
68
|
-
| `
|
|
69
|
-
| `
|
|
59
|
+
| Command | Parameters | Description |
|
|
60
|
+
| - | - | - |
|
|
61
|
+
| `getKit` | | Get exchange information e.g. name, valid languages, description, etc. |
|
|
62
|
+
| `getConstants` | | Tick size, min price, max price, min size and max size of each symbol pair and coin |
|
|
63
|
+
| `getTicker` | <ul><li>**symbol**: HollaEx trading symbol e.g. `xht-usdt`</li></ul> | Last, high, low, open and close price and volume within the last 24 hours |
|
|
64
|
+
| `getTickers` | | Last, high, low, open and close price and volume within the last 24 hours for all symbols |
|
|
65
|
+
| `getOrderbook` | <ul><li>**symbol**: HollaEx trading symbol e.g. `xht-usdt`</li></ul> | Orderbook containing list of bids and asks |
|
|
66
|
+
| `getOrderbooks` | | Orderbook containing list of bids and asks for all symbols |
|
|
67
|
+
| `getTrades` | <ul><li>**opts**: Object with additional params</li><li>**opts.symbol**: (_optional_) HollaEx trading symbol e.g. `xht-usdt`</li></ul> | List of last trades |
|
|
68
|
+
| `getUser` | | User's personal information |
|
|
69
|
+
| `getBalance` | | User's wallet balance |
|
|
70
|
+
| `getDeposits` | <ul><li>**opts**: Object with additional params</li><li>**opts.currency**: (_optional_) Filter data set by asset</li><li>**opts.status**: (_optional_) Filter data set `status`</li><li>**opts.dismissed**: (_optional_) Filter data set `dismissed`</li><li>**opts.rejected**: (_optional_) Filter data set `rejected`</li><li>**opts.processing**: (_optional_) Filter data set `processing`</li><li>**opts.waiting**: (_optional_) Filter data set `waiting`</li><li>**opts.limit**: (_optional_, _default_=`50`, _max_=`50`) Number of items to get</li><li>**opts.page**: (_optional_, _default_=`1`) Page number of data</li><li>**opts.orderBy**: (_optional_) Field to order data by</li><li>**opts.order**: (_optional_, _enum_=[`asc`, `desc`]) Specify ascending or descending order</li><li>**opts.startDate**: (_optional_, _format_=`ISO8601`) Start date of data set</li><li>**opts.endDate**: (_optional_, _format_=`ISO8601`) End date of data set</li><li>**opts.transactionId**: (_optional_) Filter data set by TXID</li><li>**opts.address**: (_optional_) Filter data set by address</li></ul> | User's list of all deposits |
|
|
71
|
+
| `getWithdrawals` | <ul><li>**opts**: Object with additional params</li><li>**opts.currency**: (_optional_) Filter data set by asset</li><li>**opts.status**: (_optional_) Filter data set `status`</li><li>**opts.dismissed**: (_optional_) Filter data set `dismissed`</li><li>**opts.rejected**: (_optional_) Filter data set `rejected`</li><li>**opts.processing**: (_optional_) Filter data set `processing`</li><li>**opts.waiting**: (_optional_) Filter data set `waiting`</li><li>**opts.limit**: (_optional_, _default_=`50`, _max_=`50`) Number of items to get</li><li>**opts.page**: (_optional_, _default_=`1`) Page number of data</li><li>**opts.orderBy**: (_optional_) Field to order data by</li><li>**opts.order**: (_optional_, _enum_=[`asc`, `desc`]) Specify ascending or descending order</li><li>**opts.startDate**: (_optional_, _format_=`ISO8601`) Start date of data set</li><li>**opts.endDate**: (_optional_, _format_=`ISO8601`) End date of data set</li><li>**opts.transactionId**: (_optional_) Filter data set by TXID</li><li>**opts.address**: (_optional_) Filter data set by address</li></ul> | User's list of all withdrawals |
|
|
72
|
+
| `requestWithdrawal` | <ul><li>**currency**: Currency code e.g. `xht`</li><li>**amount**: Withdrawal amount</li><li>**address**: Address to withdrawal to</li><li>**opts**: Object with additional params</li><li>**opts.network**: (_required if asset has multiple networks_) Blockchain network to create address for e.g. `trx`</li><li>**opts.otpCode**: (_required if user has otp enabled_) User otp code</li></ul> | Create a new withdrawal request |
|
|
73
|
+
| `getUserTrades` | <ul><li>**opts**: Object with additional params</li><li>**opts.symbol**: (_optional_) HollaEx trading symbol e.g. `xht-usdt`</li><li>**opts.limit**: (_optional_, _default_=`50`, _max_=`50`) Number of items to get</li><li>**opts.page**: (_optional_, _default_=`1`) Page number of data</li><li>**opts.orderBy**: (_optional_) Field to order data by</li><li>**opts.order**: (_optional_, _enum_=[`asc`, `desc`]) Specify ascending or descending order</li><li>**opts.startDate**: (_optional_, _format_=`ISO8601`) Start date of data set</li><li>**opts.endDate**: (_optional_, _format_=`ISO8601`) End date of data set</li></ul> | User's list of all trades |
|
|
74
|
+
| `getOrder` | <ul><li>**orderId**: HollaEx Network Order ID</li></ul> | Get specific information about a certain order |
|
|
75
|
+
| `getOrders` | <ul><li>**opts**: Object with additional params</li><li>**opts.symbol**: (_optional_) HollaEx trading symbol e.g. `xht-usdt`</li><li>**opts.side**: (_optional_, _enum_=[`buy`, `sell`]) Order side</li><li>**opts.status**: (_optional_) Filter data set `status`</li><li>**opts.limit**: (_optional_, _default_=`50`, _max_=`50`) Number of items to get</li><li>**opts.page**: (_optional_, _default_=`1`) Page number of data</li><li>**opts.orderBy**: (_optional_) Field to order data by</li><li>**opts.order**: (_optional_, _enum_=[`asc`, `desc`])</li><li>**opts.startDate**: (_optional_, _format_=`ISO8601`) Start date of data set</li><li>**opts.endDate**: (_optional_, _format_=`ISO8601`) End date of data set</li></ul> | Get the list of all user orders. It can be filter by passing the symbol |
|
|
76
|
+
| `createOrder` | <ul><li>**symbol**: HollaEx trading symbol e.g. `xht-usdt`</li><li>**side** (_enum_=[`buy`, `sell`]): Order side</li><li>**size**: Size of order to place</li><li>**type**: (_enum_=[`market`, `limit`] Order type</li><li>**price**: (_required if limit order type_) Order price</li><li>**opts**: Object with additional params</li><li>**opts.stop**: (_optional_) Stop price for order</li><li>**opts.meta**: (_optional_) Object with additional meta configurations</li><li>**opts.meta.post_only**: (_optional_, _default_=`false`) Make post only order </li><li>**opts.meta.note**: (_optional_) Custom note for order</li></ul> | Create a new order |
|
|
77
|
+
| `cancelOrder` | <ul><li>**orderId**: HollaEx Network order ID</li></ul> | Cancel a specific order with its ID |
|
|
78
|
+
| `cancelAllOrders` | <ul><li>**symbol**: HollaEx trading symbol e.g. `xht-usdt`</li></ul> | Cancel all the active orders of a user, filtered by currency pair symbol |
|
|
70
79
|
|
|
71
80
|
### Websocket
|
|
72
81
|
|
|
73
|
-
####
|
|
82
|
+
#### Functions
|
|
74
83
|
|
|
75
84
|
You can connect and subscribe to different websocket channels for realtime updates.
|
|
76
85
|
|
|
77
|
-
To connect, use the `connect` function with the
|
|
86
|
+
To connect, use the `connect` function with the channels you want to subscribe to in an array as the parameter. The connection will reconnect on it's own unless you call `disconnect`.
|
|
78
87
|
|
|
79
|
-
```
|
|
80
|
-
|
|
88
|
+
```javascript
|
|
89
|
+
client.connect(['orderbook', 'trade']);
|
|
81
90
|
```
|
|
82
91
|
|
|
83
|
-
To disconnect the websocket, call `disconnect
|
|
92
|
+
To disconnect the websocket, call `disconnect`.
|
|
84
93
|
|
|
85
|
-
```
|
|
86
|
-
|
|
94
|
+
```javascript
|
|
95
|
+
client.disconnect();
|
|
87
96
|
```
|
|
88
97
|
|
|
89
|
-
|
|
98
|
+
To subscribe to more channels after connection, use `subscribe`.
|
|
90
99
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
- `trades`
|
|
95
|
-
- `user` (Private updates for the user such as balance, user orders etc as explained below)
|
|
96
|
-
- `all` (Subscribes to all events)
|
|
97
|
-
|
|
98
|
-
For public channels (`orderbook`, `trades`), you can subscribe to specific symbols as follows:
|
|
99
|
-
`orderbook:xht-usdt`, `trades:xht-usdt`.
|
|
100
|
-
|
|
101
|
-
#### Events
|
|
100
|
+
```javascript
|
|
101
|
+
client.subscribe(['order', 'wallet']);
|
|
102
|
+
```
|
|
102
103
|
|
|
103
|
-
|
|
104
|
+
To unsubscribe from channels after connection, use `unsubscribe`.
|
|
104
105
|
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
console.log(data);
|
|
108
|
-
});
|
|
106
|
+
```javascript
|
|
107
|
+
client.unsubscribe(['orderbook']);
|
|
109
108
|
```
|
|
110
109
|
|
|
111
|
-
|
|
110
|
+
#### Channels
|
|
112
111
|
|
|
113
|
-
|
|
112
|
+
Here is the list of channels you can subscribe to:
|
|
114
113
|
|
|
115
|
-
|
|
116
|
-
- `
|
|
117
|
-
- `
|
|
118
|
-
- `
|
|
119
|
-
- `connect_error` is emitted when there is an error while the socket connects.
|
|
120
|
-
- `connect_timeout` is emitted when the socket connection times out.
|
|
114
|
+
- `orderbook`
|
|
115
|
+
- `trades`
|
|
116
|
+
- `order` (Only available with authentication. Receive order updates)
|
|
117
|
+
- `wallet` (Only available with authentication. Receive balance updates)
|
|
121
118
|
|
|
122
|
-
|
|
119
|
+
For public channels (`orderbook`, `trade`), you can subscribe to specific symbols as follows:
|
|
120
|
+
`orderbook:xht-usdt`, `trade:xht-usdt`. Not passing a symbol will subscribe to all symbols.
|
|
123
121
|
|
|
124
|
-
|
|
122
|
+
#### Events
|
|
125
123
|
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
After connecting to the websocket, you can listen for events coming from the server by using the `on` function for the `ws` property of the client.
|
|
125
|
+
The events available are default websocket events e.g. `message`, `open`, `close`, `error`, `unexpected-response`, etc.
|
|
128
126
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
socket.on('userOrder', (data) => {
|
|
133
|
-
console.log(data);
|
|
134
|
-
});
|
|
135
|
-
socket.on('userTrade', (data) => {
|
|
136
|
-
console.log(data);
|
|
137
|
-
});
|
|
138
|
-
socket.on('userWallet', (data) => {
|
|
139
|
-
console.log(data);
|
|
140
|
-
});
|
|
141
|
-
socket.on('userUpdate', (data) => {
|
|
127
|
+
```javascript
|
|
128
|
+
client.ws.on('message', (data) => {
|
|
129
|
+
data = JSON.parse(data);
|
|
142
130
|
console.log(data);
|
|
143
131
|
});
|
|
144
132
|
```
|
|
145
133
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
- _withdrawal_: When user performs a withdrawal in his account. Status = pending or completed
|
|
329
|
-
|
|
330
|
-
```json
|
|
331
|
-
{
|
|
332
|
-
"action": "update",
|
|
333
|
-
"type": "withdrawal",
|
|
334
|
-
"data": {
|
|
335
|
-
"amount": 5000,
|
|
336
|
-
"currency": "xht",
|
|
337
|
-
"status": true
|
|
338
|
-
},
|
|
339
|
-
"balance": {
|
|
340
|
-
"usdt_balance": 0,
|
|
341
|
-
"xht_balance": 300000,
|
|
342
|
-
"updated_at": "2017-07-26T13:20:40.464Z"
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
```
|
|
346
|
-
|
|
134
|
+
These are exapmles of data responses from the server.
|
|
135
|
+
|
|
136
|
+
- **orderbook**: Updates related to the user's private information are as follows:
|
|
137
|
+
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"topic": "orderbook",
|
|
141
|
+
"action": "partial",
|
|
142
|
+
"symbol": "xht-usdt",
|
|
143
|
+
"data": {
|
|
144
|
+
"bids": [
|
|
145
|
+
[0.1, 0.1],
|
|
146
|
+
...
|
|
147
|
+
],
|
|
148
|
+
"asks": [
|
|
149
|
+
[1, 1],
|
|
150
|
+
...
|
|
151
|
+
],
|
|
152
|
+
"timestamp": "2020-12-15T06:45:27.766Z"
|
|
153
|
+
},
|
|
154
|
+
"time": 1608015328
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
- **trade**: Updates related to the user's private information are as follows:
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"topic": "trade",
|
|
163
|
+
"action": "partial",
|
|
164
|
+
"symbol": "xht-usdt",
|
|
165
|
+
"data": [
|
|
166
|
+
{
|
|
167
|
+
"size": 0.012,
|
|
168
|
+
"price": 300,
|
|
169
|
+
"side": "buy",
|
|
170
|
+
"timestamp": "2020-12-15T07:25:28.887Z"
|
|
171
|
+
},
|
|
172
|
+
...
|
|
173
|
+
],
|
|
174
|
+
"time": 1608015328
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
- **wallet**: Updates related to the user's private information are as follows:
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"topic": "wallet",
|
|
183
|
+
"action": "partial",
|
|
184
|
+
"user_id": 1,
|
|
185
|
+
"data": {
|
|
186
|
+
"usdt_balance": 1,
|
|
187
|
+
"usdt_available": 1,
|
|
188
|
+
"xht_balance": 1,
|
|
189
|
+
"xht_available": 1,
|
|
190
|
+
"xmr_balance": 1,
|
|
191
|
+
"xmr_available": 1,
|
|
192
|
+
"btc_balance": 1,
|
|
193
|
+
"btc_available": 1,
|
|
194
|
+
"eth_balance": 1,
|
|
195
|
+
"eth_available": 1,
|
|
196
|
+
...,
|
|
197
|
+
"updated_at": "2020-12-15T08:41:24.048Z"
|
|
198
|
+
},
|
|
199
|
+
"time": 1608021684
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
- **order**: Websocket messages relating the the user's orders.
|
|
204
|
+
- The `status` of the order can be `new`, `pfilled`, `filled`, and `canceled`.
|
|
205
|
+
- The `action` of the data determines what caused it to happen. All three are explained below:
|
|
206
|
+
|
|
207
|
+
- `partial`: All previous and current orders. Is the first order data received when connecting. Max: 50. Descending order.
|
|
208
|
+
|
|
209
|
+
```json
|
|
210
|
+
{
|
|
211
|
+
"topic": "order",
|
|
212
|
+
"action": "partial",
|
|
213
|
+
"user_id": 1,
|
|
214
|
+
"data": [
|
|
215
|
+
{
|
|
216
|
+
"id": "7d3d9545-b7e6-4e7f-84a0-a39efa4cb173",
|
|
217
|
+
"side": "buy",
|
|
218
|
+
"symbol": "xht-usdt",
|
|
219
|
+
"type": "limit",
|
|
220
|
+
"size": 0.1,
|
|
221
|
+
"filled": 0,
|
|
222
|
+
"price": 1,
|
|
223
|
+
"stop": null,
|
|
224
|
+
"status": "new",
|
|
225
|
+
"fee": 0,
|
|
226
|
+
"fee_coin": "xht",
|
|
227
|
+
"meta": {},
|
|
228
|
+
"fee_structure": {
|
|
229
|
+
"maker": 0.1,
|
|
230
|
+
"taker": 0.1
|
|
231
|
+
},
|
|
232
|
+
"created_at": "2020-11-30T07:45:43.819Z",
|
|
233
|
+
"created_by": 1
|
|
234
|
+
},
|
|
235
|
+
...
|
|
236
|
+
],
|
|
237
|
+
"time": 1608022610
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
- `insert`: When user's order is added. The status of the order can be either `new`, `pfilled`, or `filled`.
|
|
242
|
+
|
|
243
|
+
```json
|
|
244
|
+
{
|
|
245
|
+
"topic": "order",
|
|
246
|
+
"action": "insert",
|
|
247
|
+
"user_id": 1,
|
|
248
|
+
"symbol": "xht-usdt",
|
|
249
|
+
"data": [
|
|
250
|
+
{
|
|
251
|
+
"id": "7d3d9545-b7e6-4e7f-84a0-a39efa4cb173",
|
|
252
|
+
"side": "buy",
|
|
253
|
+
"symbol": "xht-usdt",
|
|
254
|
+
"type": "limit",
|
|
255
|
+
"size": 0.1,
|
|
256
|
+
"filled": 0,
|
|
257
|
+
"price": 1,
|
|
258
|
+
"stop": null,
|
|
259
|
+
"status": "new",
|
|
260
|
+
"fee": 0,
|
|
261
|
+
"fee_coin": "xht",
|
|
262
|
+
"meta": {},
|
|
263
|
+
"fee_structure": {
|
|
264
|
+
"maker": 0.1,
|
|
265
|
+
"taker": 0.1
|
|
266
|
+
},
|
|
267
|
+
"created_at": "2020-11-30T07:45:43.819Z",
|
|
268
|
+
"updated_at": "2020-12-15T08:56:45.066Z",
|
|
269
|
+
"created_by": 1
|
|
270
|
+
},
|
|
271
|
+
...
|
|
272
|
+
],
|
|
273
|
+
"time": 1608022610
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
- `update`: When user's order status is updated. Status can be `pfilled`, `filled`, and `canceled`.
|
|
278
|
+
|
|
279
|
+
```json
|
|
280
|
+
{
|
|
281
|
+
"topic": "order",
|
|
282
|
+
"action": "insert",
|
|
283
|
+
"user_id": 1,
|
|
284
|
+
"symbol": "xht-usdt",
|
|
285
|
+
"data": [
|
|
286
|
+
{
|
|
287
|
+
"id": "7d3d9545-b7e6-4e7f-84a0-a39efa4cb173",
|
|
288
|
+
"side": "buy",
|
|
289
|
+
"symbol": "xht-usdt",
|
|
290
|
+
"type": "limit",
|
|
291
|
+
"size": 0.1,
|
|
292
|
+
"filled": 0,
|
|
293
|
+
"price": 1,
|
|
294
|
+
"stop": null,
|
|
295
|
+
"status": "new",
|
|
296
|
+
"fee": 0,
|
|
297
|
+
"fee_coin": "xht",
|
|
298
|
+
"meta": {},
|
|
299
|
+
"fee_structure": {
|
|
300
|
+
"maker": 0.1,
|
|
301
|
+
"taker": 0.1
|
|
302
|
+
},
|
|
303
|
+
"created_at": "2020-11-30T07:45:43.819Z",
|
|
304
|
+
"updated_at": "2020-12-15T08:56:45.066Z",
|
|
305
|
+
"created_by": 1
|
|
306
|
+
},
|
|
307
|
+
...
|
|
308
|
+
],
|
|
309
|
+
"time": 1608022610
|
|
310
|
+
}
|
|
311
|
+
```
|
|
347
312
|
## Example
|
|
348
313
|
|
|
349
314
|
You can run the example by going to example folder and running:
|
|
350
315
|
|
|
351
|
-
```
|
|
316
|
+
```bash
|
|
352
317
|
node example/hollaex.js
|
|
353
318
|
```
|
|
354
319
|
|