hollaex-node-lib 2.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 ADDED
@@ -0,0 +1,59 @@
1
+ kind: pipeline
2
+ type: docker
3
+ name: slack_notify
4
+
5
+ steps:
6
+ - name: partymaker_version_tag_testnet
7
+ image: alpine
8
+ commands:
9
+ - export PACKAGE_VERSION="$(grep version package.json | cut -c 14- | rev | cut -c 3- | rev)" && echo "$PACKAGE_VERSION" > .tags
10
+ - echo "Current version tag is :" && cat .tags
11
+ when:
12
+ branch: master
13
+
14
+ - name: partymaker_version_tag
15
+ image: alpine
16
+ commands:
17
+ - export PACKAGE_VERSION="$(grep version package.json | cut -c 14- | rev | cut -c 3- | rev)" && echo "$PACKAGE_VERSION-testnet" > .tags
18
+ - echo "Current version tag is :" && cat .tags
19
+ when:
20
+ branch: testnet
21
+
22
+ - name: create_github_release
23
+ image: bitholla/devops-tools:drone_github_hub-2004241546
24
+ environment:
25
+ GITHUB_TOKEN:
26
+ from_secret: github_oauth2_token_for_releases
27
+ commands:
28
+ - apt-get update && apt-get install -y hub git
29
+ - hub release create -m "HollaEx Kit v$(cat .tags) Release" -t ${DRONE_BRANCH} $(cat .tags)
30
+ when:
31
+ branch: master
32
+
33
+ - name: slack_noti_to_releases
34
+ image: bitholla/devops-tools:drone_partymaker-0.1.4
35
+ environment:
36
+ WEBHOOK_URL:
37
+ from_secret: webhook_url
38
+ when:
39
+ status: [success]
40
+
41
+ - name: notify_to_discord_releases
42
+ image: bitholla/devops-tools:drone_partymaker-0.1.5
43
+ channel: deployment
44
+ settings:
45
+ target: discord
46
+ release_name: hollaex-node-lib
47
+ environment:
48
+ WEBHOOK_URL:
49
+ from_secret: discord_webhook_url
50
+ when:
51
+ status: [ success, failure ]
52
+ branch: master
53
+
54
+ trigger:
55
+ branch:
56
+ - master
57
+ - testnet
58
+ event:
59
+ - push
package/.editorconfig ADDED
@@ -0,0 +1,10 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ insert_final_newline = true
7
+
8
+ [*.{js,json}]
9
+ indent_style = tab
10
+ indent_size = 4
package/.eslintrc.json CHANGED
@@ -12,6 +12,9 @@
12
12
  "linebreak-style": ["error", "unix"],
13
13
  "quotes": ["error", "single"],
14
14
  "semi": ["error", "always"],
15
+ "indent": ["error", "tab"],
16
+ "arrow-parens": ["error", "always"],
17
+ "object-curly-spacing": ["error", "always"],
15
18
  "no-console": 0
16
19
  }
17
20
  }
package/README.md CHANGED
@@ -2,20 +2,20 @@
2
2
 
3
3
  Nodejs library for HollaEx Kit enabled exchanges.
4
4
 
5
- **This documentation is specifically for using this library to connect to HollaEx Kit enabled exchanges. If you are an exchange operator and would like to use this library for the HollaEx Network, [click here](NETWORK_README.md)**
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.**
6
6
 
7
7
  ## Usage
8
8
 
9
9
  ```javascript
10
- const { Kit } = require('hollaex-node-lib');
10
+ const hollaex = require('hollaex-node-lib');
11
11
 
12
- const client = new Kit();
12
+ const client = new hollaex();
13
13
  ```
14
14
 
15
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.
16
16
 
