hollaex-node-lib 1.1.0 → 2.12.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/LICENSE +1 -1
- package/README.md +271 -262
- package/example/hollaex.js +7 -16
- package/index.js +7 -446
- package/kit.js +896 -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,36 +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
|
-
You can pass your `apiKey` and `apiSecret` generated from the
|
|
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
|
+
```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>'
|
|
23
|
+
});
|
|
17
24
|
```
|
|
18
25
|
|
|
19
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`.
|
|
20
27
|
|
|
21
|
-
There is a list of functions you can call which will be added later and they are not at this point implemented yet.
|
|
22
|
-
|
|
23
|
-
> - **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.
|
|
24
|
-
|
|
25
28
|
### Example:
|
|
26
29
|
|
|
27
|
-
```
|
|
28
|
-
|
|
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>'
|
|
36
|
+
});
|
|
37
|
+
|
|
29
38
|
client
|
|
30
39
|
.getTicker('xht-usdt')
|
|
31
40
|
.then((res) => {
|
|
32
|
-
|
|
33
|
-
|
|
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);
|
|
34
51
|
})
|
|
35
52
|
.catch((err) => {
|
|
36
53
|
console.log(err);
|
|
@@ -39,272 +56,264 @@ client
|
|
|
39
56
|
|
|
40
57
|
### Available functions:
|
|
41
58
|
|
|
42
|
-
| Command
|
|
43
|
-
|
|
|
44
|
-
| `
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
| `
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
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>**opts**: Object with additional params</li><li>**opts.symbol**: (_optional_) HollaEx trading symbol e.g. `xht-usdt`</li></ul> | Cancel all open order. It can be filter by passing the symbol |
|
|
59
79
|
|
|
60
80
|
### Websocket
|
|
61
81
|
|
|
82
|
+
#### Functions
|
|
83
|
+
|
|
62
84
|
You can connect and subscribe to different websocket channels for realtime updates.
|
|
63
85
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
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`.
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
client.connect(['orderbook', 'trade']);
|
|
69
90
|
```
|
|
70
91
|
|
|
71
|
-
|
|
72
|
-
`orderbook:xht-usdt`
|
|
73
|
-
Here is the list of events you can subscribe:
|
|
92
|
+
To disconnect the websocket, call `disconnect`.
|
|
74
93
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
- all (It subscribes to all events)
|
|
94
|
+
```javascript
|
|
95
|
+
client.disconnect();
|
|
96
|
+
```
|
|
79
97
|
|
|
80
|
-
|
|
98
|
+
To subscribe to more channels after connection, use `subscribe`.
|
|
81
99
|
|
|
82
|
-
```
|
|
83
|
-
|
|
100
|
+
```javascript
|
|
101
|
+
client.subscribe(['order', 'wallet']);
|
|
102
|
+
```
|
|
84
103
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
104
|
+
To unsubscribe from channels after connection, use `unsubscribe`.
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
client.unsubscribe(['orderbook']);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Channels
|
|
111
|
+
|
|
112
|
+
Here is the list of channels you can subscribe to:
|
|
113
|
+
|
|
114
|
+
- `orderbook`
|
|
115
|
+
- `trades`
|
|
116
|
+
- `order` (Only available with authentication. Receive order updates)
|
|
117
|
+
- `wallet` (Only available with authentication. Receive balance updates)
|
|
118
|
+
|
|
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.
|
|
121
|
+
|
|
122
|
+
#### Events
|
|
123
|
+
|
|
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.
|
|
126
|
+
|
|
127
|
+
```javascript
|
|
128
|
+
client.ws.on('message', (data) => {
|
|
129
|
+
data = JSON.parse(data);
|
|
98
130
|
console.log(data);
|
|
99
131
|
});
|
|
100
132
|
```
|
|
101
133
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
- _withdrawal_: When user performs a withdrawal in his account. Status = pending or completed
|
|
285
|
-
|
|
286
|
-
```json
|
|
287
|
-
{
|
|
288
|
-
"action": "update",
|
|
289
|
-
"type": "withdrawal",
|
|
290
|
-
"data": {
|
|
291
|
-
"amount": 5000,
|
|
292
|
-
"currency": "xht",
|
|
293
|
-
"status": true
|
|
294
|
-
},
|
|
295
|
-
"balance": {
|
|
296
|
-
"usdt_balance": 0,
|
|
297
|
-
"xht_balance": 300000,
|
|
298
|
-
"updated_at": "2017-07-26T13:20:40.464Z"
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
```
|
|
302
|
-
|
|
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
|
+
```
|
|
303
312
|
## Example
|
|
304
313
|
|
|
305
314
|
You can run the example by going to example folder and running:
|
|
306
315
|
|
|
307
|
-
```
|
|
316
|
+
```bash
|
|
308
317
|
node example/hollaex.js
|
|
309
318
|
```
|
|
310
319
|
|
package/example/hollaex.js
CHANGED
|
@@ -7,8 +7,8 @@ const client = new HollaEx({ apiKey: API_KEY, apiSecret: API_SECRET });
|
|
|
7
7
|
|
|
8
8
|
client
|
|
9
9
|
.getTicker('xht-usdt')
|
|
10
|
-
.then((
|
|
11
|
-
|
|
10
|
+
.then((data) => {
|
|
11
|
+
console.log(data);
|
|
12
12
|
console.log('The volume is', data.volume);
|
|
13
13
|
})
|
|
14
14
|
.catch((err) => {
|
|
@@ -22,24 +22,15 @@ client
|
|
|
22
22
|
symbols : xht-usdt
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
client.connect(['orderbook']);
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
client.ws.on('message', (data) => {
|
|
28
|
+
data = JSON.parse(data);
|
|
28
29
|
console.log(data);
|
|
29
30
|
});
|
|
30
31
|
|
|
31
|
-
const socket2 = client.connect('all');
|
|
32
|
-
|
|
33
|
-
socket2.on('orderbook', (data) => {
|
|
34
|
-
console.log(data);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// You have to use a token to use these otherwise the socket disconnects
|
|
38
|
-
socket2.on('userInfo', (data) => {
|
|
39
|
-
console.log(data);
|
|
40
|
-
});
|
|
41
32
|
|
|
42
33
|
|
|
43
34
|
setTimeout(() => {
|
|
44
|
-
|
|
45
|
-
},
|
|
35
|
+
client.disconnect();
|
|
36
|
+
}, 10000);
|