ccxt 4.2.28 → 4.2.30

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 (158) hide show
  1. package/CONTRIBUTING.md +4 -1
  2. package/README.md +6 -6
  3. package/dist/ccxt.browser.js +1865 -558
  4. package/dist/ccxt.browser.min.js +7 -7
  5. package/dist/cjs/ccxt.js +3 -1
  6. package/dist/cjs/src/ascendex.js +5 -5
  7. package/dist/cjs/src/base/Exchange.js +114 -21
  8. package/dist/cjs/src/base/errors.js +3 -3
  9. package/dist/cjs/src/base/functions/type.js +12 -0
  10. package/dist/cjs/src/bigone.js +2 -2
  11. package/dist/cjs/src/binance.js +896 -217
  12. package/dist/cjs/src/bingx.js +1 -1
  13. package/dist/cjs/src/bitfinex.js +1 -1
  14. package/dist/cjs/src/bitfinex2.js +52 -62
  15. package/dist/cjs/src/bitget.js +8 -4
  16. package/dist/cjs/src/bitmart.js +3 -3
  17. package/dist/cjs/src/bitmex.js +9 -6
  18. package/dist/cjs/src/bitrue.js +1 -1
  19. package/dist/cjs/src/bitso.js +1 -1
  20. package/dist/cjs/src/bitteam.js +2 -2
  21. package/dist/cjs/src/btcalpha.js +1 -1
  22. package/dist/cjs/src/bybit.js +28 -12
  23. package/dist/cjs/src/coinbase.js +12 -5
  24. package/dist/cjs/src/coincheck.js +1 -1
  25. package/dist/cjs/src/coinex.js +2 -2
  26. package/dist/cjs/src/coinlist.js +1 -1
  27. package/dist/cjs/src/coinmate.js +1 -1
  28. package/dist/cjs/src/coinmetro.js +12 -6
  29. package/dist/cjs/src/coinsph.js +1 -1
  30. package/dist/cjs/src/cryptocom.js +3 -3
  31. package/dist/cjs/src/digifinex.js +6 -4
  32. package/dist/cjs/src/exmo.js +2 -2
  33. package/dist/cjs/src/gate.js +5 -5
  34. package/dist/cjs/src/gemini.js +3 -3
  35. package/dist/cjs/src/hitbtc.js +14 -20
  36. package/dist/cjs/src/hollaex.js +2 -2
  37. package/dist/cjs/src/htx.js +5 -5
  38. package/dist/cjs/src/huobijp.js +1 -1
  39. package/dist/cjs/src/krakenfutures.js +1 -1
  40. package/dist/cjs/src/kucoin.js +17 -17
  41. package/dist/cjs/src/kucoinfutures.js +3 -3
  42. package/dist/cjs/src/lbank.js +1 -1
  43. package/dist/cjs/src/mexc.js +7 -7
  44. package/dist/cjs/src/novadax.js +1 -1
  45. package/dist/cjs/src/okcoin.js +2 -2
  46. package/dist/cjs/src/okx.js +24 -10
  47. package/dist/cjs/src/p2b.js +1 -0
  48. package/dist/cjs/src/phemex.js +3 -3
  49. package/dist/cjs/src/poloniexfutures.js +3 -3
  50. package/dist/cjs/src/pro/alpaca.js +1 -1
  51. package/dist/cjs/src/pro/binance.js +4 -4
  52. package/dist/cjs/src/pro/bitget.js +1 -1
  53. package/dist/cjs/src/pro/bitmart.js +1 -1
  54. package/dist/cjs/src/pro/bitmex.js +49 -6
  55. package/dist/cjs/src/pro/bitvavo.js +1 -1
  56. package/dist/cjs/src/pro/bybit.js +2 -2
  57. package/dist/cjs/src/pro/cex.js +2 -2
  58. package/dist/cjs/src/pro/coinbase.js +1 -1
  59. package/dist/cjs/src/pro/independentreserve.js +1 -1
  60. package/dist/cjs/src/pro/okx.js +1 -1
  61. package/dist/cjs/src/pro/onetrading.js +2 -2
  62. package/dist/cjs/src/pro/p2b.js +432 -0
  63. package/dist/cjs/src/pro/probit.js +5 -5
  64. package/dist/cjs/src/pro/whitebit.js +1 -1
  65. package/dist/cjs/src/probit.js +1 -1
  66. package/dist/cjs/src/timex.js +1 -1
  67. package/dist/cjs/src/tokocrypto.js +3 -3
  68. package/dist/cjs/src/wavesexchange.js +2 -2
  69. package/dist/cjs/src/whitebit.js +2 -2
  70. package/dist/cjs/src/woo.js +3 -3
  71. package/dist/cjs/src/yobit.js +1 -1
  72. package/dist/cjs/src/zaif.js +1 -1
  73. package/dist/cjs/src/zonda.js +3 -3
  74. package/js/ccxt.d.ts +4 -1
  75. package/js/ccxt.js +3 -1
  76. package/js/src/abstract/bybit.d.ts +2 -2
  77. package/js/src/abstract/okx.d.ts +1 -0
  78. package/js/src/ascendex.js +5 -5
  79. package/js/src/base/Exchange.d.ts +10 -1
  80. package/js/src/base/Exchange.js +114 -21
  81. package/js/src/base/errorHierarchy.d.ts +7 -6
  82. package/js/src/base/errorHierarchy.js +7 -6
  83. package/js/src/base/errors.d.ts +3 -3
  84. package/js/src/base/errors.js +3 -3
  85. package/js/src/base/functions/type.js +12 -0
  86. package/js/src/bigone.js +2 -2
  87. package/js/src/binance.d.ts +1 -0
  88. package/js/src/binance.js +897 -218
  89. package/js/src/bingx.js +1 -1
  90. package/js/src/bitfinex.js +1 -1
  91. package/js/src/bitfinex2.js +52 -62
  92. package/js/src/bitget.js +8 -4
  93. package/js/src/bitmart.js +3 -3
  94. package/js/src/bitmex.js +9 -6
  95. package/js/src/bitrue.js +1 -1
  96. package/js/src/bitso.d.ts +1 -1
  97. package/js/src/bitso.js +1 -1
  98. package/js/src/bitteam.js +2 -2
  99. package/js/src/btcalpha.js +1 -1
  100. package/js/src/bybit.js +28 -12
  101. package/js/src/coinbase.js +12 -5
  102. package/js/src/coincheck.js +1 -1
  103. package/js/src/coinex.js +2 -2
  104. package/js/src/coinlist.js +1 -1
  105. package/js/src/coinmate.js +1 -1
  106. package/js/src/coinmetro.d.ts +1 -1
  107. package/js/src/coinmetro.js +12 -6
  108. package/js/src/coinsph.js +1 -1
  109. package/js/src/cryptocom.js +3 -3
  110. package/js/src/digifinex.js +6 -4
  111. package/js/src/exmo.js +2 -2
  112. package/js/src/gate.js +5 -5
  113. package/js/src/gemini.d.ts +1 -1
  114. package/js/src/gemini.js +3 -3
  115. package/js/src/hitbtc.js +14 -20
  116. package/js/src/hollaex.js +2 -2
  117. package/js/src/htx.js +5 -5
  118. package/js/src/huobijp.js +1 -1
  119. package/js/src/krakenfutures.js +1 -1
  120. package/js/src/kucoin.js +17 -17
  121. package/js/src/kucoinfutures.js +3 -3
  122. package/js/src/lbank.js +1 -1
  123. package/js/src/mexc.js +7 -7
  124. package/js/src/novadax.js +1 -1
  125. package/js/src/okcoin.js +2 -2
  126. package/js/src/okx.js +24 -10
  127. package/js/src/p2b.js +1 -0
  128. package/js/src/phemex.js +3 -3
  129. package/js/src/poloniexfutures.js +3 -3
  130. package/js/src/pro/alpaca.js +1 -1
  131. package/js/src/pro/binance.js +4 -4
  132. package/js/src/pro/bitget.js +1 -1
  133. package/js/src/pro/bitmart.js +1 -1
  134. package/js/src/pro/bitmex.d.ts +2 -1
  135. package/js/src/pro/bitmex.js +49 -6
  136. package/js/src/pro/bitvavo.js +1 -1
  137. package/js/src/pro/bybit.js +2 -2
  138. package/js/src/pro/cex.js +2 -2
  139. package/js/src/pro/coinbase.js +2 -2
  140. package/js/src/pro/independentreserve.js +1 -1
  141. package/js/src/pro/okx.js +1 -1
  142. package/js/src/pro/onetrading.js +2 -2
  143. package/js/src/pro/p2b.d.ts +23 -0
  144. package/js/src/pro/p2b.js +433 -0
  145. package/js/src/pro/probit.js +5 -5
  146. package/js/src/pro/whitebit.js +1 -1
  147. package/js/src/probit.js +1 -1
  148. package/js/src/timex.js +1 -1
  149. package/js/src/tokocrypto.js +3 -3
  150. package/js/src/wavesexchange.js +2 -2
  151. package/js/src/whitebit.js +2 -2
  152. package/js/src/woo.js +3 -3
  153. package/js/src/yobit.js +1 -1
  154. package/js/src/zaif.js +1 -1
  155. package/js/src/zonda.d.ts +1 -1
  156. package/js/src/zonda.js +3 -3
  157. package/package.json +1 -1
  158. package/skip-tests.json +3 -10