17
17
  ```javascript
18
- const client = new Kit({
18
+ const client = new hollaex({
19
19
  apiURL: '<EXCHANGE_API_URL>',
20
20
  baseURL: '<EXCHANGE_BASE_URL>',
21
21
  apiKey: '<MY_API_KEY>',
@@ -28,7 +28,7 @@ You can also pass the field `apiExpiresAfter` which is the length of time in sec
28
28
  ### Example:
29
29
 
30
30
  ```javascript
31
- const client = new Kit({
31
+ const client = new hollaex({
32
32
  apiURL: '<EXCHANGE_API_URL>',
33
33
  baseURL: '<EXCHANGE_BASE_URL>',
34
34
  apiKey: '<MY_API_KEY>',
@@ -56,28 +56,26 @@ client
56
56
 
57
57
  ### Available functions:
58
58
 
59
- - **Optional parameters are all contained within an object parameter called `opts`**
60
-
61
59
  | Command | Parameters | Description |
62
60
  | - | - | - |
63
61
  | `getKit` | | Get exchange information e.g. name, valid languages, description, etc. |
64
62
  | `getConstants` | | Tick size, min price, max price, min size and max size of each symbol pair and coin |
65
- | `getTicker` | **symbol** | Last, high, low, open and close price and volume within the last 24 hours |
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 |
66
64
  | `getTickers` | | Last, high, low, open and close price and volume within the last 24 hours for all symbols |
67
- | `getOrderbook` | **symbol** | Orderbook containing list of bids and asks |
65
+ | `getOrderbook` | <ul><li>**symbol**: HollaEx trading symbol e.g. `xht-usdt`</li></ul> | Orderbook containing list of bids and asks |
68
66
  | `getOrderbooks` | | Orderbook containing list of bids and asks for all symbols |
69
- | `getTrades` | **symbol** (_optional_) | List of last trades |
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 |
70
68
  | `getUser` | | User's personal information |
71
69
  | `getBalance` | | User's wallet balance |
72
- | `getDeposits` | **currency** (_optional_), **status** (_optional_), **dismissed** (_optional_), **rejected** (_optional_), **processing** (_optional_), **waiting** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`), **transactionId** (_optional_), **address** (_optional_) | User's list of all deposits |
73
- | `getWithdrawals` | **currency** (_optional_), **status** (_optional_), **dismissed** (_optional_), **rejected** (_optional_), **processing** (_optional_), **waiting** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`), **transactionId** (_optional_), **address** (_optional_) | User's list of all withdrawals |
74
- | `requestWithdrawal` | **currency**, **amount**, **address**, **network** (_optional_), **otpCode** (_optional_) | Create a new withdrawal request |
75
- | `getUserTrades` | **symbol** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`desc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | User's list of all trades |
76
- | `getOrder` | **orderId** | Get specific information about a certain order |
77
- | `getOrders` | **symbol** (_optional_), **side** (_optional_), **status** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`desc`, _enum_=`asc`, `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | Get the list of all user orders. It can be filter by passing the symbol |
78
- | `createOrder` | **symbol**, **side** (`buy` or `sell`), **size**, **type** (`market` or `limit`), **price**, **stop** (_optional_), **meta** (_optional_, object with optional properties e.g. `post_only`) | Create a new order |
79
- | `cancelOrder` | **orderId** | Cancel a specific order with its ID |
80
- | `cancelAllOrders` | **symbol** (_optional_) | Cancel all open order. It can be filter by passing the symbol |
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 |
81
79
 
82
80
  ### Websocket
83
81
 
@@ -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((res) => {
11
- let data = JSON.parse(res);
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
- const socket1 = client.connect('trades:xht-usdt');
25
+ client.connect(['orderbook']);
26
26
 
27
- socket1.on('trades', (data) => {
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
- socket2.disconnect();
45
- }, 5000);
35
+ client.disconnect();
36
+ }, 10000);
package/index.js CHANGED
@@ -1,9 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  const Kit = require('./kit');
4
- const Network = require('./network');
5
4
 
6
- module.exports = {
7
- Kit,
8
- Network
9
- };
5
+ // To maintain backwards compatibility for `const { Kit } = require("hollaex-node-lib")`
6
+ class BackwardsCompatibleKit extends Kit {
7
+ static get Kit() {
8
+ return Kit;
9
+ }
10
+ }
11
+
12
+ module.exports = BackwardsCompatibleKit;
package/kit.js CHANGED
@@ -2,10 +2,9 @@
2
2
 
3
3
  const WebSocket = require('ws');
4
4
  const moment = require('moment');
5
- const { createRequest, createSignature, generateHeaders } = require('./utils');
5
+ const { createRequest, createSignature, generateHeaders, isDatetime, sanitizeDate } = require('./utils');
6
6
  const { setWsHeartbeat } = require('ws-heartbeat/client');
7
7
  const { each, union, isNumber, isString, isPlainObject, isBoolean } = require('lodash');
8
-
9
8
  class HollaExKit {
10
9
  constructor(
11
10
  opts = {
@@ -178,10 +177,10 @@ class HollaExKit {
178
177
  * @param {boolean} opts.waiting - Waiting status of the deposits to get. Leave blank to get all waiting and unwaiting deposits
179
178
  * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50
180
179
  * @param {number} opts.page - Page of trades data. Default: 1
181
- * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id
182
- * @param {string} opts.order - Ascending (asc) or descending (desc). Default: asc
183
- * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0
184
- * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format
180
+ * @param {string} opts.orderBy - The field to order data by e.g. amount, id.
181
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
182
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
183
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
185
184
  * @param {string} opts.transactionId - Deposits with specific transaction ID.
186
185
  * @param {string} opts.address - Deposits with specific address.
187
186
  * @return {object} A JSON object with the keys count(total number of user's deposits) and data(array of deposits as objects with keys id(number), type(string), amount(number), transaction_id(string), currency(string), created_at(string), status(boolean), fee(number), dismissed(boolean), rejected(boolean), description(string))
@@ -194,12 +193,12 @@ class HollaExKit {
194
193
  rejected: null,
195
194
  processing: null,
196
195
  waiting: null,
197
- limit: 50,
198
- page: 1,
199
- orderBy: 'id',
200
- order: 'asc',
201
- startDate: 0,
202
- endDate: moment().toISOString(),
196
+ limit: null,
197
+ page: null,
198
+ orderBy: null,
199
+ order: null,
200
+ startDate: null,
201
+ endDate: null,
203
202
  transactionId: null,
204
203
  address: null
205
204
  }
@@ -227,12 +226,12 @@ class HollaExKit {
227
226
  path += `&order=${opts.order}`;
228
227
  }
229
228
 
230
- if (isString(opts.startDate)) {
231
- path += `&start_date=${opts.startDate}`;
229
+ if (isDatetime(opts.startDate)) {
230
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
232
231
  }
233
232
 
234
- if (isString(opts.endDate)) {
235
- path += `&end_date=${opts.endDate}`;
233
+ if (isDatetime(opts.endDate)) {
234
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
236
235
  }
237
236
 
238
237
  if (isString(opts.address)) {
@@ -285,10 +284,10 @@ class HollaExKit {
285
284
  * @param {boolean} opts.waiting - Waiting status of the withdrawals to get. Leave blank to get all waiting and unwaiting withdrawals
286
285
  * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50
287
286
  * @param {number} opts.page - Page of trades data. Default: 1
288
- * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id
289
- * @param {string} opts.order - Ascending (asc) or descending (desc). Default: asc
290
- * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0
291
- * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format
287
+ * @param {string} opts.orderBy - The field to order data by e.g. amount, id.
288
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
289
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
290
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
292
291
  * @param {string} opts.transactionId - Withdrawals with specific transaction ID.
293
292
  * @param {string} opts.address - Withdrawals with specific address.
294
293
  * @return {object} A JSON object with the keys count(total number of user's withdrawals) and data(array of withdrawals as objects with keys id(number), type(string), amount(number), transaction_id(string), currency(string), created_at(string), status(boolean), fee(number), dismissed(boolean), rejected(boolean), description(string))
@@ -301,12 +300,12 @@ class HollaExKit {
301
300
  rejected: null,
302
301
  processing: null,
303
302
  waiting: null,
304
- limit: 50,
305
- page: 1,
306
- orderBy: 'id',
307
- order: 'asc',
308
- startDate: 0,
309
- endDate: moment().toISOString(),
303
+ limit: null,
304
+ page: null,
305
+ orderBy: null,
306
+ order: null,
307
+ startDate: null,
308
+ endDate: null,
310
309
  transactionId: null,
311
310
  address: null
312
311
  }
@@ -334,12 +333,12 @@ class HollaExKit {
334
333
  path += `&order=${opts.order}`;
335
334
  }
336
335
 
337
- if (isString(opts.startDate)) {
338
- path += `&start_date=${opts.startDate}`;
336
+ if (isDatetime(opts.startDate)) {
337
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
339
338
  }
340
339
 
341
- if (isString(opts.endDate)) {
342
- path += `&end_date=${opts.endDate}`;
340
+ if (isDatetime(opts.endDate)) {
341
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
343
342
  }
344
343
 
345
344
  if (isString(opts.address)) {
@@ -418,30 +417,32 @@ class HollaExKit {
418
417
  this.apiExpiresAfter,
419
418
  data
420
419
  );
421
- return createRequest(verb, `${this.apiUrl}${path}`, headers, data);
420
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
422
421
  }
423
422
 
424
423
  /**
425
424
  * Retrieve list of the user's completed trades
426
425
  * @param {object} opts - Optional parameters
427
426
  * @param {string} opts.symbol - The symbol-pair to filter by, pass undefined to receive data on all currencies
428
- * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50
429
- * @param {number} opts.page - Page of trades data. Default: 1
427
+ * @param {number} opts.limit - Amount of trades per page
428
+ * @param {number} opts.page - Page of trades data
430
429
  * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id
431
430
  * @param {string} opts.order - Ascending (asc) or descending (desc). Default: desc
432
- * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0
433
- * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format
431
+ * @param {string} opts.startDate - Start date of query in ISO8601 format
432
+ * @param {string} opts.endDate - End date of query in ISO8601 format
433
+ * @param {string} opts.format - Custom format of data set. Enum: ['all', 'csv']
434
434
  * @return {object} A JSON object with the keys count(total number of user's completed trades) and data(array of up to the user's last 50 completed trades as objects with keys side(string), symbol(string), size(number), price(number), timestamp(string), and fee(number))
435
435
  */
436
436
  getUserTrades(
437
437
  opts = {
438
438
  symbol: null,
439
- limit: 50,
440
- page: 1,
441
- orderBy: 'id',
442
- order: 'desc',
443
- startDate: 0,
444
- endDate: moment().toISOString()
439
+ limit: null,
440
+ page: null,
441
+ orderBy: null,
442
+ order: null,
443
+ startDate: null,
444
+ endDate: null,
445
+ format: null
445
446
  }
446
447
  ) {
447
448
  const verb = 'GET';
@@ -467,12 +468,16 @@ class HollaExKit {
467
468
  path += `&order=${opts.order}`;
468
469
  }
469
470
 
470
- if (isString(opts.startDate)) {
471
- path += `&start_date=${opts.startDate}`;
471
+ if (isDatetime(opts.startDate)) {
472
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
473
+ }
474
+
475
+ if (isDatetime(opts.endDate)) {
476
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
472
477
  }
473
478
 
474
- if (isString(opts.endDate)) {
475
- path += `&end_date=${opts.endDate}`;
479
+ if (isString(opts.format)) {
480
+ path += `&format=${opts.format}`;
476
481
  }
477
482
 
478
483
  const headers = generateHeaders(
@@ -482,6 +487,7 @@ class HollaExKit {
482
487
  path,
483
488
  this.apiExpiresAfter
484
489
  );
490
+
485
491
  return createRequest(verb, `${this.apiUrl}${path}`, headers);
486
492
  }
487
493
 
@@ -510,10 +516,10 @@ class HollaExKit {
510
516
  * @param {string} opts.symbol - The currency pair symbol to filter by e.g. 'hex-usdt', leave empty to retrieve information of orders of all symbols
511
517
  * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50
512
518
  * @param {number} opts.page - Page of trades data. Default: 1
513
- * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id
514
- * @param {string} opts.order - Ascending (asc) or descending (desc). Default: desc
515
- * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0
516
- * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format
519
+ * @param {string} opts.orderBy - The field to order data by e.g. amount, id.
520
+ * @param {string} opts.order - Ascending (asc) or descending (desc).
521
+ * @param {string} opts.startDate - Start date of query in ISO8601 format.
522
+ * @param {string} opts.endDate - End date of query in ISO8601 format.
517
523
  * @return {object} A JSON array of objects containing the user's active orders
518
524
  */
519
525
  getOrders(
@@ -522,12 +528,12 @@ class HollaExKit {
522
528
  side: null,
523
529
  status: null,
524
530
  open: null,
525
- limit: 50,
526
- page: 1,
527
- orderBy: 'id',
528
- order: 'desc',
529
- startDate: 0,
530
- endDate: moment().toISOString()
531
+ limit: null,
532
+ page: null,
533
+ orderBy: null,
534
+ order: null,
535
+ startDate: null,
536
+ endDate: null
531
537
  }
532
538
  ) {
533
539
  const verb = 'GET';
@@ -565,12 +571,12 @@ class HollaExKit {
565
571
  path += `&order=${opts.order}`;
566
572
  }
567
573
 
568
- if (isString(opts.startDate)) {
569
- path += `&start_date=${opts.startDate}`;
574
+ if (isDatetime(opts.startDate)) {
575
+ path += `&start_date=${sanitizeDate(opts.startDate)}`;
570
576
  }
571
577
 
572
- if (isString(opts.endDate)) {
573
- path += `&end_date=${opts.endDate}`;
578
+ if (isDatetime(opts.endDate)) {
579
+ path += `&end_date=${sanitizeDate(opts.endDate)}`;
574
580
  }
575
581
 
576
582
  const headers = generateHeaders(
@@ -593,6 +599,8 @@ class HollaExKit {
593
599
  * @param {object} opts - Optional parameters
594
600
  * @param {number} opts.stop - Stop order price
595
601
  * @param {object} opts.meta - Additional meta parameters in an object
602
+ * @param {boolean} opts.meta.post_only - Whether or not the order should only be made if market maker.
603
+ * @param {string} opts.meta.note - Additional note to add to order data.
596
604
  * @return {object} The new order as a JSON object with keys symbol(string), side(string), size(number), type(string), price(number), id(string), created_by(number), and filled(number)
597
605
  */
598
606
  createOrder(
@@ -626,7 +634,7 @@ class HollaExKit {
626
634
  this.apiExpiresAfter,
627
635
  data
628
636
  );
629
- return createRequest(verb, `${this.apiUrl}${path}`, headers, data);
637
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
630
638
  }
631
639
 
632
640
  /**
@@ -782,38 +790,21 @@ class HollaExKit {
782
790
  if (!this.wsEvents.includes(event) || this.initialConnection) {
783
791
  const [topic, symbol] = event.split(':');
784
792
  switch (topic) {
785
- case 'orderbook':
786
- case 'trade':
787
- if (symbol) {
788
- if (!this.wsEvents.includes(topic)) {
789
- this.ws.send(
790
- JSON.stringify({
791
- op: 'subscribe',
792
- args: [`${topic}:${symbol}`]
793
- })
794
- );
795
- if (!this.initialConnection) {
796
- this.wsEvents = union(this.wsEvents, [event]);
797
- }
798
- }
799
- } else {
793
+ case 'orderbook':
794
+ case 'trade':
795
+ if (symbol) {
796
+ if (!this.wsEvents.includes(topic)) {
800
797
  this.ws.send(
801
798
  JSON.stringify({
802
799
  op: 'subscribe',
803
- args: [topic]
800
+ args: [`${topic}:${symbol}`]
804
801
  })
805
802
  );
806
803
  if (!this.initialConnection) {
807
- this.wsEvents = this.wsEvents.filter(
808
- (e) => !e.includes(`${topic}:`)
809
- );
810
804
  this.wsEvents = union(this.wsEvents, [event]);
811
805
  }
812
806
  }
813
- break;
814
- case 'order':
815
- case 'wallet':
816
- case 'deposit':
807
+ } else {
817
808
  this.ws.send(
818
809
  JSON.stringify({
819
810
  op: 'subscribe',
@@ -821,11 +812,28 @@ class HollaExKit {
821
812
  })
822
813
  );
823
814
  if (!this.initialConnection) {
815
+ this.wsEvents = this.wsEvents.filter(
816
+ (e) => !e.includes(`${topic}:`)
817
+ );
824
818
  this.wsEvents = union(this.wsEvents, [event]);
825
819
  }
826
- break;
827
- default:
828
- break;
820
+ }
821
+ break;
822
+ case 'order':
823
+ case 'wallet':
824
+ case 'deposit':
825
+ this.ws.send(
826
+ JSON.stringify({
827
+ op: 'subscribe',
828
+ args: [topic]
829
+ })
830
+ );
831
+ if (!this.initialConnection) {
832
+ this.wsEvents = union(this.wsEvents, [event]);
833
+ }
834
+ break;
835
+ default:
836
+ break;
829
837
  }
830
838
  }
831
839
  });
@@ -844,38 +852,38 @@ class HollaExKit {
844
852
  if (this.wsEvents.includes(event)) {
845
853
  const [topic, symbol] = event.split(':');
846
854
  switch (topic) {
847
- case 'orderbook':
848
- case 'trade':
849
- if (symbol) {
850
- this.ws.send(
851
- JSON.stringify({
852
- op: 'unsubscribe',
853
- args: [`${topic}:${symbol}`]
854
- })
855
- );
856
- } else {
857
- this.ws.send(
858
- JSON.stringify({
859
- op: 'unsubscribe',
860
- args: [topic]
861
- })
862
- );
863
- }
864
- this.wsEvents = this.wsEvents.filter((e) => e !== event);
865
- break;
866
- case 'order':
867
- case 'wallet':
868
- case 'deposit':
855
+ case 'orderbook':
856
+ case 'trade':
857
+ if (symbol) {
858
+ this.ws.send(
859
+ JSON.stringify({
860
+ op: 'unsubscribe',
861
+ args: [`${topic}:${symbol}`]
862
+ })
863
+ );
864
+ } else {
869
865
  this.ws.send(
870
866
  JSON.stringify({
871
867
  op: 'unsubscribe',
872
868
  args: [topic]
873
869
  })
874
870
  );
875
- this.wsEvents = this.wsEvents.filter((e) => e !== event);
876
- break;
877
- default:
878
- break;
871
+ }
872
+ this.wsEvents = this.wsEvents.filter((e) => e !== event);
873
+ break;
874
+ case 'order':
875
+ case 'wallet':
876
+ case 'deposit':
877
+ this.ws.send(
878
+ JSON.stringify({
879
+ op: 'unsubscribe',
880
+ args: [topic]
881
+ })
882
+ );
883
+ this.wsEvents = this.wsEvents.filter((e) => e !== event);
884
+ break;
885
+ default:
886
+ break;
879
887
  }
880
888
  }
881
889
  });