ccxt 4.2.8 → 4.2.10

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 (57) hide show
  1. package/README.md +3 -3
  2. package/build.sh +18 -2
  3. package/dist/ccxt.browser.js +387 -149
  4. package/dist/ccxt.browser.min.js +7 -7
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/base/Exchange.js +37 -8
  7. package/dist/cjs/src/binance.js +6 -1
  8. package/dist/cjs/src/bitmart.js +94 -15
  9. package/dist/cjs/src/bl3p.js +1 -1
  10. package/dist/cjs/src/btcalpha.js +1 -1
  11. package/dist/cjs/src/cryptocom.js +3 -1
  12. package/dist/cjs/src/deribit.js +39 -22
  13. package/dist/cjs/src/kraken.js +1 -1
  14. package/dist/cjs/src/kucoin.js +1 -1
  15. package/dist/cjs/src/lykke.js +1 -1
  16. package/dist/cjs/src/ndax.js +1 -1
  17. package/dist/cjs/src/pro/binance.js +17 -1
  18. package/dist/cjs/src/pro/bitget.js +3 -1
  19. package/dist/cjs/src/pro/bitmart.js +52 -15
  20. package/dist/cjs/src/pro/blockchaincom.js +2 -28
  21. package/dist/cjs/src/pro/bybit.js +3 -1
  22. package/dist/cjs/src/pro/coinbasepro.js +9 -16
  23. package/dist/cjs/src/pro/cryptocom.js +110 -28
  24. package/dist/cjs/src/pro/luno.js +5 -5
  25. package/js/ccxt.d.ts +1 -1
  26. package/js/ccxt.js +1 -1
  27. package/js/src/base/Exchange.d.ts +4 -3
  28. package/js/src/base/Exchange.js +37 -8
  29. package/js/src/binance.js +6 -1
  30. package/js/src/bitmart.js +95 -16
  31. package/js/src/bl3p.d.ts +2 -2
  32. package/js/src/bl3p.js +1 -1
  33. package/js/src/btcalpha.d.ts +2 -2
  34. package/js/src/btcalpha.js +1 -1
  35. package/js/src/cryptocom.js +3 -1
  36. package/js/src/deribit.js +39 -22
  37. package/js/src/kraken.d.ts +2 -2
  38. package/js/src/kraken.js +1 -1
  39. package/js/src/kucoin.js +1 -1
  40. package/js/src/lykke.d.ts +2 -2
  41. package/js/src/lykke.js +1 -1
  42. package/js/src/ndax.d.ts +2 -2
  43. package/js/src/ndax.js +1 -1
  44. package/js/src/pro/binance.js +17 -1
  45. package/js/src/pro/bitget.js +3 -1
  46. package/js/src/pro/bitmart.d.ts +1 -0
  47. package/js/src/pro/bitmart.js +52 -15
  48. package/js/src/pro/blockchaincom.d.ts +1 -11
  49. package/js/src/pro/blockchaincom.js +2 -28
  50. package/js/src/pro/bybit.js +3 -1
  51. package/js/src/pro/coinbasepro.js +9 -16
  52. package/js/src/pro/cryptocom.d.ts +3 -1
  53. package/js/src/pro/cryptocom.js +111 -29
  54. package/js/src/pro/luno.d.ts +4 -4
  55. package/js/src/pro/luno.js +5 -5
  56. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  57. package/package.json +1 -1
package/js/src/bitmart.js CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/bitmart.js';
9
- import { AuthenticationError, ExchangeNotAvailable, AccountSuspended, PermissionDenied, RateLimitExceeded, InvalidNonce, InvalidAddress, ArgumentsRequired, ExchangeError, InvalidOrder, InsufficientFunds, BadRequest, OrderNotFound, BadSymbol, NotSupported } from './base/errors.js';
9
+ import { AuthenticationError, ExchangeNotAvailable, OnMaintenance, AccountSuspended, PermissionDenied, RateLimitExceeded, InvalidNonce, InvalidAddress, ArgumentsRequired, ExchangeError, InvalidOrder, InsufficientFunds, BadRequest, OrderNotFound, BadSymbol, NotSupported } from './base/errors.js';
10
10
  import { Precise } from './base/Precise.js';
11
11
  import { TICK_SIZE, TRUNCATE } from './base/functions/number.js';
