ccxt 4.0.89 → 4.0.91

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.
Files changed (56) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1038 -60
  3. package/dist/ccxt.browser.min.js +10 -10
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +62 -0
  6. package/dist/cjs/src/binance.js +7 -2
  7. package/dist/cjs/src/bitmex.js +1 -0
  8. package/dist/cjs/src/mexc.js +3 -1
  9. package/dist/cjs/src/pro/binance.js +190 -15
  10. package/dist/cjs/src/pro/bitget.js +127 -0
  11. package/dist/cjs/src/pro/bitmex.js +46 -0
  12. package/dist/cjs/src/pro/bybit.js +129 -2
  13. package/dist/cjs/src/pro/coinbasepro.js +70 -0
  14. package/dist/cjs/src/pro/cryptocom.js +71 -0
  15. package/dist/cjs/src/pro/gate.js +29 -0
  16. package/dist/cjs/src/pro/krakenfutures.js +4 -2
  17. package/dist/cjs/src/pro/kucoin.js +92 -3
  18. package/dist/cjs/src/pro/kucoinfutures.js +91 -5
  19. package/dist/cjs/src/pro/okx.js +88 -5
  20. package/dist/cjs/src/pro/poloniexfutures.js +2 -1
  21. package/dist/cjs/src/pro/probit.js +4 -2
  22. package/js/ccxt.d.ts +3 -3
  23. package/js/ccxt.js +1 -1
  24. package/js/src/abstract/binance.d.ts +6 -1
  25. package/js/src/abstract/binancecoinm.d.ts +6 -1
  26. package/js/src/abstract/binanceus.d.ts +6 -1
  27. package/js/src/abstract/binanceusdm.d.ts +6 -1
  28. package/js/src/base/Exchange.d.ts +18 -1
  29. package/js/src/base/Exchange.js +62 -0
  30. package/js/src/binance.js +7 -2
  31. package/js/src/bitmex.js +1 -0
  32. package/js/src/mexc.js +3 -1
  33. package/js/src/pro/binance.d.ts +3 -0
  34. package/js/src/pro/binance.js +190 -15
  35. package/js/src/pro/bitget.d.ts +4 -0
  36. package/js/src/pro/bitget.js +127 -0
  37. package/js/src/pro/bitmex.d.ts +1 -0
  38. package/js/src/pro/bitmex.js +46 -0
  39. package/js/src/pro/bybit.d.ts +3 -0
  40. package/js/src/pro/bybit.js +130 -3
  41. package/js/src/pro/coinbasepro.d.ts +2 -0
  42. package/js/src/pro/coinbasepro.js +71 -1
  43. package/js/src/pro/cryptocom.d.ts +3 -0
  44. package/js/src/pro/cryptocom.js +71 -0
  45. package/js/src/pro/gate.d.ts +1 -0
  46. package/js/src/pro/gate.js +29 -0
  47. package/js/src/pro/krakenfutures.js +4 -2
  48. package/js/src/pro/kucoin.d.ts +2 -0
  49. package/js/src/pro/kucoin.js +93 -4
  50. package/js/src/pro/kucoinfutures.d.ts +2 -0
  51. package/js/src/pro/kucoinfutures.js +92 -6
  52. package/js/src/pro/okx.d.ts +2 -0
  53. package/js/src/pro/okx.js +89 -6
  54. package/js/src/pro/poloniexfutures.js +2 -1
  55. package/js/src/pro/probit.js +4 -2
  56. package/package.json +1 -1
@@ -17,6 +17,8 @@ class kucoin extends kucoin$1 {
17
17
  'watchTickers': false,
18
18
  'watchTicker': true,
19
19
  'watchTrades': true,
20
+ 'watchTradesForSymbols': true,
21
+ 'watchOrderBookForSymbols': true,
20
22
  'watchBalance': true,
21
23
  'watchOHLCV': true,
22
24
  },
@@ -291,6 +293,36 @@ class kucoin extends kucoin$1 {
291
293
  }
292
294
  return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
293
295
  }
296
+ async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
297
+ /**
298
+ * @method
299
+ * @name kucoin#watchTrades
300
+ * @description get the list of most recent trades for a particular symbol
301
+ * @param {string} symbol unified symbol of the market to fetch trades for
302
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
303
+ * @param {int} [limit] the maximum amount of trades to fetch
304
+ * @param {object} [params] extra parameters specific to the kucoin api endpoint
305
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/en/latest/manual.html?#public-trades}
306
+ */
307
+ const symbolsLength = symbols.length;
308
+ if (symbolsLength === 0) {
309
+ throw new errors.ArgumentsRequired(this.id + ' watchTradesForSymbols() requires a non-empty array of symbols');
310
+ }
311
+ await this.loadMarkets();
312
+ symbols = this.marketSymbols(symbols);
313
+ const url = await this.negotiate(false);
314
+ symbols = this.marketSymbols(symbols);
315
+ const marketIds = this.marketIds(symbols);
316
+ const topic = '/market/match:' + marketIds.join(',');
317
+ const messageHash = 'multipleTrades::' + symbols.join(',');
318
+ const trades = await this.subscribe(url, messageHash, topic, params);
319
+ if (this.newUpdates) {
320
+ const first = this.safeValue(trades, 0);
321
+ const tradeSymbol = this.safeString(first, 'symbol');
322
+ limit = trades.getLimit(tradeSymbol, limit);
323
+ }
324
+ return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
325
+ }
294
326
  handleTrade(client, message) {
295
327
  //
296
328
  // {
@@ -323,6 +355,8 @@ class kucoin extends kucoin$1 {
323
355
  }
324
356
  trades.append(trade);
325
357
  client.resolve(trades, messageHash);
358
+ // watchMultipleTrades
359
+ this.resolvePromiseIfMessagehashMatches(client, 'multipleTrades::', symbol, trades);
326
360
  }