package/js/src/okx.js CHANGED
@@ -175,6 +175,7 @@ export default class okx extends Exchange {
175
175
  'api': {
176
176
  'public': {
177
177
  'get': {
178
+ 'market/books-full': 2,
178
179
  'market/tickers': 1,
179
180
  'market/ticker': 1,
180
181
  'market/index-tickers': 1,
@@ -1673,6 +1674,7 @@ export default class okx extends Exchange {
1673
1674
  * @param {string} symbol unified symbol of the market to fetch the order book for
1674
1675
  * @param {int} [limit] the maximum amount of order book entries to return
1675
1676
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1677
+ * @param {string} [params.method] 'publicGetMarketBooksFull' or 'publicGetMarketBooks' default is 'publicGetMarketBooks'
1676
1678
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
1677
1679
  */
1678
1680
  await this.loadMarkets();
@@ -1680,11 +1682,22 @@ export default class okx extends Exchange {
1680
1682
  const request = {
1681
1683
  'instId': market['id'],
1682
1684
  };
1683
- limit = (limit === undefined) ? 20 : limit;
1685
+ let method = undefined;
1686
+ [method, params] = this.handleOptionAndParams(params, 'fetchOrderBook', 'method', 'publicGetMarketBooks');
1687
+ if (method === 'publicGetMarketBooksFull' && limit === undefined) {
1688
+ limit = 5000;
1689
+ }
1690
+ limit = (limit === undefined) ? 100 : limit;
1684
1691
  if (limit !== undefined) {
1685
1692
  request['sz'] = limit; // max 400
1686
1693
  }
1687
- const response = await this.publicGetMarketBooks(this.extend(request, params));
1694
+ let response = undefined;
1695
+ if ((method === 'publicGetMarketBooksFull') || (limit > 400)) {
1696
+ response = await this.publicGetMarketBooksFull(this.extend(request, params));
1697
+ }
1698
+ else {
1699
+ response = await this.publicGetMarketBooks(this.extend(request, params));
1700
+ }
1688
1701
  //
1689
1702
  // {
1690
1703
  // "code": "0",
@@ -1738,7 +1751,7 @@ export default class okx extends Exchange {
1738
1751
  const symbol = market['symbol'];
1739
1752
  const last = this.safeString(ticker, 'last');
1740
1753
  const open = this.safeString(ticker, 'open24h');
1741
- const spot = this.safeValue(market, 'spot', false);
1754
+ const spot = this.safeBool(market, 'spot', false);
1742
1755
  const quoteVolume = spot ? this.safeString(ticker, 'volCcy24h') : undefined;
1743
1756
  const baseVolume = this.safeString(ticker, 'vol24h');
1744
1757
  const high = this.safeString(ticker, 'high24h');
@@ -2128,7 +2141,8 @@ export default class okx extends Exchange {
2128
2141
  if (since < historyBorder) {
2129
2142
  defaultType = 'HistoryCandles';
2130
2143
  }
2131
- request['before'] = since;
2144
+ const startTime = Math.max(since - 1, 0);
2145
+ request['before'] = startTime;
2132
2146
  request['after'] = this.sum(since, durationInMilliseconds * limit);
2133
2147
  }
2134
2148
  const until = this.safeInteger(params, 'until');
@@ -2594,7 +2608,7 @@ export default class okx extends Exchange {
2594
2608
  }
2595
2609
  else {
2596
2610
  marginMode = defaultMarginMode;
2597
- margin = this.safeValue(params, 'margin', false);
2611
+ margin = this.safeBool(params, 'margin', false);
2598
2612
  }
2599
2613
  if (spot) {
2600
2614
  if (margin) {
@@ -3093,7 +3107,7 @@ export default class okx extends Exchange {
3093
3107
  throw new ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
3094
3108
  }
3095
3109
  const stop = this.safeValue2(params, 'stop', 'trigger');
3096
- const trailing = this.safeValue(params, 'trailing', false);
3110
+ const trailing = this.safeBool(params, 'trailing', false);
3097
3111
  if (stop || trailing) {
3098
3112
  const orderInner = await this.cancelOrders([id], symbol, params);
3099
3113
  return this.safeValue(orderInner, 0);
@@ -3161,7 +3175,7 @@ export default class okx extends Exchange {
3161
3175
  const clientOrderIds = this.parseIds(this.safeValue2(params, 'clOrdId', 'clientOrderId'));
3162
3176
  const algoIds = this.parseIds(this.safeValue(params, 'algoId'));
3163
3177
  const stop = this.safeValue2(params, 'stop', 'trigger');
3164
- const trailing = this.safeValue(params, 'trailing', false);
3178
+ const trailing = this.safeBool(params, 'trailing', false);
3165
3179
  if (stop || trailing) {
3166
3180
  method = 'privatePostTradeCancelAlgos';
3167
3181
  }
@@ -3660,7 +3674,7 @@ export default class okx extends Exchange {
3660
3674
  let method = this.safeString(params, 'method', defaultMethod);
3661
3675
  const ordType = this.safeString(params, 'ordType');
3662
3676
  const stop = this.safeValue2(params, 'stop', 'trigger');
3663
- const trailing = this.safeValue(params, 'trailing', false);
3677
+ const trailing = this.safeBool(params, 'trailing', false);
3664
3678
  if (trailing || stop || (ordType in algoOrderTypes)) {
3665
3679
  method = 'privateGetTradeOrdersAlgoPending';
3666
3680
  }
@@ -3829,7 +3843,7 @@ export default class okx extends Exchange {
3829
3843
  let method = this.safeString(params, 'method', defaultMethod);
3830
3844
  const ordType = this.safeString(params, 'ordType');
3831
3845
  const stop = this.safeValue2(params, 'stop', 'trigger');
3832
- const trailing = this.safeValue(params, 'trailing', false);
3846
+ const trailing = this.safeBool(params, 'trailing', false);
3833
3847
  if (trailing) {
3834
3848
  method = 'privateGetTradeOrdersAlgoHistory';
3835
3849
  request['ordType'] = 'move_order_stop';
@@ -4023,7 +4037,7 @@ export default class okx extends Exchange {
4023
4037
  let method = this.safeString(params, 'method', defaultMethod);
4024
4038
  const ordType = this.safeString(params, 'ordType');
4025
4039
  const stop = this.safeValue2(params, 'stop', 'trigger');
4026
- const trailing = this.safeValue(params, 'trailing', false);
4040
+ const trailing = this.safeBool(params, 'trailing', false);
4027
4041
  if (trailing || stop || (ordType in algoOrderTypes)) {
4028
4042
  method = 'privateGetTradeOrdersAlgoHistory';
4029
4043
  request['state'] = 'effective';
package/js/src/p2b.js CHANGED
@@ -22,6 +22,7 @@ export default class p2b extends Exchange {
22
22
  'countries': ['LT'],
23
23
  'rateLimit': 100,
24
24
  'version': 'v2',
25
+ 'pro': true,
25
26
  'has': {
26
27
  'CORS': undefined,
27
28
  'spot': true,
package/js/src/phemex.js CHANGED
@@ -2420,7 +2420,7 @@ export default class phemex extends Exchange {
2420
2420
  });
2421
2421
  }
2422
2422
  parseOrder(order, market = undefined) {
2423
- const isSwap = this.safeValue(market, 'swap', false);
2423
+ const isSwap = this.safeBool(market, 'swap', false);
2424
2424
  const hasPnl = ('closedPnl' in order);
2425
2425
  if (isSwap || hasPnl) {
2426
2426
  return this.parseSwapOrder(order, market);
@@ -4332,7 +4332,7 @@ export default class phemex extends Exchange {
4332
4332
  throw new BadRequest(this.id + ' setLeverage() leverage should be between -100 and 100');
4333
4333
  }
4334
4334
  await this.loadMarkets();
4335
- const isHedged = this.safeValue(params, 'hedged', false);
4335
+ const isHedged = this.safeBool(params, 'hedged', false);
4336
4336
  const longLeverageRr = this.safeInteger(params, 'longLeverageRr');
4337
4337
  const shortLeverageRr = this.safeInteger(params, 'shortLeverageRr');
4338
4338
  const market = this.market(symbol);
@@ -4428,7 +4428,7 @@ export default class phemex extends Exchange {
4428
4428
  transfer = this.parseTransfer(response);
4429
4429
  }
4430
4430
  const transferOptions = this.safeValue(this.options, 'transfer', {});
4431
- const fillResponseFromRequest = this.safeValue(transferOptions, 'fillResponseFromRequest', true);
4431
+ const fillResponseFromRequest = this.safeBool(transferOptions, 'fillResponseFromRequest', true);
4432
4432
  if (fillResponseFromRequest) {
4433
4433
  if (transfer['fromAccount'] === undefined) {
4434
4434
  transfer['fromAccount'] = fromAccount;
@@ -864,7 +864,7 @@ export default class poloniexfutures extends Exchange {
864
864
  request['timeInForce'] = timeInForce;
865
865
  }
866
866
  }
867
- const postOnly = this.safeValue(params, 'postOnly', false);
867
+ const postOnly = this.safeBool(params, 'postOnly', false);
868
868
  const hidden = this.safeValue(params, 'hidden');
869
869
  if (postOnly && (hidden !== undefined)) {
870
870
  throw new BadRequest(this.id + ' createOrder() does not support the postOnly parameter together with a hidden parameter');
@@ -1555,8 +1555,8 @@ export default class poloniexfutures extends Exchange {
1555
1555
  // precision reported by their api is 8 d.p.
1556
1556
  // const average = Precise.stringDiv (rawCost, Precise.stringMul (filled, market['contractSize']));
1557
1557
  // bool
1558
- const isActive = this.safeValue(order, 'isActive', false);
1559
- const cancelExist = this.safeValue(order, 'cancelExist', false);
1558
+ const isActive = this.safeBool(order, 'isActive', false);
1559
+ const cancelExist = this.safeBool(order, 'cancelExist', false);
1560
1560
  const status = isActive ? 'open' : 'closed';
1561
1561
  let id = this.safeString(order, 'id');
1562
1562
  if ('cancelledOrderIds' in order) {
@@ -227,7 +227,7 @@ export default class alpaca extends alpacaRest {
227
227
  const symbol = this.safeSymbol(marketId);
228
228
  const datetime = this.safeString(message, 't');
229
229
  const timestamp = this.parse8601(datetime);
230
- const isSnapshot = this.safeValue(message, 'r', false);
230
+ const isSnapshot = this.safeBool(message, 'r', false);
231
231
  let orderbook = this.safeValue(this.orderbooks, symbol);
232
232
  if (orderbook === undefined) {
233
233
  orderbook = this.orderBook();
@@ -1273,7 +1273,7 @@ export default class binance extends binanceRest {
1273
1273
  return undefined;
1274
1274
  }
1275
1275
  const options = this.safeValue(this.options, 'watchBalance');
1276
- const fetchBalanceSnapshot = this.safeValue(options, 'fetchBalanceSnapshot', false);
1276
+ const fetchBalanceSnapshot = this.safeBool(options, 'fetchBalanceSnapshot', false);
1277
1277
  if (fetchBalanceSnapshot) {
1278
1278
  const messageHash = type + ':fetchBalanceSnapshot';
1279
1279
  if (!(messageHash in client.futures)) {
@@ -1399,8 +1399,8 @@ export default class binance extends binanceRest {
1399
1399
  this.setBalanceCache(client, type);
1400
1400
  this.setPositionsCache(client, type);
1401
1401
  const options = this.safeValue(this.options, 'watchBalance');
1402
- const fetchBalanceSnapshot = this.safeValue(options, 'fetchBalanceSnapshot', false);
1403
- const awaitBalanceSnapshot = this.safeValue(options, 'awaitBalanceSnapshot', true);
1402
+ const fetchBalanceSnapshot = this.safeBool(options, 'fetchBalanceSnapshot', false);
1403
+ const awaitBalanceSnapshot = this.safeBool(options, 'awaitBalanceSnapshot', true);
1404
1404
  if (fetchBalanceSnapshot && awaitBalanceSnapshot) {
1405
1405
  await client.future(type + ':fetchBalanceSnapshot');
1406
1406
  }
@@ -1561,7 +1561,7 @@ export default class binance extends binanceRest {
1561
1561
  let returnRateLimits = false;
1562
1562
  [returnRateLimits, params] = this.handleOptionAndParams(params, 'createOrderWs', 'returnRateLimits', false);
1563
1563
  payload['returnRateLimits'] = returnRateLimits;
1564
- const test = this.safeValue(params, 'test', false);
1564
+ const test = this.safeBool(params, 'test', false);
1565
1565
  params = this.omit(params, 'test');
1566
1566
  const message = {
1567
1567
  'id': messageHash,
@@ -895,7 +895,7 @@ export default class bitget extends bitgetRest {
895
895
  await this.loadMarkets();
896
896
  let market = undefined;
897
897
  let marketId = undefined;
898
- const isStop = this.safeValue(params, 'stop', false);
898
+ const isStop = this.safeBool(params, 'stop', false);
899
899
  params = this.omit(params, 'stop');
900
900
  let messageHash = (isStop) ? 'triggerOrder' : 'order';
901
901
  let subscriptionHash = 'order:trades';
@@ -146,7 +146,7 @@ export default class bitmart extends bitmartRest {
146
146
  return;
147
147
  }
148
148
  const options = this.safeValue(this.options, 'watchBalance');
149
- const snapshot = this.safeValue(options, 'fetchBalanceSnapshot', true);
149
+ const snapshot = this.safeBool(options, 'fetchBalanceSnapshot', true);
150
150
  if (snapshot) {
151
151
  const messageHash = type + ':' + 'fetchBalanceSnapshot';
152
152
  if (!(messageHash in client.futures)) {
@@ -1,9 +1,10 @@
1
1
  import bitmexRest from '../bitmex.js';
2
- import type { Int, Str, Strings, OrderBook, Order, Trade, Ticker, OHLCV, Position, Balances } from '../base/types.js';
2
+ import type { Int, Str, Strings, OrderBook, Order, Trade, Ticker, Tickers, OHLCV, Position, Balances } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class bitmex extends bitmexRest {
5
5
  describe(): any;
6
6
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
7
+ watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
7
8
  handleTicker(client: Client, message: any): any;
8
9
  watchBalance(params?: {}): Promise<Balances>;
9
10
  handleBalance(client: Client, message: any): void;
@@ -23,7 +23,7 @@ export default class bitmex extends bitmexRest {
23
23
  'watchOrders': true,
24
24
  'watchPostions': true,
25
25
  'watchTicker': true,
26
- 'watchTickers': false,
26
+ 'watchTickers': true,
27
27
  'watchTrades': true,
28
28
  'watchTradesForSymbols': true,
29
29
  },
@@ -75,6 +75,46 @@ export default class bitmex extends bitmexRest {
75
75
  };
76
76
  return await this.watch(url, messageHash, this.extend(request, params), messageHash);
77
77
  }
78
+ async watchTickers(symbols = undefined, params = {}) {
79
+ /**
80
+ * @method
81
+ * @name bitmex#watchTickers
82
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
83
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
84
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
85
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
86
+ */
87
+ await this.loadMarkets();
88
+ symbols = this.marketSymbols(symbols, undefined, true);
89
+ const name = 'instrument';
90
+ const url = this.urls['api']['ws'];
91
+ const messageHashes = [];
92
+ if (symbols !== undefined) {
93
+ for (let i = 0; i < symbols.length; i++) {
94
+ const symbol = symbols[i];
95
+ const market = this.market(symbol);
96
+ const hash = name + ':' + market['id'];
97
+ messageHashes.push(hash);
98
+ }
99
+ }
100
+ else {
101
+ messageHashes.push(name);
102
+ }
103
+ const request = {
104
+ 'op': 'subscribe',
105
+ 'args': messageHashes,
106
+ };
107
+ const ticker = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes);
108
+ if (this.newUpdates) {
109
+ if (symbols === undefined) {
110
+ return ticker;
111
+ }
112
+ const result = {};
113
+ result[ticker['symbol']] = ticker;
114
+ return result;
115
+ }
116
+ return this.filterByArray(this.tickers, 'symbol', symbols);
117
+ }
78
118
  handleTicker(client, message) {
79
119
  //
80
120
  // {
@@ -303,19 +343,22 @@ export default class bitmex extends bitmexRest {
303
343
  // }
304
344
  //
305
345
  const table = this.safeString(message, 'table');
306
- const data = this.safeValue(message, 'data', []);
346
+ const data = this.safeList(message, 'data', []);
347
+ const tickers = {};
307
348
  for (let i = 0; i < data.length; i++) {
308
349
  const update = data[i];
309
- const marketId = this.safeValue(update, 'symbol');
350
+ const marketId = this.safeString(update, 'symbol');
310
351
  const market = this.safeMarket(marketId);
311
352
  const symbol = market['symbol'];
312
353
  const messageHash = table + ':' + marketId;
313
- let ticker = this.safeValue(this.tickers, symbol, {});
314
- const info = this.safeValue(ticker, 'info', {});
354
+ let ticker = this.safeDict(this.tickers, symbol, {});
355
+ const info = this.safeDict(ticker, 'info', {});
315
356
  ticker = this.parseTicker(this.extend(info, update), market);
357
+ tickers[symbol] = ticker;
316
358
  this.tickers[symbol] = ticker;
317
359
  client.resolve(ticker, messageHash);
318
360
  }
361
+ client.resolve(tickers, 'instrument');
319
362
  return message;
320
363
  }
321
364
  async watchBalance(params = {}) {
@@ -579,7 +622,7 @@ export default class bitmex extends bitmexRest {
579
622
  return future;
580
623
  }
581
624
  handleAuthenticationMessage(client, message) {
582
- const authenticated = this.safeValue(message, 'success', false);
625
+ const authenticated = this.safeBool(message, 'success', false);
583
626
  const messageHash = 'authenticated';
584
627
  if (authenticated) {
585
628
  // we resolve the future here permanently so authentication only happens once
@@ -1228,7 +1228,7 @@ export default class bitvavo extends bitvavoRest {
1228
1228
  // }
1229
1229
  //
1230
1230
  const messageHash = 'authenticated';
1231
- const authenticated = this.safeValue(message, 'authenticated', false);
1231
+ const authenticated = this.safeBool(message, 'authenticated', false);
1232
1232
  if (authenticated) {
1233
1233
  // we resolve the future here permanently so authentication only happens once
1234
1234
  client.resolve(message, messageHash);
@@ -1345,8 +1345,8 @@ export default class bybit extends bybitRest {
1345
1345
  let subType = undefined;
1346
1346
  [subType, params] = this.handleSubTypeAndParams('watchBalance', undefined, params);
1347
1347
  const unified = await this.isUnifiedEnabled();
1348
- const isUnifiedMargin = this.safeValue(unified, 0, false);
1349
- const isUnifiedAccount = this.safeValue(unified, 1, false);
1348
+ const isUnifiedMargin = this.safeBool(unified, 0, false);
1349
+ const isUnifiedAccount = this.safeBool(unified, 1, false);
1350
1350
  const url = this.getUrlByMarketType(undefined, true, method, params);
1351
1351
  await this.authenticate(url);
1352
1352
  const topicByMarket = {
package/js/src/pro/cex.js CHANGED
@@ -720,7 +720,7 @@ export default class cex extends cexRest {
720
720
  order = this.parseWsOrderUpdate(data, market);
721
721
  }
722
722
  order['remaining'] = remains;
723
- const canceled = this.safeValue(data, 'cancel', false);
723
+ const canceled = this.safeBool(data, 'cancel', false);
724
724
  if (canceled) {
725
725
  order['status'] = 'canceled';
726
726
  }
@@ -809,7 +809,7 @@ export default class cex extends cexRest {
809
809
  if (isTransaction) {
810
810
  timestamp = this.parse8601(time);
811
811
  }
812
- const canceled = this.safeValue(order, 'cancel', false);
812
+ const canceled = this.safeBool(order, 'cancel', false);
813
813
  let status = 'open';
814
814
  if (canceled) {
815
815
  status = 'canceled';
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import coinbaseRest from '../coinbase.js';
9
- import { ArgumentsRequired, ExchangeError } from '../base/errors.js';
9
+ import { ExchangeError } from '../base/errors.js';
10
10
  import { ArrayCacheBySymbolById } from '../base/ws/Cache.js';
11
11
  import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
12
12
  // ---------------------------------------------------------------------------
@@ -113,7 +113,7 @@ export default class coinbase extends coinbaseRest {
113
113
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
114
114
  */
115
115
  if (symbols === undefined) {
116
- throw new ArgumentsRequired(this.id + ' watchTickers requires a symbols argument');
116
+ symbols = this.symbols;
117
117
  }
118
118
  const name = 'ticker_batch';
119
119
  const tickers = await this.subscribe(name, symbols, params);
@@ -179,7 +179,7 @@ export default class independentreserve extends independentreserveRest {
179
179
  const orderBook = this.safeValue(message, 'Data', {});
180
180
  const messageHash = 'orderbook:' + symbol + ':' + depth;
181
181
  const subscription = this.safeValue(client.subscriptions, messageHash, {});
182
- const receivedSnapshot = this.safeValue(subscription, 'receivedSnapshot', false);
182
+ const receivedSnapshot = this.safeBool(subscription, 'receivedSnapshot', false);
183
183
  const timestamp = this.safeInteger(message, 'Time');
184
184
  let storedOrderBook = this.safeValue(this.orderbooks, symbol);
185
185
  if (storedOrderBook === undefined) {
package/js/src/pro/okx.js CHANGED
@@ -867,7 +867,7 @@ export default class okx extends okxRest {
867
867
  // By default, receive order updates from any instrument type
868
868
  let type = undefined;
869
869
  [type, params] = this.handleOptionAndParams(params, 'watchMyTrades', 'type', 'ANY');
870
- const isStop = this.safeValue(params, 'stop', false);
870
+ const isStop = this.safeBool(params, 'stop', false);
871
871
  params = this.omit(params, ['stop']);
872
872
  await this.loadMarkets();
873
873
  await this.authenticate({ 'access': isStop ? 'business' : 'private' });
@@ -1060,7 +1060,7 @@ export default class onetrading extends onetradingRest {
1060
1060
  subscription = this.safeValue(client.subscriptions, subscriptionHash);
1061
1061
  if (subscription !== undefined) {
1062
1062
  const ohlcvMarket = this.safeValue(subscription, marketId, {});
1063
- const marketSubscribed = this.safeValue(ohlcvMarket, timeframe, false);
1063
+ const marketSubscribed = this.safeBool(ohlcvMarket, timeframe, false);
1064
1064
  if (!marketSubscribed) {
1065
1065
  type = 'UPDATE_SUBSCRIPTION';
1066
1066
  client.subscriptions[subscriptionHash] = undefined;
@@ -1301,7 +1301,7 @@ export default class onetrading extends onetradingRest {
1301
1301
  if (subscription !== undefined) {
1302
1302
  for (let i = 0; i < marketIds.length; i++) {
1303
1303
  const marketId = marketIds[i];
1304
- const marketSubscribed = this.safeValue(subscription, marketId, false);
1304
+ const marketSubscribed = this.safeBool(subscription, marketId, false);
1305
1305
  if (!marketSubscribed) {
1306
1306
  type = 'UPDATE_SUBSCRIPTION';
1307
1307
  client.subscriptions[subscriptionHash] = undefined;
@@ -0,0 +1,23 @@
1
+ import p2bRest from '../p2b.js';
2
+ import type { Int, OHLCV, OrderBook, Trade, Ticker } from '../base/types.js';
3
+ import Client from '../base/ws/Client.js';
4
+ export default class p2b extends p2bRest {
5
+ describe(): any;
6
+ subscribe(name: string, messageHash: string, request: any, params?: {}): Promise<any>;
7
+ watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
8
+ watchTicker(symbol: string, params?: {}): Promise<Ticker>;
9
+ watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
10
+ watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
11
+ handleOHLCV(client: Client, message: any): any;
12
+ handleTrade(client: Client, message: any): any;
13
+ handleTicker(client: Client, message: any): any;
14
+ handleOrderBook(client: Client, message: any): void;
15
+ handleMessage(client: Client, message: any): any;
16
+ handleErrorMessage(client: Client, message: any): boolean;
17
+ ping(client: any): {
18
+ method: string;
19
+ params: any[];
20
+ id: number;
21
+ };
22
+ handlePong(client: Client, message: any): any;
23
+ }