12
12
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
@@ -309,7 +309,11 @@ export default class bitmart extends Exchange {
309
309
  '30012': AuthenticationError,
310
310
  '30013': RateLimitExceeded,
311
311
  '30014': ExchangeNotAvailable,
312
- // funding account errors
312
+ '30016': OnMaintenance,
313
+ '30017': RateLimitExceeded,
314
+ '30018': BadRequest,
315
+ '30019': PermissionDenied,
316
+ // funding account & sub account errors
313
317
  '60000': BadRequest,
314
318
  '60001': BadRequest,
315
319
  '60002': BadRequest,
@@ -326,13 +330,31 @@ export default class bitmart extends Exchange {
326
330
  '60020': PermissionDenied,
327
331
  '60021': PermissionDenied,
328
332
  '60022': PermissionDenied,
333
+ '60026': PermissionDenied,
334
+ '60027': PermissionDenied,
335
+ '60028': AccountSuspended,
336
+ '60029': AccountSuspended,
329
337
  '60030': BadRequest,
330
338
  '60031': BadRequest,
331
339
  '60050': ExchangeError,
332
340
  '60051': ExchangeError,
333
341
  '61001': InsufficientFunds,
334
342
  '61003': BadRequest,
335
- // spot errors
343
+ '61004': BadRequest,
344
+ '61005': BadRequest,
345
+ '61006': NotSupported,
346
+ '61007': ExchangeError,
347
+ '61008': ExchangeError,
348
+ // spot public errors
349
+ '70000': ExchangeError,
350
+ '70001': BadRequest,
351
+ '70002': BadSymbol,
352
+ '71001': BadRequest,
353
+ '71002': BadRequest,
354
+ '71003': BadRequest,
355
+ '71004': BadRequest,
356
+ '71005': BadRequest,
357
+ // spot & margin errors
336
358
  '50000': BadRequest,
337
359
  '50001': BadSymbol,
338
360
  '50002': BadRequest,
@@ -352,26 +374,75 @@ export default class bitmart extends Exchange {
352
374
  '50016': BadRequest,
353
375
  '50017': BadRequest,
354
376
  '50018': BadRequest,
355
- '50019': BadRequest,
356
- '51004': InsufficientFunds,
357
- // '50019': ExchangeError, // 400, Invalid status. validate status is [1=Failed, 2=Success, 3=Frozen Failed, 4=Frozen Success, 5=Partially Filled, 6=Fully Fulled, 7=Canceling, 8=Canceled
377
+ '50019': ExchangeError,
358
378
  '50020': InsufficientFunds,
359
379
  '50021': BadRequest,
360
380
  '50022': ExchangeNotAvailable,
361
381
  '50023': BadSymbol,
382
+ '50024': BadRequest,
383
+ '50025': BadRequest,
384
+ '50026': BadRequest,
385
+ '50027': BadRequest,
386
+ '50028': BadRequest,
362
387
  '50029': InvalidOrder,
363
- '50030': InvalidOrder,
388
+ '50030': OrderNotFound,
389
+ '50031': OrderNotFound,
364
390
  '50032': OrderNotFound,
391
+ '50033': InvalidOrder,
365
392
  // below Error codes used interchangeably for both failed postOnly and IOC orders depending on market price and order side
366
- '50035': InvalidOrder,
367
393
  '50034': InvalidOrder,
394
+ '50035': InvalidOrder,
395
+ '50036': ExchangeError,
396
+ '50037': BadRequest,
397
+ '50038': BadRequest,
398
+ '50039': BadRequest,
399
+ '50040': BadSymbol,
400
+ '50041': ExchangeError,
401
+ '50042': BadRequest,
402
+ '51000': BadSymbol,
403
+ '51001': ExchangeError,
404
+ '51002': ExchangeError,
405
+ '51003': ExchangeError,
406
+ '51004': InsufficientFunds,
407
+ '51005': InvalidOrder,
408
+ '51006': InvalidOrder,
409
+ '51007': BadRequest,
410
+ '51008': ExchangeError,
411
+ '51009': InvalidOrder,
412
+ '51010': InvalidOrder,
368
413
  '51011': InvalidOrder,
414
+ '51012': InvalidOrder,
415
+ '51013': InvalidOrder,
416
+ '51014': InvalidOrder,
417
+ '51015': InvalidOrder,
418
+ '52000': BadRequest,
419
+ '52001': BadRequest,
420
+ '52002': BadRequest,
421
+ '52003': BadRequest,
422
+ '52004': BadRequest,
369
423
  '53000': AccountSuspended,
370
424
  '53001': AccountSuspended,
425
+ '53002': PermissionDenied,
426
+ '53003': PermissionDenied,
427
+ '53005': PermissionDenied,
428
+ '53006': PermissionDenied,
429
+ '53007': PermissionDenied,
430
+ '53008': PermissionDenied,
431
+ '53009': PermissionDenied,
432
+ '53010': PermissionDenied,
371
433
  '57001': BadRequest,
372
434
  '58001': BadRequest,
373
435
  '59001': ExchangeError,
374
436
  '59002': ExchangeError,
437
+ '59003': ExchangeError,
438
+ '59004': ExchangeError,
439
+ '59005': PermissionDenied,
440
+ '59006': ExchangeError,
441
+ '59007': ExchangeError,
442
+ '59008': ExchangeError,
443
+ '59009': ExchangeError,
444
+ '59010': InsufficientFunds,
445
+ '59011': ExchangeError,
375
446
  // contract errors
376
447
  '40001': ExchangeError,
377
448
  '40002': ExchangeError,
@@ -407,14 +478,22 @@ export default class bitmart extends Exchange {
407
478
  '40032': InvalidOrder,
408
479
  '40033': InvalidOrder,
409
480
  '40034': BadSymbol,
410
- '53002': PermissionDenied,
411
- '53003': PermissionDenied,
412
- '53005': PermissionDenied,
413
- '53006': PermissionDenied,
414
- '53007': PermissionDenied,
415
- '53008': PermissionDenied,
416
- '53009': PermissionDenied,
417
- '53010': PermissionDenied, // 403 This account is restricted from borrowing
481
+ '40035': OrderNotFound,
482
+ '40036': InvalidOrder,
483
+ '40037': OrderNotFound,
484
+ '40038': BadRequest,
485
+ '40039': BadRequest,
486
+ '40040': InvalidOrder,
487
+ '40041': InvalidOrder,
488
+ '40042': InvalidOrder,
489
+ '40043': InvalidOrder,
490
+ '40044': InvalidOrder,
491
+ '40045': InvalidOrder,
492
+ '40046': PermissionDenied,
493
+ '40047': PermissionDenied,
494
+ '40048': BadRequest,
495
+ '40049': BadRequest,
496
+ '40050': InvalidOrder, // 403, Client OrderId duplicated with existing orders
418
497
  },
419
498
  'broad': {},
420
499
  },
package/js/src/bl3p.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bl3p.js';
2
- import type { Balances, Int, Market, OrderBook, OrderSide, OrderType, Str, Ticker, Trade } from './base/types.js';
2
+ import type { Balances, Int, Market, OrderBook, OrderSide, OrderType, Str, Ticker, Trade, IndexType } from './base/types.js';
3
3
  /**
4
4
  * @class bl3p
5
5
  * @augments Exchange
@@ -8,7 +8,7 @@ export default class bl3p extends Exchange {
8
8
  describe(): any;
9
9
  parseBalance(response: any): Balances;
10
10
  fetchBalance(params?: {}): Promise<Balances>;
11
- parseBidAsk(bidask: any, priceKey?: number, amountKey?: number): number[];
11
+ parseBidAsk(bidask: any, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): number[];
12
12
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
13
13
  parseTicker(ticker: any, market?: Market): Ticker;
14
14
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
package/js/src/bl3p.js CHANGED
@@ -149,7 +149,7 @@ export default class bl3p extends Exchange {
149
149
  const response = await this.privatePostGENMKTMoneyInfo(params);
150
150
  return this.parseBalance(response);
151
151
  }
152
- parseBidAsk(bidask, priceKey = 0, amountKey = 1) {
152
+ parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
153
153
  const price = this.safeString(bidask, priceKey);
154
154
  const size = this.safeString(bidask, amountKey);
155
155
  return [
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/btcalpha.js';
2
- import type { Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction } from './base/types.js';
2
+ import type { IndexType, Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction } from './base/types.js';
3
3
  /**
4
4
  * @class btcalpha
5
5
  * @augments Exchange
@@ -12,7 +12,7 @@ export default class btcalpha extends Exchange {
12
12
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
13
13
  parseTicker(ticker: any, market?: Market): Ticker;
14
14
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
15
- parseBidsAsks(bidasks: any, priceKey?: number, amountKey?: number): any[];
15
+ parseBidsAsks(bidasks: any, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): any[];
16
16
  parseTrade(trade: any, market?: Market): Trade;
17
17
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
18
18
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
@@ -362,7 +362,7 @@ export default class btcalpha extends Exchange {
362
362
  const response = await this.publicGetOrderbookPairName(this.extend(request, params));
363
363
  return this.parseOrderBook(response, market['symbol'], undefined, 'buy', 'sell', 'price', 'amount');
364
364
  }
365
- parseBidsAsks(bidasks, priceKey = 0, amountKey = 1) {
365
+ parseBidsAsks(bidasks, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
366
366
  const result = [];
367
367
  for (let i = 0; i < bidasks.length; i++) {
368
368
  const bidask = bidasks[i];
@@ -773,6 +773,7 @@ export default class cryptocom extends Exchange {
773
773
  // "p": "26386.00",
774
774
  // "q": "0.00453",
775
775
  // "t": 1686944282062,
776
+ // "tn" : 1704476468851524373,
776
777
  // "d": "4611686018455979970",
777
778
  // "i": "BTC_USD"
778
779
  // },
@@ -1943,7 +1944,8 @@ export default class cryptocom extends Exchange {
1943
1944
  // "s": "sell",
1944
1945
  // "p": "26386.00",
1945
1946
  // "q": "0.00453",
1946
- // "t": 1686944282062,
1947
+ // "tn": 1686944282062,
1948
+ // "tn": 1704476468851524373,
1947
1949
  // "d": "4611686018455979970",
1948
1950
  // "i": "BTC_USD"
1949
1951
  // }
package/js/src/deribit.js CHANGED
@@ -1726,27 +1726,18 @@ export default class deribit extends Exchange {
1726
1726
  * @param {string} symbol unified symbol of the market to create an order in
1727
1727
  * @param {string} type 'market' or 'limit'
1728
1728
  * @param {string} side 'buy' or 'sell'
1729
- * @param {float} amount how much of currency you want to trade. For perpetual and futures the amount is in USD. For options it is in corresponding cryptocurrency contracts currency.
1729
+ * @param {float} amount how much you want to trade in units of the base currency. For inverse perpetual and futures the amount is in the quote currency USD. For options it is in the underlying assets base currency.
1730
1730
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1731
1731
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1732
+ * @param {string} [params.trigger] the trigger type 'index_price', 'mark_price', or 'last_price', default is 'last_price'
1733
+ * @param {float} [params.trailingAmount] the quote amount to trail away from the current market price
1732
1734
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1733
1735
  */
1734
1736
  await this.loadMarkets();
1735
1737
  const market = this.market(symbol);
1736
- if (market['inverse']) {
1737
- amount = this.amountToPrecision(symbol, amount);
1738
- }
1739
- else if (market['settle'] === 'USDC') {
1740
- amount = this.amountToPrecision(symbol, amount);
1741
- }
1742
- else {
1743
- amount = this.currencyToPrecision(symbol, amount);
1744
- }
1745
1738
  const request = {
1746
1739
  'instrument_name': market['id'],
1747
- // for perpetual and futures the amount is in USD
1748
- // for options it is in corresponding cryptocurrency contracts, e.g., BTC or ETH
1749
- 'amount': amount,
1740
+ 'amount': this.amountToPrecision(symbol, amount),
1750
1741
  'type': type, // limit, stop_limit, market, stop_market, default is limit
1751
1742
  // 'label': 'string', // user-defined label for the order (maximum 64 characters)
1752
1743
  // 'price': this.priceToPrecision (symbol, 123.45), // only for limit and stop_limit orders
@@ -1759,12 +1750,15 @@ export default class deribit extends Exchange {
1759
1750
  // 'trigger': 'index_price', // mark_price, last_price, required for stop_limit orders
1760
1751
  // 'advanced': 'usd', // 'implv', advanced option order type, options only
1761
1752
  };
1753
+ const trigger = this.safeString(params, 'trigger', 'last_price');
1762
1754
  const timeInForce = this.safeStringUpper(params, 'timeInForce');
1763
1755
  const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
1764
1756
  // only stop loss sell orders are allowed when price crossed from above
1765
1757
  const stopLossPrice = this.safeValue(params, 'stopLossPrice');
1766
1758
  // only take profit buy orders are allowed when price crossed from below
1767
1759
  const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
1760
+ const trailingAmount = this.safeString2(params, 'trailingAmount', 'trigger_offset');
1761
+ const isTrailingAmountOrder = trailingAmount !== undefined;
1768
1762
  const isStopLimit = type === 'stop_limit';
1769
1763
  const isStopMarket = type === 'stop_market';
1770
1764
  const isTakeLimit = type === 'take_limit';
@@ -1786,10 +1780,15 @@ export default class deribit extends Exchange {
1786
1780
  else {
1787
1781
  request['type'] = 'market';
1788
1782
  }
1789
- if (isStopOrder) {
1783
+ if (isTrailingAmountOrder) {
1784
+ request['trigger'] = trigger;
1785
+ request['type'] = 'trailing_stop';
1786
+ request['trigger_offset'] = this.parseToNumeric(trailingAmount);
1787
+ }
1788
+ else if (isStopOrder) {
1790
1789
  const triggerPrice = (stopLossPrice !== undefined) ? stopLossPrice : takeProfitPrice;
1791
1790
  request['trigger_price'] = this.priceToPrecision(symbol, triggerPrice);
1792
- request['trigger'] = 'last_price'; // required
1791
+ request['trigger'] = trigger;
1793
1792
  if (isStopLossOrder) {
1794
1793
  if (isMarketOrder) {
1795
1794
  // stop_market (sell only)
@@ -1829,7 +1828,7 @@ export default class deribit extends Exchange {
1829
1828
  request['time_in_force'] = 'fill_or_kill';
1830
1829
  }
1831
1830
  }
1832
- params = this.omit(params, ['timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'reduceOnly']);
1831
+ params = this.omit(params, ['timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'reduceOnly', 'trailingAmount']);
1833
1832
  let response = undefined;
1834
1833
  if (this.capitalize(side) === 'Buy') {
1835
1834
  response = await this.privateGetBuy(this.extend(request, params));
@@ -1896,25 +1895,43 @@ export default class deribit extends Exchange {
1896
1895
  return this.parseOrder(order, market);
1897
1896
  }
1898
1897
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1898
+ /**
1899
+ * @method
1900
+ * @name deribit#editOrder
1901
+ * @description edit a trade order
1902
+ * @see https://docs.deribit.com/#private-edit
1903
+ * @param {string} id edit order id
1904
+ * @param {string} [symbol] unified symbol of the market to edit an order in
1905
+ * @param {string} [type] 'market' or 'limit'
1906
+ * @param {string} [side] 'buy' or 'sell'
1907
+ * @param {float} amount how much you want to trade in units of the base currency, inverse swap and future use the quote currency
1908
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
1909
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1910
+ * @param {float} [params.trailingAmount] the quote amount to trail away from the current market price
1911
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1912
+ */
1899
1913
  if (amount === undefined) {
1900
1914
  throw new ArgumentsRequired(this.id + ' editOrder() requires an amount argument');
1901
1915
  }
1902
- if (price === undefined) {
1903
- throw new ArgumentsRequired(this.id + ' editOrder() requires a price argument');
1904
- }
1905
1916
  await this.loadMarkets();
1906
1917
  const request = {
1907
1918
  'order_id': id,
1908
- // for perpetual and futures the amount is in USD
1909
- // for options it is in corresponding cryptocurrency contracts, e.g., BTC or ETH
1910
1919
  'amount': this.amountToPrecision(symbol, amount),
1911
- 'price': this.priceToPrecision(symbol, price), // required
1912
1920
  // 'post_only': false, // if the new price would cause the order to be filled immediately (as taker), the price will be changed to be just below the spread.
1913
1921
  // 'reject_post_only': false, // if true the order is put to order book unmodified or request is rejected
1914
1922
  // 'reduce_only': false, // if true, the order is intended to only reduce a current position
1915
1923
  // 'stop_price': false, // stop price, required for stop_limit orders
1916
1924
  // 'advanced': 'usd', // 'implv', advanced option order type, options only
1917
1925
  };
1926
+ if (price !== undefined) {
1927
+ request['price'] = this.priceToPrecision(symbol, price);
1928
+ }
1929
+ const trailingAmount = this.safeString2(params, 'trailingAmount', 'trigger_offset');
1930
+ const isTrailingAmountOrder = trailingAmount !== undefined;
1931
+ if (isTrailingAmountOrder) {
1932
+ request['trigger_offset'] = this.parseToNumeric(trailingAmount);
1933
+ params = this.omit(params, 'trigger_offset');
1934
+ }
1918
1935
  const response = await this.privateGetEdit(this.extend(request, params));
1919
1936
  const result = this.safeValue(response, 'result', {});
1920
1937
  const order = this.safeValue(result, 'order');
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/kraken.js';
2
- import type { Int, OrderSide, OrderType, OHLCV, Trade, Order, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Strings, Currency, Market } from './base/types.js';
2
+ import type { IndexType, Int, OrderSide, OrderType, OHLCV, Trade, Order, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Strings, Currency, Market } from './base/types.js';
3
3
  /**
4
4
  * @class kraken
5
5
  * @augments Exchange
@@ -27,7 +27,7 @@ export default class kraken extends Exchange {
27
27
  percentage: boolean;
28
28
  tierBased: boolean;
29
29
  };
30
- parseBidAsk(bidask: any, priceKey?: number, amountKey?: number): number[];
30
+ parseBidAsk(bidask: any, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): number[];
31
31
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
32
32
  parseTicker(ticker: any, market?: Market): Ticker;
33
33
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
package/js/src/kraken.js CHANGED
@@ -754,7 +754,7 @@ export default class kraken extends Exchange {
754
754
  'tierBased': true,
755
755
  };
756
756
  }
757
- parseBidAsk(bidask, priceKey = 0, amountKey = 1) {
757
+ parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
758
758
  const price = this.safeNumber(bidask, priceKey);
759
759
  const amount = this.safeNumber(bidask, amountKey);
760
760
  const timestamp = this.safeInteger(bidask, 2);
package/js/src/kucoin.js CHANGED
@@ -2422,7 +2422,7 @@ export default class kucoin extends Exchange {
2422
2422
  // }
2423
2423
  // }
2424
2424
  const responseData = this.safeValue(response, 'data', {});
2425
- const orders = this.safeValue(responseData, 'items', []);
2425
+ const orders = this.safeValue(responseData, 'items', responseData);
2426
2426
  return this.parseOrders(orders, market, since, limit);
2427
2427
  }
2428
2428
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
package/js/src/lykke.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/lykke.js';
2
- import type { Balances, Currency, Int, Market, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction } from './base/types.js';
2
+ import type { IndexType, Balances, Currency, Int, Market, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction } from './base/types.js';
3
3
  /**
4
4
  * @class lykke
5
5
  * @augments Exchange
@@ -25,7 +25,7 @@ export default class lykke extends Exchange {
25
25
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
26
26
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
27
27
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
28
- parseBidAsk(bidask: any, priceKey?: number, amountKey?: number): number[];
28
+ parseBidAsk(bidask: any, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): number[];
29
29
  fetchDepositAddress(code: string, params?: {}): Promise<{
30
30
  currency: string;
31
31
  address: string;
package/js/src/lykke.js CHANGED
@@ -1081,7 +1081,7 @@ export default class lykke extends Exchange {
1081
1081
  //
1082
1082
  return this.parseTrades(payload, market, since, limit);
1083
1083
  }
1084
- parseBidAsk(bidask, priceKey = 0, amountKey = 1) {
1084
+ parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
1085
1085
  const price = this.safeString(bidask, priceKey);
1086
1086
  const amount = Precise.stringAbs(this.safeString(bidask, amountKey));
1087
1087
  return [this.parseNumber(price), this.parseNumber(amount)];
package/js/src/ndax.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/ndax.js';
2
- import type { Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Ticker, Trade, Transaction } from './base/types.js';
2
+ import type { IndexType, Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Ticker, Trade, Transaction } from './base/types.js';
3
3
  /**
4
4
  * @class ndax
5
5
  * @augments Exchange
@@ -10,7 +10,7 @@ export default class ndax extends Exchange {
10
10
  fetchCurrencies(params?: {}): Promise<{}>;
11
11
  fetchMarkets(params?: {}): Promise<import("./base/types.js").MarketInterface[]>;
12
12
  parseMarket(market: any): Market;
13
- parseOrderBook(orderbook: any, symbol: any, timestamp?: any, bidsKey?: string, asksKey?: string, priceKey?: number, amountKey?: number): OrderBook;
13
+ parseOrderBook(orderbook: any, symbol: any, timestamp?: any, bidsKey?: string, asksKey?: string, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): OrderBook;
14
14
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
15
15
  parseTicker(ticker: any, market?: Market): Ticker;
16
16
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
package/js/src/ndax.js CHANGED
@@ -521,7 +521,7 @@ export default class ndax extends Exchange {
521
521
  'info': market,
522
522
  };
523
523
  }
524
- parseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 6, amountKey = 8) {
524
+ parseOrderBook(orderbook, symbol, timestamp = undefined, bidsKey = 'bids', asksKey = 'asks', priceKey = 6, amountKey = 8, countOrIdKey = 2) {
525
525
  let nonce = undefined;
526
526
  const result = {
527
527
  'symbol': symbol,
@@ -867,7 +867,10 @@ export default class binance extends binanceRest {
867
867
  name = this.safeString(params, 'name', name);
868
868
  params = this.omit(params, 'name');
869
869
  let wsParams = [];
870
- const messageHash = 'tickers';
870
+ let messageHash = 'tickers';
871
+ if (symbols !== undefined) {
872
+ messageHash = 'tickers::' + symbols.join(',');
873
+ }
871
874
  if (name === 'bookTicker') {
872
875
  if (marketIds === undefined) {
873
876
  throw new ArgumentsRequired(this.id + ' watchTickers() requires symbols for bookTicker');
@@ -1060,6 +1063,19 @@ export default class binance extends binanceRest {
1060
1063
  this.tickers[symbol] = result;
1061
1064
  newTickers.push(result);
1062
1065
  }
1066
+ const messageHashes = this.findMessageHashes(client, 'tickers::');
1067
+ for (let i = 0; i < messageHashes.length; i++) {
1068
+ const messageHash = messageHashes[i];
1069
+ const parts = messageHash.split('::');
1070
+ const symbolsString = parts[1];
1071
+ const symbols = symbolsString.split(',');
1072
+ const tickers = this.filterByArray(newTickers, 'symbol', symbols);
1073
+ const tickersSymbols = Object.keys(tickers);
1074
+ const numTickers = tickersSymbols.length;
1075
+ if (numTickers > 0) {
1076
+ client.resolve(tickers, messageHash);
1077
+ }
1078
+ }
1063
1079
  client.resolve(newTickers, 'tickers');
1064
1080
  }
1065
1081
  signParams(params = {}) {
@@ -156,7 +156,9 @@ export default class bitget extends bitgetRest {
156
156
  }
157
157
  const tickers = await this.watchPublicMultiple(messageHashes, topics, params);
158
158
  if (this.newUpdates) {
159
- return tickers;
159
+ const result = {};
160
+ result[tickers['symbol']] = tickers;
161
+ return result;
160
162
  }
161
163
  return this.filterByArray(this.tickers, 'symbol', symbols);
162
164
  }
@@ -22,6 +22,7 @@ export default class bitmart extends bitmartRest {
22
22
  handleTrade(client: Client, message: any): any;
23
23
  parseWsTrade(trade: any, market?: Market): Trade;
24
24
  handleTicker(client: Client, message: any): any;
25
+ resolveMessageHashesForSymbol(client: any, symbol: any, result: any, prexif: any): void;
25
26
  parseWsSwapTicker(ticker: any, market?: Market): Ticker;
26
27
  watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
27
28
  handleOHLCV(client: Client, message: any): void;
@@ -293,22 +293,39 @@ export default class bitmart extends bitmartRest {
293
293
  const market = this.getMarketFromSymbols(symbols);
294
294
  let type = 'spot';
295
295
  [type, params] = this.handleMarketTypeAndParams('watchTickers', market, params);
296
+ const url = this.implodeHostname(this.urls['api']['ws'][type]['public']);
296
297
  symbols = this.marketSymbols(symbols);
297
- if (type === 'spot') {
298
- throw new NotSupported(this.id + ' watchTickers() does not support ' + type + ' markets. Use watchTicker() instead');
298
+ let messageHash = 'tickers::' + type;
299
+ if (symbols !== undefined) {
300
+ messageHash += '::' + symbols.join(',');
299
301
  }
300
- const url = this.implodeHostname(this.urls['api']['ws'][type]['public']);
301
- if (type === 'swap') {
302
- type = 'futures';
302
+ let request = undefined;
303
+ let tickers = undefined;
304
+ const isSpot = (type === 'spot');
305
+ if (isSpot) {
306
+ if (symbols === undefined) {
307
+ throw new ArgumentsRequired(this.id + ' watchTickers() for ' + type + ' market type requires symbols argument to be provided');
308
+ }
309
+ const marketIds = this.marketIds(symbols);
310
+ const finalArray = [];
311
+ for (let i = 0; i < marketIds.length; i++) {
312
+ finalArray.push('spot/ticker:' + marketIds[i]);
313
+ }
314
+ request = {
315
+ 'op': 'subscribe',
316
+ 'args': finalArray,
317
+ };
318
+ tickers = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
319
+ }
320
+ else {
321
+ request = {
322
+ 'action': 'subscribe',
323
+ 'args': ['futures/ticker'],
324
+ };
325
+ tickers = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
303
326
  }
304
- const messageHash = 'tickers';
305
- const request = {
306
- 'action': 'subscribe',
307
- 'args': ['futures/ticker'],
308
- };
309
- const newTickers = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
310
327
  if (this.newUpdates) {
311
- return newTickers;
328
+ return tickers;
312
329
  }
313
330
  return this.filterByArray(this.tickers, 'symbol', symbols);
314
331
  }
@@ -707,7 +724,7 @@ export default class bitmart extends bitmartRest {
707
724
  // }
708
725
  //
709
726
  const marketId = this.safeString(position, 'symbol');
710
- market = this.safeMarket(marketId, market, '', 'swap');
727
+ market = this.safeMarket(marketId, market, undefined, 'swap');
711
728
  const symbol = market['symbol'];
712
729
  const openTimestamp = this.safeInteger(position, 'create_time');
713
730
  const timestamp = this.safeInteger(position, 'update_time');
@@ -893,16 +910,36 @@ export default class bitmart extends bitmartRest {
893
910
  const messageHash = table + ':' + marketId;
894
911
  this.tickers[symbol] = ticker;
895
912
  client.resolve(ticker, messageHash);
913
+ this.resolveMessageHashesForSymbol(client, symbol, ticker, 'tickers::');
896
914
  }
897
915
  }
898
916
  else {
917
+ // on each update for contract markets, single ticker is provided
899
918
  const ticker = this.parseWsSwapTicker(data);
900
919
  const symbol = this.safeString(ticker, 'symbol');
901
920
  this.tickers[symbol] = ticker;
902
- client.resolve(ticker, 'tickers');
921
+ client.resolve(ticker, 'tickers::swap');
922
+ this.resolveMessageHashesForSymbol(client, symbol, ticker, 'tickers::');
903
923
  }
904
924
  return message;
905
925
  }
926
+ resolveMessageHashesForSymbol(client, symbol, result, prexif) {
927
+ const prefixSeparator = '::';
928
+ const symbolsSeparator = ',';
929
+ const messageHashes = this.findMessageHashes(client, prexif);
930
+ for (let i = 0; i < messageHashes.length; i++) {
931
+ const messageHash = messageHashes[i];
932
+ const parts = messageHash.split(prefixSeparator);
933
+ const length = parts.length;
934
+ const symbolsString = parts[length - 1];
935
+ const symbols = symbolsString.split(symbolsSeparator);
936
+ if (this.inArray(symbol, symbols)) {
937
+ const response = {};
938
+ response[symbol] = result;
939
+ client.resolve(response, messageHash);
940
+ }
941
+ }
942
+ }
906
943
  parseWsSwapTicker(ticker, market = undefined) {
907
944
  //
908
945
  // {
@@ -1049,7 +1086,7 @@ export default class bitmart extends bitmartRest {
1049
1086
  }
1050
1087
  else {
1051
1088
  const marketId = this.safeString(data, 'symbol');
1052
- const market = this.safeMarket(marketId, undefined, '', 'swap');
1089
+ const market = this.safeMarket(marketId, undefined, undefined, 'swap');
1053
1090
  const symbol = market['symbol'];
1054
1091
  const items = this.safeValue(data, 'items', []);
1055
1092
  this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
@@ -1,5 +1,5 @@
1
1
  import blockchaincomRest from '../blockchaincom.js';
2
- import type { IndexType, Int, Str, OrderBook, Order, Trade, Ticker, OHLCV, Balances } from '../base/types.js';
2
+ import type { Int, Str, OrderBook, Order, Trade, Ticker, OHLCV, Balances } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class blockchaincom extends blockchaincomRest {
5
5
  describe(): any;
@@ -19,16 +19,6 @@ export default class blockchaincom extends blockchaincomRest {
19
19
  parseWsOrderStatus(status: any): string;
20
20
  watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
21
21
  handleOrderBook(client: Client, message: any): any;
22
- parseCountedBidAsk(bidAsk: any, priceKey?: IndexType, amountKey?: IndexType, countKey?: IndexType): number[];
23
- parseCountedBidsAsks(bidasks: any, priceKey?: IndexType, amountKey?: IndexType, countKey?: IndexType): any[];
24
- parseCountedOrderBook(orderbook: any, symbol: string, timestamp?: Int, bidsKey?: IndexType, asksKey?: IndexType, priceKey?: IndexType, amountKey?: IndexType, countKey?: IndexType): {
25
- symbol: string;
26
- bids: any;
27
- asks: any;
28
- timestamp: number;
29
- datetime: string;
30
- nonce: any;
31
- };
32
22
  handleDelta(bookside: any, delta: any): void;
33
23
  handleDeltas(bookside: any, deltas: any): void;
34
24
  checkSequenceNumber(client: Client, message: any): void;