327
361
  async watchOrderBook(symbol, limit = undefined, params = {}) {
328
362
  /**
@@ -368,6 +402,39 @@ class kucoin extends kucoin$1 {
368
402
  const orderbook = await this.subscribe(url, messageHash, topic, params, subscription);
369
403
  return orderbook.limit();
370
404
  }
405
+ async watchOrderBookForSymbols(symbols, limit = undefined, params = {}) {
406
+ /**
407
+ * @method
408
+ * @name kucoin#watchOrderBookForSymbols
409
+ * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
410
+ * @param {string[]} symbols unified array of symbols
411
+ * @param {int} [limit] the maximum amount of order book entries to return
412
+ * @param {object} [params] extra parameters specific to the kucoin api endpoint
413
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
414
+ */
415
+ const symbolsLength = symbols.length;
416
+ if (symbolsLength === 0) {
417
+ throw new errors.ArgumentsRequired(this.id + ' watchOrderBookForSymbols() requires a non-empty array of symbols');
418
+ }
419
+ if (limit !== undefined) {
420
+ if ((limit !== 20) && (limit !== 100)) {
421
+ throw new errors.ExchangeError(this.id + " watchOrderBook 'limit' argument must be undefined, 20 or 100");
422
+ }
423
+ }
424
+ await this.loadMarkets();
425
+ symbols = this.marketSymbols(symbols);
426
+ const marketIds = this.marketIds(symbols);
427
+ const url = await this.negotiate(false);
428
+ const topic = '/market/level2:' + marketIds.join(',');
429
+ const messageHash = 'multipleOrderbook::' + symbols.join(',');
430
+ const subscription = {
431
+ 'method': this.handleOrderBookSubscription,
432
+ 'symbols': symbols,
433
+ 'limit': limit,
434
+ };
435
+ const orderbook = await this.subscribe(url, messageHash, topic, params, subscription);
436
+ return orderbook.limit();
437
+ }
371
438
  handleOrderBook(client, message) {
372
439
  //
373
440
  // initial snapshot is fetched with ccxt's fetchOrderBook
@@ -398,7 +465,18 @@ class kucoin extends kucoin$1 {
398
465
  if (nonce === undefined) {
399
466
  const cacheLength = storedOrderBook.cache.length;
400
467
  const topic = this.safeString(message, 'topic');
401
- const subscription = client.subscriptions[topic];
468
+ const topicParts = topic.split(':');
469
+ const topicSymbol = this.safeString(topicParts, 1);
470
+ const topicChannel = this.safeString(topicParts, 0);
471
+ const subscriptions = Object.keys(client.subscriptions);
472
+ let subscription = undefined;
473
+ for (let i = 0; i < subscriptions.length; i++) {
474
+ const key = subscriptions[i];
475
+ if ((key.indexOf(topicSymbol) >= 0) && (key.indexOf(topicChannel) >= 0)) {
476
+ subscription = client.subscriptions[key];
477
+ break;
478
+ }
479
+ }
402
480
  const limit = this.safeInteger(subscription, 'limit');
403
481
  const snapshotDelay = this.handleOption('watchOrderBook', 'snapshotDelay', 5);
404
482
  if (cacheLength === snapshotDelay) {
@@ -412,6 +490,8 @@ class kucoin extends kucoin$1 {
412
490
  }
413
491
  this.handleDelta(storedOrderBook, data);
414
492
  client.resolve(storedOrderBook, messageHash);
493
+ // watchMultipleOrderBook
494
+ this.resolvePromiseIfMessagehashMatches(client, 'multipleOrderbook::', symbol, storedOrderBook);
415
495
  }
416
496
  getCacheIndex(orderbook, cache) {
417
497
  const firstDelta = this.safeValue(cache, 0);
@@ -450,9 +530,18 @@ class kucoin extends kucoin$1 {
450
530
  }
451
531
  }
452
532
  handleOrderBookSubscription(client, message, subscription) {
453
- const symbol = this.safeString(subscription, 'symbol');
454
533
  const limit = this.safeInteger(subscription, 'limit');
455
- this.orderbooks[symbol] = this.orderBook({}, limit);
534
+ const symbols = this.safeValue(subscription, 'symbols');
535
+ if (symbols === undefined) {
536
+ const symbol = this.safeString(subscription, 'symbol');
537
+ this.orderbooks[symbol] = this.orderBook({}, limit);
538
+ }
539
+ else {
540
+ for (let i = 0; i < symbols.length; i++) {
541
+ const symbol = symbols[i];
542
+ this.orderbooks[symbol] = this.orderBook({}, limit);
543
+ }
544
+ }
456
545
  // moved snapshot initialization to handleOrderBook to fix
457
546
  // https://github.com/ccxt/ccxt/issues/6820
458
547
  // the general idea is to fetch the snapshot after the first delta
@@ -16,6 +16,8 @@ class kucoinfutures extends kucoinfutures$1 {
16
16
  'watchOrderBook': true,
17
17
  'watchOrders': true,
18
18
  'watchBalance': true,
19
+ 'watchTradesForSymbols': true,
20
+ 'watchOrderBookForSymbols': true,
19
21
  },
20
22
  'options': {
21
23
  'accountsByType': {
@@ -199,6 +201,36 @@ class kucoinfutures extends kucoinfutures$1 {
199
201
  }
200
202
  return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
201
203
  }
204
+ async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
205
+ /**
206
+ * @method
207
+ * @name kucoinfutures#watchTrades
208
+ * @description get the list of most recent trades for a particular symbol
209
+ * @param {string} symbol unified symbol of the market to fetch trades for
210
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
211
+ * @param {int} [limit] the maximum amount of trades to fetch
212
+ * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
213
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/en/latest/manual.html?#public-trades}
214
+ */
215
+ const symbolsLength = symbols.length;
216
+ if (symbolsLength === 0) {
217
+ throw new errors.ArgumentsRequired(this.id + ' watchTradesForSymbols() requires a non-empty array of symbols');
218
+ }
219
+ await this.loadMarkets();
220
+ symbols = this.marketSymbols(symbols);
221
+ const url = await this.negotiate(false);
222
+ symbols = this.marketSymbols(symbols);
223
+ const marketIds = this.marketIds(symbols);
224
+ const topic = '/contractMarket/execution:' + marketIds.join(',');
225
+ const messageHash = 'multipleTrades::' + symbols.join(',');
226
+ const trades = await this.subscribe(url, messageHash, topic, params);
227
+ if (this.newUpdates) {
228
+ const first = this.safeValue(trades, 0);
229
+ const tradeSymbol = this.safeString(first, 'symbol');
230
+ limit = trades.getLimit(tradeSymbol, limit);
231
+ }
232
+ return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
233
+ }
202
234
  handleTrade(client, message) {
203
235
  //
204
236
  // {
@@ -232,6 +264,7 @@ class kucoinfutures extends kucoinfutures$1 {
232
264
  trades.append(trade);
233
265
  const messageHash = 'trades:' + symbol;
234
266
  client.resolve(trades, messageHash);
267
+ this.resolvePromiseIfMessagehashMatches(client, 'multipleTrades::', symbol, trades);
235
268
  return message;
236
269
  }
237
270
  async watchOrderBook(symbol, limit = undefined, params = {}) {
@@ -270,6 +303,39 @@ class kucoinfutures extends kucoinfutures$1 {
270
303
  const orderbook = await this.subscribe(url, messageHash, topic, subscription, params);
271
304
  return orderbook.limit();
272
305
  }
306
+ async watchOrderBookForSymbols(symbols, limit = undefined, params = {}) {
307
+ /**
308
+ * @method
309
+ * @name kucoinfutures#watchOrderBookForSymbols
310
+ * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
311
+ * @param {string[]} symbols unified array of symbols
312
+ * @param {int} [limit] the maximum amount of order book entries to return
313
+ * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
314
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
315
+ */
316
+ const symbolsLength = symbols.length;
317
+ if (symbolsLength === 0) {
318
+ throw new errors.ArgumentsRequired(this.id + ' watchOrderBookForSymbols() requires a non-empty array of symbols');
319
+ }
320
+ if (limit !== undefined) {
321
+ if ((limit !== 20) && (limit !== 100)) {
322
+ throw new errors.ExchangeError(this.id + " watchOrderBook 'limit' argument must be undefined, 20 or 100");
323
+ }
324
+ }
325
+ await this.loadMarkets();
326
+ symbols = this.marketSymbols(symbols);
327
+ const marketIds = this.marketIds(symbols);
328
+ const url = await this.negotiate(false);
329
+ const topic = '/contractMarket/level2:' + marketIds.join(',');
330
+ const messageHash = 'multipleOrderbook::' + symbols.join(',');
331
+ const subscription = {
332
+ 'method': this.handleOrderBookSubscription,
333
+ 'symbols': symbols,
334
+ 'limit': limit,
335
+ };
336
+ const orderbook = await this.subscribe(url, messageHash, topic, subscription, params);
337
+ return orderbook.limit();
338
+ }
273
339
  handleDelta(orderbook, delta) {
274
340
  orderbook['nonce'] = this.safeInteger(delta, 'sequence');
275
341
  const timestamp = this.safeInteger(delta, 'timestamp');
@@ -318,13 +384,23 @@ class kucoinfutures extends kucoinfutures$1 {
318
384
  const marketId = this.safeString(topicParts, 1);
319
385
  const symbol = this.safeSymbol(marketId, undefined, '-');
320
386
  const messageHash = 'orderbook:' + symbol;
321
- const storedOrderBook = this.orderbooks[symbol];
387
+ const storedOrderBook = this.safeValue(this.orderbooks, symbol);
322
388
  const nonce = this.safeInteger(storedOrderBook, 'nonce');
323
389
  const deltaEnd = this.safeInteger(data, 'sequence');
324
390
  if (nonce === undefined) {
325
391
  const cacheLength = storedOrderBook.cache.length;
326
- const topic = this.safeString(message, 'topic');
327
- const subscription = client.subscriptions[topic];
392
+ const topicParts = topic.split(':');
393
+ const topicSymbol = this.safeString(topicParts, 1);
394
+ const topicChannel = this.safeString(topicParts, 0);
395
+ const subscriptions = Object.keys(client.subscriptions);
396
+ let subscription = undefined;
397
+ for (let i = 0; i < subscriptions.length; i++) {
398
+ const key = subscriptions[i];
399
+ if ((key.indexOf(topicSymbol) >= 0) && (key.indexOf(topicChannel) >= 0)) {
400
+ subscription = client.subscriptions[key];
401
+ break;
402
+ }
403
+ }
328
404
  const limit = this.safeInteger(subscription, 'limit');
329
405
  const snapshotDelay = this.handleOption('watchOrderBook', 'snapshotDelay', 5);
330
406
  if (cacheLength === snapshotDelay) {
@@ -338,6 +414,7 @@ class kucoinfutures extends kucoinfutures$1 {
338
414
  }
339
415
  this.handleDelta(storedOrderBook, data);
340
416
  client.resolve(storedOrderBook, messageHash);
417
+ this.resolvePromiseIfMessagehashMatches(client, 'multipleOrderbook::', symbol, storedOrderBook);
341
418
  }
342
419
  getCacheIndex(orderbook, cache) {
343
420
  const firstDelta = this.safeValue(cache, 0);
@@ -356,9 +433,18 @@ class kucoinfutures extends kucoinfutures$1 {
356
433
  return cache.length;
357
434
  }
358
435
  handleOrderBookSubscription(client, message, subscription) {
359
- const symbol = this.safeString(subscription, 'symbol');
360
436
  const limit = this.safeInteger(subscription, 'limit');
361
- this.orderbooks[symbol] = this.orderBook({}, limit);
437
+ const symbols = this.safeValue(subscription, 'symbols');
438
+ if (symbols === undefined) {
439
+ const symbol = this.safeString(subscription, 'symbol');
440
+ this.orderbooks[symbol] = this.orderBook({}, limit);
441
+ }
442
+ else {
443
+ for (let i = 0; i < symbols.length; i++) {
444
+ const symbol = symbols[i];
445
+ this.orderbooks[symbol] = this.orderBook({}, limit);
446
+ }
447
+ }
362
448
  // moved snapshot initialization to handleOrderBook to fix
363
449
  // https://github.com/ccxt/ccxt/issues/6820
364
450
  // the general idea is to fetch the snapshot after the first delta
@@ -16,6 +16,8 @@ class okx extends okx$1 {
16
16
  'watchTickers': true,
17
17
  'watchOrderBook': true,
18
18
  'watchTrades': true,
19
+ 'watchTradesForSymbols': true,
20
+ 'watchOrderBookForSymbols': true,
19
21
  'watchBalance': true,
20
22
  'watchOHLCV': true,
21
23
  'watchOrders': true,
@@ -97,9 +99,10 @@ class okx extends okx$1 {
97
99
  // for context: https://www.okx.com/help-center/changes-to-v5-api-websocket-subscription-parameter-and-url
98
100
  const isSandbox = this.options['sandboxMode'];
99
101
  const sandboxSuffix = isSandbox ? '?brokerId=9999' : '';
102
+ const isBusiness = (access === 'business');
100
103
  const isPublic = (access === 'public');
101
104
  const url = this.urls['api']['ws'];
102
- if ((channel.indexOf('candle') > -1) || (channel === 'orders-algo')) {
105
+ if (isBusiness || (channel.indexOf('candle') > -1) || (channel === 'orders-algo')) {
103
106
  return url + '/business' + sandboxSuffix;
104
107
  }
105
108
  else if (isPublic) {
@@ -169,6 +172,47 @@ class okx extends okx$1 {
169
172
  }
170
173
  return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
171
174
  }
175
+ async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
176
+ /**
177
+ * @method
178
+ * @name okx#watchTradesForSymbols
179
+ * @description get the list of most recent trades for a particular symbol
180
+ * @param {string} symbol unified symbol of the market to fetch trades for
181
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
182
+ * @param {int} [limit] the maximum amount of trades to fetch
183
+ * @param {object} [params] extra parameters specific to the okx api endpoint
184
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/en/latest/manual.html?#public-trades}
185
+ */
186
+ const symbolsLength = symbols.length;
187
+ if (symbolsLength === 0) {
188
+ throw new errors.ArgumentsRequired(this.id + ' watchTradesForSymbols() requires a non-empty array of symbols');
189
+ }
190
+ await this.loadMarkets();
191
+ symbols = this.marketSymbols(symbols);
192
+ const channel = 'trades';
193
+ const topics = [];
194
+ for (let i = 0; i < symbols.length; i++) {
195
+ const marketId = this.marketId(symbols[i]);
196
+ const topic = {
197
+ 'channel': channel,
198
+ 'instId': marketId,
199
+ };
200
+ topics.push(topic);
201
+ }
202
+ const request = {
203
+ 'op': 'subscribe',
204
+ 'args': topics,
205
+ };
206
+ const messageHash = 'multipleTrades::' + symbols.join(',');
207
+ const url = this.getUrl(channel, 'public');
208
+ const trades = await this.watch(url, messageHash, request, messageHash);
209
+ if (this.newUpdates) {
210
+ const first = this.safeValue(trades, 0);
211
+ const tradeSymbol = this.safeString(first, 'symbol');
212
+ limit = trades.getLimit(tradeSymbol, limit);
213
+ }
214
+ return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
215
+ }
172
216
  handleTrades(client, message) {
173
217
  //
174
218
  // {
@@ -201,6 +245,7 @@ class okx extends okx$1 {
201
245
  }
202
246
  stored.append(trade);
203
247
  client.resolve(stored, messageHash);
248
+ this.resolvePromiseIfMessagehashMatches(client, 'multipleTrades::', symbol, stored);
204
249
  }
205
250
  return message;
206
251
  }
@@ -397,6 +442,41 @@ class okx extends okx$1 {
397
442
  const orderbook = await this.subscribe('public', depth, depth, symbol, params);
398
443
  return orderbook.limit();
399
444
  }
445
+ async watchOrderBookForSymbols(symbols, limit = undefined, params = {}) {
446
+ /**
447
+ * @method
448
+ * @name okx#watchOrderBookForSymbols
449
+ * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
450
+ * @param {string[]} symbols unified array of symbols
451
+ * @param {int} [limit] the maximum amount of order book entries to return
452
+ * @param {object} [params] extra parameters specific to the okx api endpoint
453
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
454
+ */
455
+ await this.loadMarkets();
456
+ symbols = this.marketSymbols(symbols);
457
+ const options = this.safeValue(this.options, 'watchOrderBook', {});
458
+ const depth = this.safeString(options, 'depth', 'books');
459
+ if ((depth === 'books-l2-tbt') || (depth === 'books50-l2-tbt')) {
460
+ await this.authenticate({ 'access': 'public' });
461
+ }
462
+ const topics = [];
463
+ for (let i = 0; i < symbols.length; i++) {
464
+ const marketId = this.marketId(symbols[i]);
465
+ const topic = {
466
+ 'channel': depth,
467
+ 'instId': marketId,
468
+ };
469
+ topics.push(topic);
470
+ }
471
+ const request = {
472
+ 'op': 'subscribe',
473
+ 'args': topics,
474
+ };
475
+ const url = this.getUrl(depth, 'public');
476
+ const messageHash = 'multipleOrderbooks::' + symbols.join(',');
477
+ const orderbook = await this.watch(url, messageHash, request, messageHash);
478
+ return orderbook.limit();
479
+ }
400
480
  handleDelta(bookside, delta) {
401
481
  //
402
482
  // [
@@ -576,6 +656,7 @@ class okx extends okx$1 {
576
656
  orderbook['symbol'] = symbol;
577
657
  this.handleOrderBookMessage(client, update, orderbook, messageHash);
578
658
  client.resolve(orderbook, messageHash);
659
+ this.resolvePromiseIfMessagehashMatches(client, 'multipleOrderbooks::', symbol, orderbook);
579
660
  }
580
661
  }
581
662
  else if (action === 'update') {
@@ -585,6 +666,7 @@ class okx extends okx$1 {
585
666
  const update = data[i];
586
667
  this.handleOrderBookMessage(client, update, orderbook, messageHash);
587
668
  client.resolve(orderbook, messageHash);
669
+ this.resolvePromiseIfMessagehashMatches(client, 'multipleOrderbooks::', symbol, orderbook);
588
670
  }
589
671
  }
590
672
  }
@@ -600,6 +682,7 @@ class okx extends okx$1 {
600
682
  const snapshot = this.parseOrderBook(update, symbol, timestamp, 'bids', 'asks', 0, 1);
601
683
  orderbook.reset(snapshot);
602
684
  client.resolve(orderbook, messageHash);
685
+ this.resolvePromiseIfMessagehashMatches(client, 'multipleOrderbooks::', symbol, orderbook);
603
686
  }
604
687
  }
605
688
  return message;
@@ -738,13 +821,13 @@ class okx extends okx$1 {
738
821
  * @param {bool} [params.stop] true if fetching trigger or conditional trades
739
822
  * @returns {object[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure
740
823
  */
741
- await this.loadMarkets();
742
- await this.authenticate();
743
824
  // By default, receive order updates from any instrument type
744
825
  let type = undefined;
745
826
  [type, params] = this.handleOptionAndParams(params, 'watchMyTrades', 'type', 'ANY');
746
827
  const isStop = this.safeValue(params, 'stop', false);
747
828
  params = this.omit(params, ['stop']);
829
+ await this.loadMarkets();
830
+ await this.authenticate({ 'access': isStop ? 'business' : 'private' });
748
831
  const channel = isStop ? 'orders-algo' : 'orders';
749
832
  let messageHash = channel + '::myTrades';
750
833
  let market = undefined;
@@ -780,13 +863,13 @@ class okx extends okx$1 {
780
863
  * @param {bool} [params.stop] true if fetching trigger or conditional orders
781
864
  * @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
782
865
  */
783
- await this.loadMarkets();
784
- await this.authenticate();
785
866
  let type = undefined;
786
867
  // By default, receive order updates from any instrument type
787
868
  [type, params] = this.handleOptionAndParams(params, 'watchOrders', 'type', 'ANY');
788
869
  const isStop = this.safeValue(params, 'stop', false);
789
870
  params = this.omit(params, ['stop']);
871
+ await this.loadMarkets();
872
+ await this.authenticate({ 'access': isStop ? 'business' : 'private' });
790
873
  let market = undefined;
791
874
  if (symbol !== undefined) {
792
875
  market = this.market(symbol);
@@ -301,7 +301,8 @@ class poloniexfutures extends poloniexfutures$1 {
301
301
  limit = orders.getLimit(symbol, limit);
302
302
  }
303
303
  orders = this.filterBySymbolSinceLimit(orders, symbol, since, limit);
304
- if (orders.length === 0) {
304
+ const length = orders.length;
305
+ if (length === 0) {
305
306
  return await this.watchOrders(symbol, since, limit, params);
306
307
  }
307
308
  return orders;
@@ -270,7 +270,8 @@ class probit extends probit$1 {
270
270
  // }
271
271
  //
272
272
  const rawTrades = this.safeValue(message, 'data', []);
273
- if (rawTrades.length === 0) {
273
+ const length = rawTrades.length;
274
+ if (length === 0) {
274
275
  return;
275
276
  }
276
277
  const reset = this.safeValue(message, 'reset', false);
@@ -356,7 +357,8 @@ class probit extends probit$1 {
356
357
  // }
357
358
  //
358
359
  const rawOrders = this.safeValue(message, 'data', []);
359
- if (rawOrders.length === 0) {
360
+ const length = rawOrders.length;
361
+ if (length === 0) {
360
362
  return;
361
363
  }
362
364
  const messageHash = 'orders';
package/js/ccxt.d.ts CHANGED
@@ -2,9 +2,9 @@ import { Exchange } from './src/base/Exchange.js';
2
2
  import { Precise } from './src/base/Precise.js';
3
3
  import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
- import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax } from './src/base/types.js';
5
+ import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending } from './src/base/errors.js';
7
- declare const version = "4.0.88";
7
+ declare const version = "4.0.90";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
@@ -513,5 +513,5 @@ declare const ccxt: {
513
513
  zaif: typeof zaif;
514
514
  zonda: typeof zonda;
515
515
  } & typeof functions & typeof errors;
516
- export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitforex, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitstamp1, bittrex, bitvavo, bkex, bl3p, blockchaincom, btcalpha, btcbox, btcmarkets, btctradeua, btcturk, bybit, cex, coinbase, coinbaseprime, coinbasepro, coincheck, coinex, coinfalcon, coinmate, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, huobi, huobijp, huobipro, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, lbank2, luno, lykke, mercado, mexc, mexc3, ndax, novadax, oceanex, okcoin, okex, okex5, okx, paymium, phemex, poloniex, poloniexfutures, probit, tidex, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
516
+ export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitforex, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitstamp1, bittrex, bitvavo, bkex, bl3p, blockchaincom, btcalpha, btcbox, btcmarkets, btctradeua, btcturk, bybit, cex, coinbase, coinbaseprime, coinbasepro, coincheck, coinex, coinfalcon, coinmate, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, huobi, huobijp, huobipro, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, lbank2, luno, lykke, mercado, mexc, mexc3, ndax, novadax, oceanex, okcoin, okex, okex5, okx, paymium, phemex, poloniex, poloniexfutures, probit, tidex, timex, tokocrypto, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
517
517
  export default ccxt;
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.0.89';
41
+ const version = '4.0.91';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -373,6 +373,7 @@ interface Exchange {
373
373
  dapiPublicGetContinuousKlines(params?: {}): Promise<implicitReturnType>;
374
374
  dapiPublicGetIndexPriceKlines(params?: {}): Promise<implicitReturnType>;
375
375
  dapiPublicGetMarkPriceKlines(params?: {}): Promise<implicitReturnType>;
376
+ dapiPublicGetPremiumIndexKlines(params?: {}): Promise<implicitReturnType>;
376
377
  dapiPublicGetTicker24hr(params?: {}): Promise<implicitReturnType>;
377
378
  dapiPublicGetTickerPrice(params?: {}): Promise<implicitReturnType>;
378
379
  dapiPublicGetTickerBookTicker(params?: {}): Promise<implicitReturnType>;
@@ -384,6 +385,7 @@ interface Exchange {
384
385
  dapiDataGetTakerBuySellVol(params?: {}): Promise<implicitReturnType>;
385
386
  dapiDataGetBasis(params?: {}): Promise<implicitReturnType>;
386
387
  dapiPrivateGetPositionSideDual(params?: {}): Promise<implicitReturnType>;
388
+ dapiPrivateGetOrderAmendment(params?: {}): Promise<implicitReturnType>;
387
389
  dapiPrivateGetOrder(params?: {}): Promise<implicitReturnType>;
388
390
  dapiPrivateGetOpenOrder(params?: {}): Promise<implicitReturnType>;
389
391
  dapiPrivateGetOpenOrders(params?: {}): Promise<implicitReturnType>;
@@ -397,7 +399,10 @@ interface Exchange {
397
399
  dapiPrivateGetLeverageBracket(params?: {}): Promise<implicitReturnType>;
398
400
  dapiPrivateGetForceOrders(params?: {}): Promise<implicitReturnType>;
399
401
  dapiPrivateGetAdlQuantile(params?: {}): Promise<implicitReturnType>;
400
- dapiPrivateGetOrderAmendment(params?: {}): Promise<implicitReturnType>;
402
+ dapiPrivateGetCommissionRate(params?: {}): Promise<implicitReturnType>;
403
+ dapiPrivateGetIncomeAsyn(params?: {}): Promise<implicitReturnType>;
404
+ dapiPrivateGetIncomeAsynId(params?: {}): Promise<implicitReturnType>;
405
+ dapiPrivateGetPmExchangeInfo(params?: {}): Promise<implicitReturnType>;
401
406
  dapiPrivateGetPmAccountInfo(params?: {}): Promise<implicitReturnType>;
402
407
  dapiPrivatePostPositionSideDual(params?: {}): Promise<implicitReturnType>;
403
408
  dapiPrivatePostOrder(params?: {}): Promise<implicitReturnType>;
@@ -373,6 +373,7 @@ interface binance {
373
373
  dapiPublicGetContinuousKlines(params?: {}): Promise<implicitReturnType>;
374
374
  dapiPublicGetIndexPriceKlines(params?: {}): Promise<implicitReturnType>;
375
375
  dapiPublicGetMarkPriceKlines(params?: {}): Promise<implicitReturnType>;
376
+ dapiPublicGetPremiumIndexKlines(params?: {}): Promise<implicitReturnType>;
376
377
  dapiPublicGetTicker24hr(params?: {}): Promise<implicitReturnType>;
377
378
  dapiPublicGetTickerPrice(params?: {}): Promise<implicitReturnType>;
378
379
  dapiPublicGetTickerBookTicker(params?: {}): Promise<implicitReturnType>;
@@ -384,6 +385,7 @@ interface binance {
384
385
  dapiDataGetTakerBuySellVol(params?: {}): Promise<implicitReturnType>;
385
386
  dapiDataGetBasis(params?: {}): Promise<implicitReturnType>;
386
387
  dapiPrivateGetPositionSideDual(params?: {}): Promise<implicitReturnType>;
388
+ dapiPrivateGetOrderAmendment(params?: {}): Promise<implicitReturnType>;
387
389
  dapiPrivateGetOrder(params?: {}): Promise<implicitReturnType>;
388
390
  dapiPrivateGetOpenOrder(params?: {}): Promise<implicitReturnType>;
389
391
  dapiPrivateGetOpenOrders(params?: {}): Promise<implicitReturnType>;
@@ -397,7 +399,10 @@ interface binance {
397
399
  dapiPrivateGetLeverageBracket(params?: {}): Promise<implicitReturnType>;
398
400
  dapiPrivateGetForceOrders(params?: {}): Promise<implicitReturnType>;
399
401
  dapiPrivateGetAdlQuantile(params?: {}): Promise<implicitReturnType>;
400
- dapiPrivateGetOrderAmendment(params?: {}): Promise<implicitReturnType>;
402
+ dapiPrivateGetCommissionRate(params?: {}): Promise<implicitReturnType>;
403
+ dapiPrivateGetIncomeAsyn(params?: {}): Promise<implicitReturnType>;
404
+ dapiPrivateGetIncomeAsynId(params?: {}): Promise<implicitReturnType>;
405
+ dapiPrivateGetPmExchangeInfo(params?: {}): Promise<implicitReturnType>;
401
406
  dapiPrivateGetPmAccountInfo(params?: {}): Promise<implicitReturnType>;
402
407
  dapiPrivatePostPositionSideDual(params?: {}): Promise<implicitReturnType>;
403
408
  dapiPrivatePostOrder(params?: {}): Promise<implicitReturnType>;
@@ -373,6 +373,7 @@ interface binance {
373
373
  dapiPublicGetContinuousKlines(params?: {}): Promise<implicitReturnType>;
374
374
  dapiPublicGetIndexPriceKlines(params?: {}): Promise<implicitReturnType>;
375
375
  dapiPublicGetMarkPriceKlines(params?: {}): Promise<implicitReturnType>;
376
+ dapiPublicGetPremiumIndexKlines(params?: {}): Promise<implicitReturnType>;
376
377
  dapiPublicGetTicker24hr(params?: {}): Promise<implicitReturnType>;
377
378
  dapiPublicGetTickerPrice(params?: {}): Promise<implicitReturnType>;
378
379
  dapiPublicGetTickerBookTicker(params?: {}): Promise<implicitReturnType>;
@@ -384,6 +385,7 @@ interface binance {
384
385
  dapiDataGetTakerBuySellVol(params?: {}): Promise<implicitReturnType>;
385
386
  dapiDataGetBasis(params?: {}): Promise<implicitReturnType>;
386
387
  dapiPrivateGetPositionSideDual(params?: {}): Promise<implicitReturnType>;
388
+ dapiPrivateGetOrderAmendment(params?: {}): Promise<implicitReturnType>;
387
389
  dapiPrivateGetOrder(params?: {}): Promise<implicitReturnType>;
388
390
  dapiPrivateGetOpenOrder(params?: {}): Promise<implicitReturnType>;
389
391
  dapiPrivateGetOpenOrders(params?: {}): Promise<implicitReturnType>;
@@ -397,7 +399,10 @@ interface binance {
397
399
  dapiPrivateGetLeverageBracket(params?: {}): Promise<implicitReturnType>;
398
400
  dapiPrivateGetForceOrders(params?: {}): Promise<implicitReturnType>;
399
401
  dapiPrivateGetAdlQuantile(params?: {}): Promise<implicitReturnType>;
400
- dapiPrivateGetOrderAmendment(params?: {}): Promise<implicitReturnType>;
402
+ dapiPrivateGetCommissionRate(params?: {}): Promise<implicitReturnType>;
403
+ dapiPrivateGetIncomeAsyn(params?: {}): Promise<implicitReturnType>;
404
+ dapiPrivateGetIncomeAsynId(params?: {}): Promise<implicitReturnType>;
405
+ dapiPrivateGetPmExchangeInfo(params?: {}): Promise<implicitReturnType>;
401
406
  dapiPrivateGetPmAccountInfo(params?: {}): Promise<implicitReturnType>;
402
407
  dapiPrivatePostPositionSideDual(params?: {}): Promise<implicitReturnType>;
403
408
  dapiPrivatePostOrder(params?: {}): Promise<implicitReturnType>;
@@ -373,6 +373,7 @@ interface binance {
373
373
  dapiPublicGetContinuousKlines(params?: {}): Promise<implicitReturnType>;
374
374
  dapiPublicGetIndexPriceKlines(params?: {}): Promise<implicitReturnType>;
375
375
  dapiPublicGetMarkPriceKlines(params?: {}): Promise<implicitReturnType>;
376
+ dapiPublicGetPremiumIndexKlines(params?: {}): Promise<implicitReturnType>;
376
377
  dapiPublicGetTicker24hr(params?: {}): Promise<implicitReturnType>;
377
378
  dapiPublicGetTickerPrice(params?: {}): Promise<implicitReturnType>;
378
379
  dapiPublicGetTickerBookTicker(params?: {}): Promise<implicitReturnType>;
@@ -384,6 +385,7 @@ interface binance {
384
385
  dapiDataGetTakerBuySellVol(params?: {}): Promise<implicitReturnType>;
385
386
  dapiDataGetBasis(params?: {}): Promise<implicitReturnType>;
386
387
  dapiPrivateGetPositionSideDual(params?: {}): Promise<implicitReturnType>;
388
+ dapiPrivateGetOrderAmendment(params?: {}): Promise<implicitReturnType>;
387
389
  dapiPrivateGetOrder(params?: {}): Promise<implicitReturnType>;
388
390
  dapiPrivateGetOpenOrder(params?: {}): Promise<implicitReturnType>;
389
391
  dapiPrivateGetOpenOrders(params?: {}): Promise<implicitReturnType>;
@@ -397,7 +399,10 @@ interface binance {
397
399
  dapiPrivateGetLeverageBracket(params?: {}): Promise<implicitReturnType>;
398
400
  dapiPrivateGetForceOrders(params?: {}): Promise<implicitReturnType>;
399
401
  dapiPrivateGetAdlQuantile(params?: {}): Promise<implicitReturnType>;
400
- dapiPrivateGetOrderAmendment(params?: {}): Promise<implicitReturnType>;
402
+ dapiPrivateGetCommissionRate(params?: {}): Promise<implicitReturnType>;
403
+ dapiPrivateGetIncomeAsyn(params?: {}): Promise<implicitReturnType>;
404
+ dapiPrivateGetIncomeAsynId(params?: {}): Promise<implicitReturnType>;
405
+ dapiPrivateGetPmExchangeInfo(params?: {}): Promise<implicitReturnType>;
401
406
  dapiPrivateGetPmAccountInfo(params?: {}): Promise<implicitReturnType>;
402
407
  dapiPrivatePostPositionSideDual(params?: {}): Promise<implicitReturnType>;
403
408
  dapiPrivatePostOrder(params?: {}): Promise<implicitReturnType>;