ccxt 4.0.99 → 4.0.101

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 (91) hide show
  1. package/CHANGELOG.md +224 -0
  2. package/README.md +3 -3
  3. package/dist/ccxt.browser.js +477 -226
  4. package/dist/ccxt.browser.min.js +2 -2
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/base/Exchange.js +6 -1
  7. package/dist/cjs/src/binance.js +28 -1
  8. package/dist/cjs/src/bitbank.js +11 -0
  9. package/dist/cjs/src/bitfinex.js +12 -8
  10. package/dist/cjs/src/bitflyer.js +39 -10
  11. package/dist/cjs/src/bitforex.js +0 -8
  12. package/dist/cjs/src/bitget.js +15 -5
  13. package/dist/cjs/src/bitstamp1.js +22 -0
  14. package/dist/cjs/src/bl3p.js +24 -0
  15. package/dist/cjs/src/bybit.js +111 -36
  16. package/dist/cjs/src/coinbasepro.js +11 -0
  17. package/dist/cjs/src/currencycom.js +1 -1
  18. package/dist/cjs/src/deribit.js +3 -3
  19. package/dist/cjs/src/huobi.js +1 -1
  20. package/dist/cjs/src/huobijp.js +1 -1
  21. package/dist/cjs/src/idex.js +1 -1
  22. package/dist/cjs/src/kucoinfutures.js +46 -51
  23. package/dist/cjs/src/lbank.js +1 -1
  24. package/dist/cjs/src/lbank2.js +3 -3
  25. package/dist/cjs/src/okx.js +5 -5
  26. package/dist/cjs/src/pro/ascendex.js +2 -2
  27. package/dist/cjs/src/pro/binance.js +11 -11
  28. package/dist/cjs/src/pro/bitfinex2.js +5 -5
  29. package/dist/cjs/src/pro/bitget.js +5 -5
  30. package/dist/cjs/src/pro/bitmex.js +2 -2
  31. package/dist/cjs/src/pro/bittrex.js +2 -2
  32. package/dist/cjs/src/pro/bitvavo.js +2 -2
  33. package/dist/cjs/src/pro/bybit.js +2 -2
  34. package/dist/cjs/src/pro/coinbase.js +5 -6
  35. package/dist/cjs/src/pro/cryptocom.js +4 -4
  36. package/dist/cjs/src/pro/currencycom.js +3 -3
  37. package/dist/cjs/src/pro/hitbtc.js +4 -4
  38. package/dist/cjs/src/pro/huobi.js +7 -8
  39. package/dist/cjs/src/pro/huobijp.js +1 -2
  40. package/dist/cjs/src/pro/krakenfutures.js +7 -7
  41. package/dist/cjs/src/pro/kucoin.js +51 -2
  42. package/dist/cjs/src/pro/kucoinfutures.js +3 -3
  43. package/dist/cjs/src/pro/phemex.js +4 -4
  44. package/dist/cjs/src/pro/poloniex.js +6 -6
  45. package/dist/cjs/src/pro/whitebit.js +7 -7
  46. package/dist/cjs/src/probit.js +2 -2
  47. package/js/ccxt.d.ts +1 -1
  48. package/js/ccxt.js +1 -1
  49. package/js/src/base/Exchange.js +6 -1
  50. package/js/src/binance.js +28 -1
  51. package/js/src/bitbank.js +11 -0
  52. package/js/src/bitfinex.js +12 -8
  53. package/js/src/bitflyer.js +39 -10
  54. package/js/src/bitforex.js +0 -8
  55. package/js/src/bitget.js +15 -5
  56. package/js/src/bitstamp1.js +22 -0
  57. package/js/src/bl3p.js +24 -0
  58. package/js/src/bybit.js +111 -36
  59. package/js/src/coinbasepro.js +11 -0
  60. package/js/src/currencycom.js +1 -1
  61. package/js/src/deribit.js +3 -3
  62. package/js/src/huobi.js +1 -1
  63. package/js/src/huobijp.js +1 -1
  64. package/js/src/idex.js +1 -1
  65. package/js/src/kucoinfutures.js +46 -51
  66. package/js/src/lbank.js +1 -1
  67. package/js/src/lbank2.js +3 -3
  68. package/js/src/okx.js +5 -5
  69. package/js/src/pro/ascendex.js +2 -2
  70. package/js/src/pro/binance.js +11 -11
  71. package/js/src/pro/bitfinex2.js +5 -5
  72. package/js/src/pro/bitget.js +5 -5
  73. package/js/src/pro/bitmex.js +2 -2
  74. package/js/src/pro/bittrex.js +2 -2
  75. package/js/src/pro/bitvavo.js +2 -2
  76. package/js/src/pro/bybit.js +2 -2
  77. package/js/src/pro/coinbase.js +5 -6
  78. package/js/src/pro/cryptocom.js +4 -4
  79. package/js/src/pro/currencycom.js +3 -3
  80. package/js/src/pro/hitbtc.js +4 -4
  81. package/js/src/pro/huobi.js +7 -8
  82. package/js/src/pro/huobijp.js +1 -2
  83. package/js/src/pro/krakenfutures.js +7 -7
  84. package/js/src/pro/kucoin.d.ts +1 -0
  85. package/js/src/pro/kucoin.js +51 -2
  86. package/js/src/pro/kucoinfutures.js +3 -3
  87. package/js/src/pro/phemex.js +4 -4
  88. package/js/src/pro/poloniex.js +6 -6
  89. package/js/src/pro/whitebit.js +7 -7
  90. package/js/src/probit.js +2 -2
  91. package/package.json +1 -1
@@ -8207,7 +8207,12 @@ class Exchange {
8207
8207
  const oldNumber = this.number;
8208
8208
  // we parse trades as strings here!
8209
8209
  this.number = String;
8210
- trades = this.parseTrades(rawTrades, market);
8210
+ const firstTrade = this.safeValue(rawTrades, 0);
8211
+ // parse trades if they haven't already been parsed
8212
+ const tradesAreParsed = ((firstTrade !== undefined) && ('info' in firstTrade) && ('id' in firstTrade));
8213
+ if (!tradesAreParsed) {
8214
+ trades = this.parseTrades(rawTrades, market);
8215
+ }
8211
8216
  this.number = oldNumber;
8212
8217
  let tradesLength = 0;
8213
8218
  const isArray = Array.isArray(trades);
@@ -19090,6 +19095,18 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
19090
19095
  // "M": true // Was the trade the best price match?
19091
19096
  // }
19092
19097
  //
19098
+ // REST: aggregate trades for swap & future (both linear and inverse)
19099
+ //
19100
+ // {
19101
+ // "a": "269772814",
19102
+ // "p": "25864.1",
19103
+ // "q": "3",
19104
+ // "f": "662149354",
19105
+ // "l": "662149355",
19106
+ // "T": "1694209776022",
19107
+ // "m": false,
19108
+ // }
19109
+ //
19093
19110
  // recent public trades and old public trades
19094
19111
  // https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#recent-trades-list
19095
19112
  // https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#old-trade-lookup-market_data
@@ -19343,7 +19360,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
19343
19360
  }
19344
19361
  }
19345
19362
  if (limit !== undefined) {
19346
- request['limit'] = limit; // default = 500, maximum = 1000
19363
+ const isFutureOrSwap = (market['swap'] || market['future']);
19364
+ request['limit'] = isFutureOrSwap ? Math.min(limit, 1000) : limit; // default = 500, maximum = 1000
19347
19365
  }
19348
19366
  params = this.omit(params, ['until', 'fetchTradesMethod']);
19349
19367
  //
@@ -19372,6 +19390,20 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
19372
19390
  // }
19373
19391
  // ]
19374
19392
  //
19393
+ // inverse (swap & future)
19394
+ //
19395
+ // [
19396
+ // {
19397
+ // "a": "269772814",
19398
+ // "p": "25864.1",
19399
+ // "q": "3",
19400
+ // "f": "662149354",
19401
+ // "l": "662149355",
19402
+ // "T": "1694209776022",
19403
+ // "m": false,
19404
+ // },
19405
+ // ]
19406
+ //
19375
19407
  // recent public trades and historical public trades
19376
19408
  //
19377
19409
  // [
@@ -28886,6 +28918,17 @@ class bitbank extends _abstract_bitbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28886
28918
  return this.parseOrderBook(orderbook, market['symbol'], timestamp);
28887
28919
  }
28888
28920
  parseTrade(trade, market = undefined) {
28921
+ //
28922
+ // fetchTrades
28923
+ //
28924
+ // {
28925
+ // "transaction_id": "1143247037",
28926
+ // "side": "buy",
28927
+ // "price": "3836025",
28928
+ // "amount": "0.0005",
28929
+ // "executed_at": "1694249441593"
28930
+ // }
28931
+ //
28889
28932
  const timestamp = this.safeInteger(trade, 'executed_at');
28890
28933
  market = this.safeMarket(undefined, market);
28891
28934
  const priceString = this.safeString(trade, 'price');
@@ -31720,14 +31763,6 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
31720
31763
  // "type":"sell"
31721
31764
  // }
31722
31765
  //
31723
- // { "timestamp":1637258238,
31724
- // "tid":894452800,
31725
- // "price":"0.99958",
31726
- // "amount":"261.90514",
31727
- // "exchange":"bitfinex",
31728
- // "type":"buy"
31729
- // }
31730
- //
31731
31766
  // fetchMyTrades (private) v1
31732
31767
  //
31733
31768
  // {
@@ -31806,6 +31841,18 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
31806
31841
  request['timestamp'] = this.parseToInt(since / 1000);
31807
31842
  }
31808
31843
  const response = await this.publicGetTradesSymbol(this.extend(request, params));
31844
+ //
31845
+ // [
31846
+ // {
31847
+ // "timestamp": "1694284565",
31848
+ // "tid": "1415415034",
31849
+ // "price": "25862.0",
31850
+ // "amount": "0.00020685",
31851
+ // "exchange": "bitfinex",
31852
+ // "type": "buy"
31853
+ // },
31854
+ // ]
31855
+ //
31809
31856
  return this.parseTrades(response, market, since, limit);
31810
31857
  }
31811
31858
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -35798,7 +35845,7 @@ class bitflyer extends _abstract_bitflyer_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
35798
35845
  //
35799
35846
  // fetchTrades (public) v1
35800
35847
  //
35801
- // {
35848
+ // {
35802
35849
  // "id":2278466664,
35803
35850
  // "side":"SELL",
35804
35851
  // "price":56810.7,
@@ -35808,16 +35855,18 @@ class bitflyer extends _abstract_bitflyer_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
35808
35855
  // "sell_child_order_acceptance_id":"JRF20211119-114639-236919"
35809
35856
  // }
35810
35857
  //
35811
- // {
35812
- // "id":2278463423,
35813
- // "side":"BUY",
35814
- // "price":56757.83,
35815
- // "size":0.6003,"exec_date":"2021-11-19T11:28:00.523",
35816
- // "buy_child_order_acceptance_id":"JRF20211119-112800-236526",
35817
- // "sell_child_order_acceptance_id":"JRF20211119-112734-062017"
35818
- // }
35819
- //
35858
+ // fetchMyTrades
35820
35859
  //
35860
+ // {
35861
+ // "id": 37233,
35862
+ // "side": "BUY",
35863
+ // "price": 33470,
35864
+ // "size": 0.01,
35865
+ // "exec_date": "2015-07-07T09:57:40.397",
35866
+ // "child_order_id": "JOR20150707-060559-021935",
35867
+ // "child_order_acceptance_id": "JRF20150707-060559-396699"
35868
+ // "commission": 0,
35869
+ // },
35821
35870
  //
35822
35871
  let side = this.safeStringLower(trade, 'side');
35823
35872
  if (side !== undefined) {
@@ -35876,6 +35925,19 @@ class bitflyer extends _abstract_bitflyer_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
35876
35925
  request['count'] = limit;
35877
35926
  }
35878
35927
  const response = await this.publicGetGetexecutions(this.extend(request, params));
35928
+ //
35929
+ // [
35930
+ // {
35931
+ // "id": 39287,
35932
+ // "side": "BUY",
35933
+ // "price": 31690,
35934
+ // "size": 27.04,
35935
+ // "exec_date": "2015-07-08T02:43:34.823",
35936
+ // "buy_child_order_acceptance_id": "JRF20150707-200203-452209",
35937
+ // "sell_child_order_acceptance_id": "JRF20150708-024334-060234"
35938
+ // },
35939
+ // ]
35940
+ //
35879
35941
  return this.parseTrades(response, market, since, limit);
35880
35942
  }
35881
35943
  async fetchTradingFee(symbol, params = {}) {
@@ -36112,6 +36174,20 @@ class bitflyer extends _abstract_bitflyer_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
36112
36174
  request['count'] = limit;
36113
36175
  }
36114
36176
  const response = await this.privateGetGetexecutions(this.extend(request, params));
36177
+ //
36178
+ // [
36179
+ // {
36180
+ // "id": 37233,
36181
+ // "side": "BUY",
36182
+ // "price": 33470,
36183
+ // "size": 0.01,
36184
+ // "exec_date": "2015-07-07T09:57:40.397",
36185
+ // "child_order_id": "JOR20150707-060559-021935",
36186
+ // "child_order_acceptance_id": "JRF20150707-060559-396699"
36187
+ // "commission": 0,
36188
+ // },
36189
+ // ]
36190
+ //
36115
36191
  return this.parseTrades(response, market, since, limit);
36116
36192
  }
36117
36193
  async fetchPositions(symbols = undefined, params = {}) {
@@ -36644,14 +36720,6 @@ class bitforex extends _abstract_bitforex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
36644
36720
  // "tid":"1131019666"
36645
36721
  // }
36646
36722
  //
36647
- // {
36648
- // "price":57591.33,
36649
- // "amount":0.002,
36650
- // "time":1637329685322,
36651
- // "direction":1,
36652
- // "tid":"1131019639"
36653
- // }
36654
- //
36655
36723
  // fetchMyTrades (private)
36656
36724
  //
36657
36725
  // {
@@ -39379,7 +39447,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
39379
39447
  // "fillTime": "1692073691000"
39380
39448
  // }
39381
39449
  //
39382
- // swap
39450
+ // swap (public trades)
39383
39451
  //
39384
39452
  // {
39385
39453
  // "tradeId": "1075199767891652609",
@@ -39511,6 +39579,16 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
39511
39579
  params = this.omit(params, 'method');
39512
39580
  if (swapMethod === 'publicMixGetMarketFillsHistory') {
39513
39581
  response = await this.publicMixGetMarketFillsHistory(this.extend(request, params));
39582
+ //
39583
+ // {
39584
+ // "tradeId": "1084459062491590657",
39585
+ // "price": "25874",
39586
+ // "size": "1.624",
39587
+ // "side": "Buy",
39588
+ // "timestamp": "1694281109000",
39589
+ // "symbol": "BTCUSDT_UMCBL",
39590
+ // }
39591
+ //
39514
39592
  }
39515
39593
  else if (swapMethod === 'publicMixGetMarketFills') {
39516
39594
  response = await this.publicMixGetMarketFills(this.extend(request, params));
@@ -40211,12 +40289,12 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
40211
40289
  }
40212
40290
  else if (isStopLossOrTakeProfit) {
40213
40291
  if (isStopLoss) {
40214
- const stopLossTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice');
40215
- request['presetStopLossPrice'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
40292
+ const slTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice');
40293
+ request['presetStopLossPrice'] = this.priceToPrecision(symbol, slTriggerPrice);
40216
40294
  }
40217
40295
  if (isTakeProfit) {
40218
- const takeProfitTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice');
40219
- request['presetTakeProfitPrice'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
40296
+ const tpTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice');
40297
+ request['presetTakeProfitPrice'] = this.priceToPrecision(symbol, tpTriggerPrice);
40220
40298
  }
40221
40299
  }
40222
40300
  }
@@ -59354,6 +59432,17 @@ class bitstamp1 extends _abstract_bitstamp1_js__WEBPACK_IMPORTED_MODULE_0__/* ["
59354
59432
  return this.parseTicker(ticker, market);
59355
59433
  }
59356
59434
  parseTrade(trade, market = undefined) {
59435
+ //
59436
+ // public trade
59437
+ //
59438
+ // {
59439
+ // "amount": "0.00114000",
59440
+ // "date": "1694287856",
59441
+ // "price": "25865",
59442
+ // "tid": 298730788,
59443
+ // "type": 0
59444
+ // }
59445
+ //
59357
59446
  const timestamp = this.safeTimestamp2(trade, 'date', 'datetime');
59358
59447
  const side = (trade['type'] === 0) ? 'buy' : 'sell';
59359
59448
  const orderId = this.safeString(trade, 'order_id');
@@ -59398,6 +59487,17 @@ class bitstamp1 extends _abstract_bitstamp1_js__WEBPACK_IMPORTED_MODULE_0__/* ["
59398
59487
  'time': 'minute',
59399
59488
  };
59400
59489
  const response = await this.publicGetTransactions(this.extend(request, params));
59490
+ //
59491
+ // [
59492
+ // {
59493
+ // "amount": "0.00114000",
59494
+ // "date": "1694287856",
59495
+ // "price": "25865",
59496
+ // "tid": 298730788,
59497
+ // "type": 0
59498
+ // },
59499
+ // ]
59500
+ //
59401
59501
  return this.parseTrades(response, market, since, limit);
59402
59502
  }
59403
59503
  parseBalance(response) {
@@ -65963,6 +66063,16 @@ class bl3p extends _abstract_bl3p_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
65963
66063
  return this.parseTicker(ticker, market);
65964
66064
  }
65965
66065
  parseTrade(trade, market = undefined) {
66066
+ //
66067
+ // fetchTrades
66068
+ //
66069
+ // {
66070
+ // "trade_id": "2518789",
66071
+ // "date": "1694348697745",
66072
+ // "amount_int": "2959153",
66073
+ // "price_int": "2416231440"
66074
+ // }
66075
+ //
65966
66076
  const id = this.safeString(trade, 'trade_id');
65967
66077
  const timestamp = this.safeInteger(trade, 'date');
65968
66078
  const price = this.safeString(trade, 'price_int');
@@ -65999,6 +66109,20 @@ class bl3p extends _abstract_bl3p_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
65999
66109
  const response = await this.publicGetMarketTrades(this.extend({
66000
66110
  'market': market['id'],
66001
66111
  }, params));
66112
+ //
66113
+ // {
66114
+ // "result": "success",
66115
+ // "data": {
66116
+ // "trades": [
66117
+ // {
66118
+ // "trade_id": "2518789",
66119
+ // "date": "1694348697745",
66120
+ // "amount_int": "2959153",
66121
+ // "price_int": "2416231440"
66122
+ // },
66123
+ // ]
66124
+ // }
66125
+ // }
66002
66126
  const result = this.parseTrades(response['data']['trades'], market, since, limit);
66003
66127
  return result;
66004
66128
  }
@@ -72342,7 +72466,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
72342
72466
  '110023': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
72343
72467
  '110024': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
72344
72468
  '110025': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
72345
- '110026': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
72469
+ '110026': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
72346
72470
  '110027': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
72347
72471
  '110028': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
72348
72472
  '110029': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
@@ -74017,20 +74141,14 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
74017
74141
  request['limit'] = limit; // max 1000, default 1000
74018
74142
  }
74019
74143
  request['interval'] = this.safeString(this.timeframes, timeframe, timeframe);
74020
- let method = undefined;
74144
+ let response = undefined;
74021
74145
  if (market['spot']) {
74022
74146
  request['category'] = 'spot';
74023
- method = 'publicGetV5MarketKline';
74147
+ response = await this.publicGetV5MarketKline(this.extend(request, params));
74024
74148
  }
74025
74149
  else {
74026
74150
  const price = this.safeString(params, 'price');
74027
74151
  params = this.omit(params, 'price');
74028
- const methods = {
74029
- 'mark': 'publicGetV5MarketMarkPriceKline',
74030
- 'index': 'publicGetV5MarketIndexPriceKline',
74031
- 'premiumIndex': 'publicGetV5MarketPremiumIndexPriceKline',
74032
- };
74033
- method = this.safeValue(methods, price, 'publicGetV5MarketKline');
74034
74152
  if (market['linear']) {
74035
74153
  request['category'] = 'linear';
74036
74154
  }
@@ -74040,8 +74158,19 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
74040
74158
  else {
74041
74159
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' fetchOHLCV() is not supported for option markets');
74042
74160
  }
74161
+ if (price === 'mark') {
74162
+ response = await this.publicGetV5MarketMarkPriceKline(this.extend(request, params));
74163
+ }
74164
+ else if (price === 'index') {
74165
+ response = await this.publicGetV5MarketIndexPriceKline(this.extend(request, params));
74166
+ }
74167
+ else if (price === 'premiumIndex') {
74168
+ response = await this.publicGetV5MarketPremiumIndexPriceKline(this.extend(request, params));
74169
+ }
74170
+ else {
74171
+ response = await this.publicGetV5MarketKline(this.extend(request, params));
74172
+ }
74043
74173
  }
74044
- const response = await this[method](this.extend(request, params));
74045
74174
  //
74046
74175
  // {
74047
74176
  // "retCode": 0,
@@ -75214,6 +75343,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
75214
75343
  * @param {boolean} [params.isLeverage] *unified spot only* false then spot trading true then margin trading
75215
75344
  * @param {string} [params.tpslMode] *contract only* 'full' or 'partial'
75216
75345
  * @param {string} [params.mmp] *option only* market maker protection
75346
+ * @param {int} [params.triggerDirection] *contract only* conditional orders, 1: triggered when market price rises to triggerPrice, 2: triggered when market price falls to triggerPrice
75217
75347
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
75218
75348
  */
75219
75349
  await this.loadMarkets();
@@ -75321,7 +75451,6 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
75321
75451
  const isBuy = side === 'buy';
75322
75452
  const ascending = stopLossTriggerPrice ? !isBuy : isBuy;
75323
75453
  if (triggerPrice !== undefined) {
75324
- request['triggerDirection'] = ascending ? 2 : 1;
75325
75454
  request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
75326
75455
  }
75327
75456
  else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
@@ -75467,8 +75596,13 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
75467
75596
  request['orderLinkId'] = this.uuid16();
75468
75597
  }
75469
75598
  params = this.omit(params, ['stopPrice', 'timeInForce', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId']);
75470
- const method = market['option'] ? 'privatePostOptionUsdcOpenapiPrivateV1PlaceOrder' : 'privatePostPerpetualUsdcOpenapiPrivateV1PlaceOrder';
75471
- const response = await this[method](this.extend(request, params));
75599
+ let response = undefined;
75600
+ if (market['option']) {
75601
+ response = await this.privatePostOptionUsdcOpenapiPrivateV1PlaceOrder(this.extend(request, params));
75602
+ }
75603
+ else {
75604
+ response = await this.privatePostPerpetualUsdcOpenapiPrivateV1PlaceOrder(this.extend(request, params));
75605
+ }
75472
75606
  //
75473
75607
  // {
75474
75608
  // "retCode":0,
@@ -75510,12 +75644,11 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
75510
75644
  if (price !== undefined) {
75511
75645
  request['orderPrice'] = this.priceToPrecision(symbol, price);
75512
75646
  }
75513
- let method = undefined;
75647
+ let response = undefined;
75514
75648
  if (market['option']) {
75515
- method = 'privatePostOptionUsdcOpenapiPrivateV1ReplaceOrder';
75649
+ response = await this.privatePostOptionUsdcOpenapiPrivateV1ReplaceOrder(this.extend(request, params));
75516
75650
  }
75517
75651
  else {
75518
- method = 'privatePostPerpetualUsdcOpenapiPrivateV1ReplaceOrder';
75519
75652
  const isStop = this.safeValue(params, 'stop', false);
75520
75653
  const triggerPrice = this.safeValue2(params, 'stopPrice', 'triggerPrice');
75521
75654
  const stopLossPrice = this.safeValue(params, 'stopLossPrice');
@@ -75536,8 +75669,8 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
75536
75669
  }
75537
75670
  }
75538
75671
  params = this.omit(params, ['stop', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']);
75672
+ response = await this.privatePostPerpetualUsdcOpenapiPrivateV1ReplaceOrder(this.extend(request, params));
75539
75673
  }
75540
- const response = await this[method](this.extend(request, params));
75541
75674
  //
75542
75675
  // {
75543
75676
  // "retCode": 0,
@@ -75671,18 +75804,17 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
75671
75804
  };
75672
75805
  const isStop = this.safeValue(params, 'stop', false);
75673
75806
  params = this.omit(params, ['stop']);
75674
- let method = undefined;
75675
75807
  if (id !== undefined) { // The user can also use argument params["order_link_id"]
75676
75808
  request['orderId'] = id;
75677
75809
  }
75810
+ let response = undefined;
75678
75811
  if (market['option']) {
75679
- method = 'privatePostOptionUsdcOpenapiPrivateV1CancelOrder';
75812
+ response = await this.privatePostOptionUsdcOpenapiPrivateV1CancelOrder(this.extend(request, params));
75680
75813
  }
75681
75814
  else {
75682
- method = 'privatePostPerpetualUsdcOpenapiPrivateV1CancelOrder';
75683
75815
  request['orderFilter'] = isStop ? 'StopOrder' : 'Order';
75816
+ response = await this.privatePostPerpetualUsdcOpenapiPrivateV1CancelOrder(this.extend(request, params));
75684
75817
  }
75685
- const response = await this[method](this.extend(request, params));
75686
75818
  //
75687
75819
  // {
75688
75820
  // "retCode": 0,
@@ -76855,7 +76987,6 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
76855
76987
  request['start_date'] = this.yyyymmdd(since);
76856
76988
  }
76857
76989
  }
76858
- const method = (enableUnified[1]) ? 'privateGetV5AccountTransactionLog' : 'privateGetV2PrivateWalletFundRecords';
76859
76990
  if (code !== undefined) {
76860
76991
  currency = this.currency(code);
76861
76992
  request[currencyKey] = currency['id'];
@@ -76863,7 +76994,13 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
76863
76994
  if (limit !== undefined) {
76864
76995
  request['limit'] = limit;
76865
76996
  }
76866
- const response = await this[method](this.extend(request, params));
76997
+ let response = undefined;
76998
+ if (enableUnified[1]) {
76999
+ response = await this.privateGetV5AccountTransactionLog(this.extend(request, params));
77000
+ }
77001
+ else {
77002
+ response = await this.privateGetV2PrivateWalletFundRecords(this.extend(request, params));
77003
+ }
76867
77004
  //
76868
77005
  // {
76869
77006
  // "ret_code": 0,
@@ -77584,21 +77721,83 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
77584
77721
  });
77585
77722
  }
77586
77723
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
77724
+ /**
77725
+ * @method
77726
+ * @name bybit#setMarginMode
77727
+ * @description set margin mode (account) or trade mode (symbol)
77728
+ * @see https://bybit-exchange.github.io/docs/v5/account/set-margin-mode
77729
+ * @see https://bybit-exchange.github.io/docs/v5/position/cross-isolate
77730
+ * @param {string} marginMode account mode must be either [isolated, cross, portfolio], trade mode must be either [isolated, cross]
77731
+ * @param {string} symbol unified market symbol of the market the position is held in, default is undefined
77732
+ * @param {object} [params] extra parameters specific to the bybit api endpoint
77733
+ * @param {string} [params.leverage] the rate of leverage, is required if setting trade mode (symbol)
77734
+ * @returns {object} response from the exchange
77735
+ */
77587
77736
  await this.loadMarkets();
77588
77737
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
77589
77738
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
77590
- if (marginMode === 'ISOLATED_MARGIN') {
77591
- if (!isUnifiedAccount) {
77592
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' setMarginMode() Normal Account not support ISOLATED_MARGIN');
77739
+ let response = undefined;
77740
+ if (symbol === undefined) {
77741
+ if (marginMode === 'isolated') {
77742
+ if (!isUnifiedAccount) {
77743
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' setMarginMode() Normal Account not support ISOLATED_MARGIN');
77744
+ }
77745
+ marginMode = 'ISOLATED_MARGIN';
77746
+ }
77747
+ else if (marginMode === 'cross') {
77748
+ marginMode = 'REGULAR_MARGIN';
77593
77749
  }
77750
+ else if (marginMode === 'portfolio') {
77751
+ marginMode = 'PORTFOLIO_MARGIN';
77752
+ }
77753
+ else {
77754
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' setMarginMode() marginMode must be either [isolated, cross, portfolio]');
77755
+ }
77756
+ const request = {
77757
+ 'setMarginMode': marginMode,
77758
+ };
77759
+ response = await this.privatePostV5AccountSetMarginMode(this.extend(request, params));
77594
77760
  }
77595
- else if ((marginMode !== 'REGULAR_MARGIN') && (marginMode !== 'PORTFOLIO_MARGIN')) {
77596
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' setMarginMode() marginMode must be either ISOLATED_MARGIN or REGULAR_MARGIN or PORTFOLIO_MARGIN');
77761
+ else {
77762
+ const market = this.market(symbol);
77763
+ let type = undefined;
77764
+ [type, params] = this.getBybitType('setMarginMode', market, params);
77765
+ if (type === 'linear') {
77766
+ if (isUnifiedAccount) {
77767
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' setMarginMode() with symbol Unified Account only support inverse contract');
77768
+ }
77769
+ const isUsdtSettled = market['settle'] === 'USDT';
77770
+ if (!isUsdtSettled) {
77771
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' setMarginMode() with symbol only support USDT perpetual / inverse contract');
77772
+ }
77773
+ }
77774
+ else if (type !== 'inverse') {
77775
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' setMarginMode() does not support this market type');
77776
+ }
77777
+ let tradeMode = undefined;
77778
+ if (marginMode === 'cross') {
77779
+ tradeMode = 0;
77780
+ }
77781
+ else if (marginMode === 'isolated') {
77782
+ tradeMode = 1;
77783
+ }
77784
+ else {
77785
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' setMarginMode() with symbol marginMode must be either [isolated, cross]');
77786
+ }
77787
+ const leverage = this.safeString(params, 'leverage');
77788
+ params = this.omit(params, ['leverage']);
77789
+ if (leverage === undefined) {
77790
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' setMarginMode() with symbol requires leverage');
77791
+ }
77792
+ const request = {
77793
+ 'category': type,
77794
+ 'symbol': market['id'],
77795
+ 'tradeMode': tradeMode,
77796
+ 'buyLeverage': leverage,
77797
+ 'sellLeverage': leverage,
77798
+ };
77799
+ response = await this.privatePostV5PositionSwitchIsolated(this.extend(request, params));
77597
77800
  }
77598
- const request = {
77599
- 'setMarginMode': marginMode,
77600
- };
77601
- const response = await this.privatePostV5AccountSetMarginMode(this.extend(request, params));
77602
77801
  return response;
77603
77802
  }
77604
77803
  async setLeverage(leverage, symbol = undefined, params = {}) {
@@ -77630,15 +77829,14 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
77630
77829
  'buyLeverage': leverage,
77631
77830
  'sellLeverage': leverage,
77632
77831
  };
77633
- let method = undefined;
77832
+ let response = undefined;
77634
77833
  if (isUsdcSettled && !isUnifiedAccount) {
77635
77834
  request['leverage'] = leverage;
77636
- method = 'privatePostPerpetualUsdcOpenapiPrivateV1PositionLeverageSave';
77835
+ response = await this.privatePostPerpetualUsdcOpenapiPrivateV1PositionLeverageSave(this.extend(request, params));
77637
77836
  }
77638
77837
  else {
77639
77838
  request['buyLeverage'] = leverage;
77640
77839
  request['sellLeverage'] = leverage;
77641
- method = 'privatePostV5PositionSetLeverage';
77642
77840
  if (market['linear']) {
77643
77841
  request['category'] = 'linear';
77644
77842
  }
@@ -77648,8 +77846,9 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
77648
77846
  else {
77649
77847
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' setLeverage() only support linear and inverse market');
77650
77848
  }
77849
+ response = await this.privatePostV5PositionSetLeverage(this.extend(request, params));
77651
77850
  }
77652
- return await this[method](this.extend(request, params));
77851
+ return response;
77653
77852
  }
77654
77853
  async setPositionMode(hedged, symbol = undefined, params = {}) {
77655
77854
  /**
@@ -84360,6 +84559,17 @@ class coinbasepro extends _abstract_coinbasepro_js__WEBPACK_IMPORTED_MODULE_0__/
84360
84559
  request['limit'] = limit; // default 100
84361
84560
  }
84362
84561
  const response = await this.publicGetProductsIdTrades(this.extend(request, params));
84562
+ //
84563
+ // [
84564
+ // {
84565
+ // "trade_id": "15035219",
84566
+ // "side": "sell",
84567
+ // "size": "0.27426731",
84568
+ // "price": "25820.42000000",
84569
+ // "time": "2023-09-10T13:47:41.447577Z"
84570
+ // },
84571
+ // ]
84572
+ //
84363
84573
  return this.parseTrades(response, market, since, limit);
84364
84574
  }
84365
84575
  async fetchTradingFees(params = {}) {
@@ -100552,7 +100762,7 @@ class currencycom extends _abstract_currencycom_js__WEBPACK_IMPORTED_MODULE_0__/
100552
100762
  // 'limit': 500, // default 500, max 1000
100553
100763
  };
100554
100764
  if (limit !== undefined) {
100555
- request['limit'] = limit; // default 500, max 1000
100765
+ request['limit'] = Math.min(limit, 1000); // default 500, max 1000
100556
100766
  }
100557
100767
  if (since !== undefined) {
100558
100768
  request['startTime'] = since;
@@ -107103,12 +107313,12 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
107103
107313
  const result = [];
107104
107314
  for (let i = 0; i < volatilityResult.length; i++) {
107105
107315
  const timestamp = this.safeInteger(volatilityResult[i], 0);
107106
- const volatility = this.safeNumber(volatilityResult[i], 1);
107316
+ const volatilityObj = this.safeNumber(volatilityResult[i], 1);
107107
107317
  result.push({
107108
- 'info': volatility,
107318
+ 'info': volatilityObj,
107109
107319
  'timestamp': timestamp,
107110
107320
  'datetime': this.iso8601(timestamp),
107111
- 'volatility': volatility,
107321
+ 'volatility': volatilityObj,
107112
107322
  });
107113
107323
  }
107114
107324
  return result;
@@ -129534,7 +129744,7 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
129534
129744
  }
129535
129745
  request[fieldName] = market['id'];
129536
129746
  if (limit !== undefined) {
129537
- request['size'] = limit; // max 2000
129747
+ request['size'] = Math.min(limit, 2000); // max 2000
129538
129748
  }
129539
129749
  const response = await this[method](this.extend(request, params));
129540
129750
  //
@@ -136031,7 +136241,7 @@ class huobijp extends _abstract_huobijp_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
136031
136241
  'symbol': market['id'],
136032
136242
  };
136033
136243
  if (limit !== undefined) {
136034
- request['size'] = limit;
136244
+ request['size'] = Math.min(limit, 2000);
136035
136245
  }
136036
136246
  const response = await this.marketGetHistoryTrade(this.extend(request, params));
136037
136247
  //
@@ -137596,7 +137806,7 @@ class idex extends _abstract_idex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
137596
137806
  request['start'] = since;
137597
137807
  }
137598
137808
  if (limit !== undefined) {
137599
- request['limit'] = limit;
137809
+ request['limit'] = Math.min(limit, 1000);
137600
137810
  }
137601
137811
  // [
137602
137812
  // {
@@ -150523,58 +150733,53 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
150523
150733
  const request = {
150524
150734
  'symbol': market['id'],
150525
150735
  };
150526
- const response = await this.futuresPrivateGetPositions(this.extend(request, params));
150736
+ const response = await this.futuresPrivateGetPosition(this.extend(request, params));
150527
150737
  //
150528
- // {
150529
- // "code": "200000",
150530
- // "data": [
150531
- // {
150532
- // "id": "63b3599e6c41f50001c47d44",
150533
- // "symbol": "XBTUSDTM",
150534
- // "autoDeposit": false,
150535
- // "maintMarginReq": 0.004,
150536
- // "riskLimit": 25000,
150537
- // "realLeverage": 5.0,
150538
- // "crossMode": false,
150539
- // "delevPercentage": 0.57,
150540
- // "openingTimestamp": 1684000025528,
150541
- // "currentTimestamp": 1684000052160,
150542
- // "currentQty": 1,
150543
- // "currentCost": 26.821,
150544
- // "currentComm": 0.0160926,
150545
- // "unrealisedCost": 26.821,
150546
- // "realisedGrossCost": 0.0,
150547
- // "realisedCost": 0.0160926,
150548
- // "isOpen": true,
150549
- // "markPrice": 26821.13,
150550
- // "markValue": 26.82113,
150551
- // "posCost": 26.821,
150552
- // "posCross": 0.0,
150553
- // "posCrossMargin": 0.0,
150554
- // "posInit": 5.3642,
150555
- // "posComm": 0.01931112,
150556
- // "posCommCommon": 0.01931112,
150557
- // "posLoss": 0.0,
150558
- // "posMargin": 5.38351112,
150559
- // "posMaint": 0.12927722,
150560
- // "maintMargin": 5.38364112,
150561
- // "realisedGrossPnl": 0.0,
150562
- // "realisedPnl": -0.0160926,
150563
- // "unrealisedPnl": 1.3E-4,
150564
- // "unrealisedPnlPcnt": 0.0,
150565
- // "unrealisedRoePcnt": 0.0,
150566
- // "avgEntryPrice": 26821.0,
150567
- // "liquidationPrice": 21567.0,
150568
- // "bankruptPrice": 21456.0,
150569
- // "settleCurrency": "USDT",
150570
- // "isInverse": false,
150571
- // "maintainMargin": 0.004
150572
- // }
150573
- // ]
150574
- // }
150738
+ // {
150739
+ // "code": "200000",
150740
+ // "data": {
150741
+ // "id": "6505ee6eaff4070001f651c4",
150742
+ // "symbol": "XBTUSDTM",
150743
+ // "autoDeposit": false,
150744
+ // "maintMarginReq": 0,
150745
+ // "riskLimit": 200,
150746
+ // "realLeverage": 0.0,
150747
+ // "crossMode": false,
150748
+ // "delevPercentage": 0.0,
150749
+ // "currentTimestamp": 1694887534594,
150750
+ // "currentQty": 0,
150751
+ // "currentCost": 0.0,
150752
+ // "currentComm": 0.0,
150753
+ // "unrealisedCost": 0.0,
150754
+ // "realisedGrossCost": 0.0,
150755
+ // "realisedCost": 0.0,
150756
+ // "isOpen": false,
150757
+ // "markPrice": 26611.71,
150758
+ // "markValue": 0.0,
150759
+ // "posCost": 0.0,
150760
+ // "posCross": 0,
150761
+ // "posInit": 0.0,
150762
+ // "posComm": 0.0,
150763
+ // "posLoss": 0.0,
150764
+ // "posMargin": 0.0,
150765
+ // "posMaint": 0.0,
150766
+ // "maintMargin": 0.0,
150767
+ // "realisedGrossPnl": 0.0,
150768
+ // "realisedPnl": 0.0,
150769
+ // "unrealisedPnl": 0.0,
150770
+ // "unrealisedPnlPcnt": 0,
150771
+ // "unrealisedRoePcnt": 0,
150772
+ // "avgEntryPrice": 0.0,
150773
+ // "liquidationPrice": 0.0,
150774
+ // "bankruptPrice": 0.0,
150775
+ // "settleCurrency": "USDT",
150776
+ // "maintainMargin": 0,
150777
+ // "riskLimitLevel": 1
150778
+ // }
150779
+ // }
150575
150780
  //
150576
- const data = this.safeValue(response, 'data', []);
150577
- return this.parsePosition(data[0], market);
150781
+ const data = this.safeValue(response, 'data', {});
150782
+ return this.parsePosition(data, market);
150578
150783
  }
150579
150784
  async fetchPositions(symbols = undefined, params = {}) {
150580
150785
  /**
@@ -150720,7 +150925,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
150720
150925
  'unrealizedPnl': this.parseNumber(unrealisedPnl),
150721
150926
  'contracts': this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringAbs */ .O.stringAbs(size)),
150722
150927
  'contractSize': this.safeValue(market, 'contractSize'),
150723
- 'realizedPnl': this.safeNumber(position, 'realised_pnl'),
150928
+ 'realizedPnl': this.safeNumber(position, 'realisedPnl'),
150724
150929
  'marginRatio': undefined,
150725
150930
  'liquidationPrice': this.safeNumber(position, 'liquidationPrice'),
150726
150931
  'markPrice': this.safeNumber(position, 'markPrice'),
@@ -154993,7 +155198,7 @@ class lbank extends _abstract_lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
154993
155198
  request['time'] = since;
154994
155199
  }
154995
155200
  if (limit !== undefined) {
154996
- request['size'] = limit;
155201
+ request['size'] = Math.min(limit, 600);
154997
155202
  }
154998
155203
  const response = await this.publicGetTrades(this.extend(request, params));
154999
155204
  return this.parseTrades(response, market, since, limit);
@@ -156080,8 +156285,8 @@ class lbank2 extends _abstract_lbank2_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
156080
156285
  await this.loadMarkets();
156081
156286
  const market = this.market(symbol);
156082
156287
  if (market['swap']) {
156083
- const response = await this.fetchTickers([market['symbol']], params);
156084
- return this.safeValue(response, market['symbol']);
156288
+ const responseForSwap = await this.fetchTickers([market['symbol']], params);
156289
+ return this.safeValue(responseForSwap, market['symbol']);
156085
156290
  }
156086
156291
  const request = {
156087
156292
  'symbol': market['id'],
@@ -156403,7 +156608,7 @@ class lbank2 extends _abstract_lbank2_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
156403
156608
  request['time'] = since;
156404
156609
  }
156405
156610
  if (limit !== undefined) {
156406
- request['size'] = limit;
156611
+ request['size'] = Math.min(limit, 600);
156407
156612
  }
156408
156613
  else {
156409
156614
  request['size'] = 600; // max
@@ -177164,13 +177369,13 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
177164
177369
  promises.push(this.publicGetPublicInstruments(this.extend(request, params)));
177165
177370
  }
177166
177371
  const promisesResult = await Promise.all(promises);
177167
- let data = [];
177372
+ let markets = [];
177168
177373
  for (let i = 0; i < promisesResult.length; i++) {
177169
177374
  const res = this.safeValue(promisesResult, i, {});
177170
177375
  const options = this.safeValue(res, 'data', []);
177171
- data = this.arrayConcat(data, options);
177376
+ markets = this.arrayConcat(markets, options);
177172
177377
  }
177173
- return this.parseMarkets(data);
177378
+ return this.parseMarkets(markets);
177174
177379
  }
177175
177380
  const response = await this.publicGetPublicInstruments(this.extend(request, params));
177176
177381
  //
@@ -182429,8 +182634,8 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
182429
182634
  const entry = settlements[i];
182430
182635
  const timestamp = this.safeInteger(entry, 'ts');
182431
182636
  const details = this.safeValue(entry, 'details', []);
182432
- for (let i = 0; i < details.length; i++) {
182433
- const settlement = this.parseSettlement(details[i], market);
182637
+ for (let j = 0; j < details.length; j++) {
182638
+ const settlement = this.parseSettlement(details[j], market);
182434
182639
  result.push(this.extend(settlement, {
182435
182640
  'timestamp': timestamp,
182436
182641
  'datetime': this.iso8601(timestamp),
@@ -192623,8 +192828,8 @@ class ascendex extends _ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
192623
192828
  // unroll the accumulated deltas
192624
192829
  const messages = orderbook.cache;
192625
192830
  for (let i = 0; i < messages.length; i++) {
192626
- const message = messages[i];
192627
- this.handleOrderBookMessage(client, message, orderbook);
192831
+ const messageItem = messages[i];
192832
+ this.handleOrderBookMessage(client, messageItem, orderbook);
192628
192833
  }
192629
192834
  this.orderbooks[symbol] = orderbook;
192630
192835
  client.resolve(orderbook, messageHash);
@@ -193653,10 +193858,10 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
193653
193858
  // unroll the accumulated deltas
193654
193859
  const messages = orderbook.cache;
193655
193860
  for (let i = 0; i < messages.length; i++) {
193656
- const message = messages[i];
193657
- const U = this.safeInteger(message, 'U');
193658
- const u = this.safeInteger(message, 'u');
193659
- const pu = this.safeInteger(message, 'pu');
193861
+ const messageItem = messages[i];
193862
+ const U = this.safeInteger(messageItem, 'U');
193863
+ const u = this.safeInteger(messageItem, 'u');
193864
+ const pu = this.safeInteger(messageItem, 'pu');
193660
193865
  if (type === 'future') {
193661
193866
  // 4. Drop any event where u is < lastUpdateId in the snapshot
193662
193867
  if (u < orderbook['nonce']) {
@@ -193664,7 +193869,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
193664
193869
  }
193665
193870
  // 5. The first processed event should have U <= lastUpdateId AND u >= lastUpdateId
193666
193871
  if ((U <= orderbook['nonce']) && (u >= orderbook['nonce']) || (pu === orderbook['nonce'])) {
193667
- this.handleOrderBookMessage(client, message, orderbook);
193872
+ this.handleOrderBookMessage(client, messageItem, orderbook);
193668
193873
  }
193669
193874
  }
193670
193875
  else {
@@ -193674,7 +193879,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
193674
193879
  }
193675
193880
  // 5. The first processed event should have U <= lastUpdateId+1 AND u >= lastUpdateId+1
193676
193881
  if (((U - 1) <= orderbook['nonce']) && ((u - 1) >= orderbook['nonce'])) {
193677
- this.handleOrderBookMessage(client, message, orderbook);
193882
+ this.handleOrderBookMessage(client, messageItem, orderbook);
193678
193883
  }
193679
193884
  }
193680
193885
  }
@@ -193815,8 +194020,8 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
193815
194020
  handleOrderBookSubscription(client, message, subscription) {
193816
194021
  const defaultLimit = this.safeInteger(this.options, 'watchOrderBookLimit', 1000);
193817
194022
  // const messageHash = this.safeString (subscription, 'messageHash');
193818
- const symbol = this.safeString(subscription, 'symbol'); // watchOrderBook
193819
- const symbols = this.safeValue(subscription, 'symbols', [symbol]); // watchOrderBookForSymbols
194023
+ const symbolOfSubscription = this.safeString(subscription, 'symbol'); // watchOrderBook
194024
+ const symbols = this.safeValue(subscription, 'symbols', [symbolOfSubscription]); // watchOrderBookForSymbols
193820
194025
  const limit = this.safeInteger(subscription, 'limit', defaultLimit);
193821
194026
  // handle list of symbols
193822
194027
  for (let i = 0; i < symbols.length; i++) {
@@ -194523,12 +194728,12 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
194523
194728
  client.resolve(result, '!' + 'bookTicker@arr');
194524
194729
  const messageHashes = this.findMessageHashes(client, 'tickers::');
194525
194730
  for (let i = 0; i < messageHashes.length; i++) {
194526
- const messageHash = messageHashes[i];
194527
- const parts = messageHash.split('::');
194731
+ const currentMessageHash = messageHashes[i];
194732
+ const parts = currentMessageHash.split('::');
194528
194733
  const symbolsString = parts[1];
194529
194734
  const symbols = symbolsString.split(',');
194530
194735
  if (this.inArray(symbol, symbols)) {
194531
- client.resolve(result, messageHash);
194736
+ client.resolve(result, currentMessageHash);
194532
194737
  }
194533
194738
  }
194534
194739
  }
@@ -197434,9 +197639,9 @@ class bitfinex2 extends _bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
197434
197639
  const size = (delta[2] < 0) ? -delta[2] : delta[2];
197435
197640
  const side = (delta[2] < 0) ? 'asks' : 'bids';
197436
197641
  const bookside = orderbook[side];
197437
- const id = this.safeString(delta, 0);
197642
+ const idString = this.safeString(delta, 0);
197438
197643
  const price = this.safeFloat(delta, 1);
197439
- bookside.store(price, size, id);
197644
+ bookside.store(price, size, idString);
197440
197645
  }
197441
197646
  }
197442
197647
  else {
@@ -197456,12 +197661,12 @@ class bitfinex2 extends _bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
197456
197661
  }
197457
197662
  else {
197458
197663
  const deltas = message[1];
197459
- const orderbook = this.orderbooks[symbol];
197664
+ const orderbookItem = this.orderbooks[symbol];
197460
197665
  if (isRaw) {
197461
197666
  const price = this.safeString(deltas, 1);
197462
197667
  const size = (deltas[2] < 0) ? -deltas[2] : deltas[2];
197463
197668
  const side = (deltas[2] < 0) ? 'asks' : 'bids';
197464
- const bookside = orderbook[side];
197669
+ const bookside = orderbookItem[side];
197465
197670
  // price = 0 means that you have to remove the order from your book
197466
197671
  const amount = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringGt */ .O.stringGt(price, '0') ? size : '0';
197467
197672
  bookside.store(this.parseNumber(price), this.parseNumber(amount), id);
@@ -197472,7 +197677,7 @@ class bitfinex2 extends _bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
197472
197677
  const price = this.safeString(deltas, 0);
197473
197678
  const size = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringLt */ .O.stringLt(amount, '0') ? _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringNeg */ .O.stringNeg(amount) : amount;
197474
197679
  const side = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringLt */ .O.stringLt(amount, '0') ? 'asks' : 'bids';
197475
- const bookside = orderbook[side];
197680
+ const bookside = orderbookItem[side];
197476
197681
  bookside.store(this.parseNumber(price), this.parseNumber(size), this.parseNumber(counter));
197477
197682
  }
197478
197683
  client.resolve(orderbook, messageHash);
@@ -198297,10 +198502,10 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
198297
198502
  const hashes = [];
198298
198503
  for (let i = 0; i < symbolsAndTimeframes.length; i++) {
198299
198504
  const data = symbolsAndTimeframes[i];
198300
- const symbol = this.safeString(data, 0);
198301
- const timeframe = this.safeString(data, 1);
198302
- const market = this.market(symbol);
198303
- const interval = this.safeString(this.options['timeframes'], timeframe);
198505
+ const currentSymbol = this.safeString(data, 0);
198506
+ const currentTimeframe = this.safeString(data, 1);
198507
+ const market = this.market(currentSymbol);
198508
+ const interval = this.safeString(this.options['timeframes'], currentTimeframe);
198304
198509
  const instType = market['spot'] ? 'sp' : 'mc';
198305
198510
  const args = {
198306
198511
  'instType': instType,
@@ -198308,7 +198513,7 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
198308
198513
  'instId': this.getWsMarketId(market),
198309
198514
  };
198310
198515
  topics.push(args);
198311
- hashes.push(symbol + '#' + timeframe);
198516
+ hashes.push(currentSymbol + '#' + currentSymbol);
198312
198517
  }
198313
198518
  const messageHash = 'multipleOHLCV::' + hashes.join(',');
198314
198519
  const [symbol, timeframe, stored] = await this.watchPublicMultiple(messageHash, topics, params);
@@ -201039,8 +201244,8 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
201039
201244
  for (let i = 0; i < symbols.length; i++) {
201040
201245
  const symbol = symbols[i];
201041
201246
  const market = this.market(symbol);
201042
- const messageHash = table + ':' + market['id'];
201043
- topics.push(messageHash);
201247
+ const currentMessageHash = table + ':' + market['id'];
201248
+ topics.push(currentMessageHash);
201044
201249
  }
201045
201250
  const messageHash = 'multipleOrderbook::' + symbols.join(',');
201046
201251
  const url = this.urls['api']['ws'];
@@ -204821,8 +205026,8 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
204821
205026
  // unroll the accumulated deltas
204822
205027
  // 3. Playback the cached Level 2 data flow.
204823
205028
  for (let i = 0; i < messages.length; i++) {
204824
- const message = messages[i];
204825
- this.handleOrderBookMessage(client, message, orderbook);
205029
+ const messageItem = messages[i];
205030
+ this.handleOrderBookMessage(client, messageItem, orderbook);
204826
205031
  }
204827
205032
  this.orderbooks[symbol] = orderbook;
204828
205033
  client.resolve(orderbook, messageHash);
@@ -205445,8 +205650,8 @@ class bitvavo extends _bitvavo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
205445
205650
  // unroll the accumulated deltas
205446
205651
  const messages = orderbook.cache;
205447
205652
  for (let i = 0; i < messages.length; i++) {
205448
- const message = messages[i];
205449
- this.handleOrderBookMessage(client, message, orderbook);
205653
+ const messageItem = messages[i];
205654
+ this.handleOrderBookMessage(client, messageItem, orderbook);
205450
205655
  }
205451
205656
  this.orderbooks[symbol] = orderbook;
205452
205657
  client.resolve(orderbook, messageHash);
@@ -207125,8 +207330,8 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
207125
207330
  const topics = [];
207126
207331
  for (let i = 0; i < symbols.length; i++) {
207127
207332
  const symbol = symbols[i];
207128
- const market = this.market(symbol);
207129
- const topic = 'orderbook.' + limit.toString() + '.' + market['id'];
207333
+ const currentMarket = this.market(symbol);
207334
+ const topic = 'orderbook.' + limit.toString() + '.' + currentMarket['id'];
207130
207335
  topics.push(topic);
207131
207336
  }
207132
207337
  const messageHash = 'multipleOrderbook::' + symbols.join(',');
@@ -209870,12 +210075,11 @@ class coinbase extends _coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
209870
210075
  this.trades[symbol] = tradesArray;
209871
210076
  }
209872
210077
  for (let i = 0; i < events.length; i++) {
209873
- const event = events[i];
209874
- const trades = this.safeValue(event, 'trades');
209875
- for (let i = 0; i < trades.length; i++) {
209876
- const item = trades[i];
209877
- const trade = this.parseTrade(item);
209878
- tradesArray.append(trade);
210078
+ const currentEvent = events[i];
210079
+ const currentTrades = this.safeValue(currentEvent, 'trades');
210080
+ for (let j = 0; j < currentTrades.length; j++) {
210081
+ const item = currentTrades[i];
210082
+ tradesArray.append(this.parseTrade(item));
209879
210083
  }
209880
210084
  }
209881
210085
  client.resolve(tradesArray, messageHash);
@@ -212264,8 +212468,8 @@ class cryptocom extends _cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
212264
212468
  for (let i = 0; i < symbols.length; i++) {
212265
212469
  const symbol = symbols[i];
212266
212470
  const market = this.market(symbol);
212267
- const messageHash = 'book' + '.' + market['id'];
212268
- topics.push(messageHash);
212471
+ const currentMessageHash = 'book' + '.' + market['id'];
212472
+ topics.push(currentMessageHash);
212269
212473
  }
212270
212474
  const messageHash = 'multipleOrderbooks::' + symbols.join(',');
212271
212475
  const orderbook = await this.watchPublicMultiple(messageHash, topics, params);
@@ -212352,8 +212556,8 @@ class cryptocom extends _cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
212352
212556
  for (let i = 0; i < symbols.length; i++) {
212353
212557
  const symbol = symbols[i];
212354
212558
  const market = this.market(symbol);
212355
- const messageHash = 'trade' + '.' + market['id'];
212356
- topics.push(messageHash);
212559
+ const currentMessageHash = 'trade' + '.' + market['id'];
212560
+ topics.push(currentMessageHash);
212357
212561
  }
212358
212562
  const messageHash = 'multipleTrades::' + symbols.join(',');
212359
212563
  const trades = await this.watchPublicMultiple(messageHash, topics, params);
@@ -213525,13 +213729,13 @@ class currencycom extends _currencycom_js__WEBPACK_IMPORTED_MODULE_0__/* ["defau
213525
213729
  const subscription = this.safeValue(subscriptionsById, requestId);
213526
213730
  if (subscription !== undefined) {
213527
213731
  if (status === 'OK') {
213528
- const destination = this.safeString(subscription, 'destination');
213529
- if (destination !== undefined) {
213732
+ const subscriptionDestination = this.safeString(subscription, 'destination');
213733
+ if (subscriptionDestination !== undefined) {
213530
213734
  const methods = {
213531
213735
  '/api/v1/ticker/24hr': this.handleTicker,
213532
213736
  '/api/v1/account': this.handleBalance,
213533
213737
  };
213534
- const method = this.safeValue(methods, destination);
213738
+ const method = this.safeValue(methods, subscriptionDestination);
213535
213739
  if (method === undefined) {
213536
213740
  return message;
213537
213741
  }
@@ -217451,8 +217655,8 @@ class hitbtc extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
217451
217655
  this.trades[symbol] = stored;
217452
217656
  }
217453
217657
  const trades = this.parseWsTrades(data[marketId], market);
217454
- for (let i = 0; i < trades.length; i++) {
217455
- stored.append(trades[i]);
217658
+ for (let j = 0; j < trades.length; j++) {
217659
+ stored.append(trades[j]);
217456
217660
  }
217457
217661
  const messageHash = 'trades::' + symbol;
217458
217662
  client.resolve(stored, messageHash);
@@ -217579,8 +217783,8 @@ class hitbtc extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
217579
217783
  this.ohlcvs[symbol][timeframe] = stored;
217580
217784
  }
217581
217785
  const ohlcvs = this.parseWsOHLCVs(data[marketId], market);
217582
- for (let i = 0; i < ohlcvs.length; i++) {
217583
- stored.append(ohlcvs[i]);
217786
+ for (let j = 0; j < ohlcvs.length; j++) {
217787
+ stored.append(ohlcvs[j]);
217584
217788
  }
217585
217789
  const messageHash = channel + '::' + symbol;
217586
217790
  client.resolve(stored, messageHash);
@@ -218975,8 +219179,7 @@ class huobi extends _huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
218975
219179
  orderbook.reset(snapshot);
218976
219180
  // unroll the accumulated deltas
218977
219181
  for (let i = 0; i < messages.length; i++) {
218978
- const message = messages[i];
218979
- this.handleOrderBookMessage(client, message, orderbook);
219182
+ this.handleOrderBookMessage(client, messages[i], orderbook);
218980
219183
  }
218981
219184
  this.orderbooks[symbol] = orderbook;
218982
219185
  client.resolve(orderbook, messageHash);
@@ -220237,14 +220440,14 @@ class huobi extends _huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
220237
220440
  const action = this.safeString(message, 'action');
220238
220441
  if (action === 'ping') {
220239
220442
  const data = this.safeValue(message, 'data');
220240
- const ping = this.safeInteger(data, 'ts');
220241
- await client.send({ 'action': 'pong', 'data': { 'ts': ping } });
220443
+ const pingTs = this.safeInteger(data, 'ts');
220444
+ await client.send({ 'action': 'pong', 'data': { 'ts': pingTs } });
220242
220445
  return;
220243
220446
  }
220244
220447
  const op = this.safeString(message, 'op');
220245
220448
  if (op === 'ping') {
220246
- const ping = this.safeInteger(message, 'ts');
220247
- await client.send({ 'op': 'pong', 'ts': ping });
220449
+ const pingTs = this.safeInteger(message, 'ts');
220450
+ await client.send({ 'op': 'pong', 'ts': pingTs });
220248
220451
  }
220249
220452
  }
220250
220453
  catch (e) {
@@ -220713,7 +220916,7 @@ class huobi extends _huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
220713
220916
  const signature = this.hmac(this.encode(payload), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_3__/* .sha256 */ .J, 'base64');
220714
220917
  let request = undefined;
220715
220918
  if (type === 'spot') {
220716
- const params = {
220919
+ const newParams = {
220717
220920
  'authType': 'api',
220718
220921
  'accessKey': this.apiKey,
220719
220922
  'signatureMethod': 'HmacSHA256',
@@ -220722,7 +220925,7 @@ class huobi extends _huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
220722
220925
  'signature': signature,
220723
220926
  };
220724
220927
  request = {
220725
- 'params': params,
220928
+ 'params': newParams,
220726
220929
  'action': 'req',
220727
220930
  'ch': 'auth',
220728
220931
  };
@@ -221086,8 +221289,7 @@ class huobijp extends _huobijp_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
221086
221289
  // unroll the accumulated deltas
221087
221290
  const messages = orderbook.cache;
221088
221291
  for (let i = 0; i < messages.length; i++) {
221089
- const message = messages[i];
221090
- this.handleOrderBookMessage(client, message, orderbook);
221292
+ this.handleOrderBookMessage(client, messages[i], orderbook);
221091
221293
  }
221092
221294
  this.orderbooks[symbol] = orderbook;
221093
221295
  client.resolve(orderbook, messageHash);
@@ -224297,9 +224499,9 @@ class krakenfutures extends _krakenfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
224297
224499
  let totalAmount = '0';
224298
224500
  const trades = previousOrder['trades'];
224299
224501
  for (let i = 0; i < trades.length; i++) {
224300
- const trade = trades[i];
224301
- totalCost = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringAdd */ .O.stringAdd(totalCost, this.numberToString(trade['cost']));
224302
- totalAmount = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringAdd */ .O.stringAdd(totalAmount, this.numberToString(trade['amount']));
224502
+ const currentTrade = trades[i];
224503
+ totalCost = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringAdd */ .O.stringAdd(totalCost, this.numberToString(currentTrade['cost']));
224504
+ totalAmount = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringAdd */ .O.stringAdd(totalAmount, this.numberToString(currentTrade['amount']));
224303
224505
  }
224304
224506
  if (_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringGt */ .O.stringGt(totalAmount, '0')) {
224305
224507
  previousOrder['average'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringDiv */ .O.stringDiv(totalCost, totalAmount);
@@ -224334,13 +224536,13 @@ class krakenfutures extends _krakenfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
224334
224536
  if (isCancel) {
224335
224537
  // get order without symbol
224336
224538
  for (let i = 0; i < orders.length; i++) {
224337
- const order = orders[i];
224338
- if (order['id'] === message['order_id']) {
224339
- orders[i] = this.extend(order, {
224539
+ const currentOrder = orders[i];
224540
+ if (currentOrder['id'] === message['order_id']) {
224541
+ orders[i] = this.extend(currentOrder, {
224340
224542
  'status': 'canceled',
224341
224543
  });
224342
224544
  client.resolve(orders, 'orders');
224343
- client.resolve(orders, 'orders:' + order['symbol']);
224545
+ client.resolve(orders, 'orders:' + currentOrder['symbol']);
224344
224546
  break;
224345
224547
  }
224346
224548
  }
@@ -225127,7 +225329,7 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
225127
225329
  'watchOrderBook': true,
225128
225330
  'watchOrders': true,
225129
225331
  'watchMyTrades': true,
225130
- 'watchTickers': false,
225332
+ 'watchTickers': true,
225131
225333
  'watchTicker': true,
225132
225334
  'watchTrades': true,
225133
225335
  'watchTradesForSymbols': true,
@@ -225245,6 +225447,29 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
225245
225447
  const messageHash = 'ticker:' + symbol;
225246
225448
  return await this.subscribe(url, messageHash, topic, query);
225247
225449
  }
225450
+ async watchTickers(symbols = undefined, params = {}) {
225451
+ /**
225452
+ * @method
225453
+ * @name kucoin#watchTickers
225454
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
225455
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
225456
+ * @param {object} [params] extra parameters specific to the kucoin api endpoint
225457
+ * @returns {object} a [ticker structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
225458
+ */
225459
+ await this.loadMarkets();
225460
+ symbols = this.marketSymbols(symbols);
225461
+ let messageHash = 'tickers';
225462
+ if (symbols !== undefined) {
225463
+ messageHash = 'tickers::' + symbols.join(',');
225464
+ }
225465
+ const url = await this.negotiate(false);
225466
+ const topic = '/market/ticker:all';
225467
+ const tickers = await this.subscribe(url, messageHash, topic, params);
225468
+ if (this.newUpdates) {
225469
+ return tickers;
225470
+ }
225471
+ return this.filterByArray(this.tickers, 'symbol', symbols);
225472
+ }
225248
225473
  handleTicker(client, message) {
225249
225474
  //
225250
225475
  // market/snapshot
@@ -225304,7 +225529,14 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
225304
225529
  let market = undefined;
225305
225530
  if (topic !== undefined) {
225306
225531
  const parts = topic.split(':');
225307
- const marketId = this.safeString(parts, 1);
225532
+ const first = this.safeString(parts, 1);
225533
+ let marketId = undefined;
225534
+ if (first === 'all') {
225535
+ marketId = this.safeString(message, 'subject');
225536
+ }
225537
+ else {
225538
+ marketId = first;
225539
+ }
225308
225540
  market = this.safeMarket(marketId, market, '-');
225309
225541
  }
225310
225542
  const data = this.safeValue(message, 'data', {});
@@ -225314,6 +225546,21 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
225314
225546
  this.tickers[symbol] = ticker;
225315
225547
  const messageHash = 'ticker:' + symbol;
225316
225548
  client.resolve(ticker, messageHash);
225549
+ // watchTickers
225550
+ client.resolve(ticker, 'tickers');
225551
+ const messageHashes = this.findMessageHashes(client, 'tickers::');
225552
+ for (let i = 0; i < messageHashes.length; i++) {
225553
+ const messageHash = messageHashes[i];
225554
+ const parts = messageHash.split('::');
225555
+ const symbolsString = parts[1];
225556
+ const symbols = symbolsString.split(',');
225557
+ const tickers = this.filterByArray(this.tickers, 'symbol', symbols);
225558
+ const tickersSymbols = Object.keys(tickers);
225559
+ const numTickers = tickersSymbols.length;
225560
+ if (numTickers > 0) {
225561
+ client.resolve(tickers, messageHash);
225562
+ }
225563
+ }
225317
225564
  }
225318
225565
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
225319
225566
  /**
@@ -225993,6 +226240,10 @@ class kucoin extends _kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
225993
226240
  // }
225994
226241
  // }
225995
226242
  //
226243
+ const topic = this.safeString(message, 'topic');
226244
+ if (topic === '/market/ticker:all') {
226245
+ return this.handleTicker(client, message);
226246
+ }
225996
226247
  const subject = this.safeString(message, 'subject');
225997
226248
  const methods = {
225998
226249
  'trade.l2update': this.handleOrderBook,
@@ -226455,9 +226706,9 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
226455
226706
  const deltaEnd = this.safeInteger(data, 'sequence');
226456
226707
  if (nonce === undefined) {
226457
226708
  const cacheLength = storedOrderBook.cache.length;
226458
- const topicParts = topic.split(':');
226459
- const topicSymbol = this.safeString(topicParts, 1);
226460
- const topicChannel = this.safeString(topicParts, 0);
226709
+ const topicPartsNew = topic.split(':');
226710
+ const topicSymbol = this.safeString(topicPartsNew, 1);
226711
+ const topicChannel = this.safeString(topicPartsNew, 0);
226461
226712
  const subscriptions = Object.keys(client.subscriptions);
226462
226713
  let subscription = undefined;
226463
226714
  for (let i = 0; i < subscriptions.length; i++) {
@@ -232306,8 +232557,8 @@ class phemex extends _phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
232306
232557
  }
232307
232558
  const keys = Object.keys(marketIds);
232308
232559
  for (let i = 0; i < keys.length; i++) {
232309
- const messageHash = 'orders' + ':' + keys[i];
232310
- client.resolve(this.orders, messageHash);
232560
+ const currentMessageHash = 'orders' + ':' + keys[i];
232561
+ client.resolve(this.orders, currentMessageHash);
232311
232562
  }
232312
232563
  // resolve generic subscription (spot or swap)
232313
232564
  const messageHash = 'orders:' + type;
@@ -232589,8 +232840,8 @@ class phemex extends _phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
232589
232840
  return method.call(this, client, message);
232590
232841
  }
232591
232842
  }
232592
- const method = this.safeString(message, 'method', '');
232593
- if (('market24h' in message) || ('spot_market24h' in message) || (method.indexOf('perp_market24h_pack_p') >= 0)) {
232843
+ const methodName = this.safeString(message, 'method', '');
232844
+ if (('market24h' in message) || ('spot_market24h' in message) || (methodName.indexOf('perp_market24h_pack_p') >= 0)) {
232594
232845
  return this.handleTicker(client, message);
232595
232846
  }
232596
232847
  else if (('trades' in message) || ('trades_p' in message)) {
@@ -233324,8 +233575,8 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
233324
233575
  let totalCost = '0';
233325
233576
  let totalAmount = '0';
233326
233577
  const previousOrderTrades = previousOrder['trades'];
233327
- for (let i = 0; i < previousOrderTrades.length; i++) {
233328
- const previousOrderTrade = previousOrderTrades[i];
233578
+ for (let j = 0; j < previousOrderTrades.length; j++) {
233579
+ const previousOrderTrade = previousOrderTrades[j];
233329
233580
  const cost = this.numberToString(previousOrderTrade['cost']);
233330
233581
  const amount = this.numberToString(previousOrderTrade['amount']);
233331
233582
  totalCost = _base_Precise_js__WEBPACK_IMPORTED_MODULE_4__/* .Precise.stringAdd */ .O.stringAdd(totalCost, cost);
@@ -233565,16 +233816,16 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
233565
233816
  }
233566
233817
  const orderbook = this.orderbooks[symbol];
233567
233818
  if (bids !== undefined) {
233568
- for (let i = 0; i < bids.length; i++) {
233569
- const bid = this.safeValue(bids, i);
233819
+ for (let j = 0; j < bids.length; j++) {
233820
+ const bid = this.safeValue(bids, j);
233570
233821
  const price = this.safeNumber(bid, 0);
233571
233822
  const amount = this.safeNumber(bid, 1);
233572
233823
  orderbook['bids'].store(price, amount);
233573
233824
  }
233574
233825
  }
233575
233826
  if (asks !== undefined) {
233576
- for (let i = 0; i < asks.length; i++) {
233577
- const ask = this.safeValue(asks, i);
233827
+ for (let j = 0; j < asks.length; j++) {
233828
+ const ask = this.safeValue(asks, j);
233578
233829
  const price = this.safeNumber(ask, 0);
233579
233830
  const amount = this.safeNumber(ask, 1);
233580
233831
  orderbook['asks'].store(price, amount);
@@ -236673,8 +236924,8 @@ class whitebit extends _whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
236673
236924
  // watchTickers
236674
236925
  const messageHashes = Object.keys(client.futures);
236675
236926
  for (let i = 0; i < messageHashes.length; i++) {
236676
- const messageHash = messageHashes[i];
236677
- if (messageHash.indexOf('tickers') >= 0 && messageHash.indexOf(symbol) >= 0) {
236927
+ const currentMessageHash = messageHashes[i];
236928
+ if (currentMessageHash.indexOf('tickers') >= 0 && currentMessageHash.indexOf(symbol) >= 0) {
236678
236929
  // Example: user calls watchTickers with ['LTC/USDT', 'ETH/USDT']
236679
236930
  // the associated messagehash will be: 'tickers:LTC/USDT:ETH/USDT'
236680
236931
  // since we only have access to a single symbol at a time
@@ -236684,7 +236935,7 @@ class whitebit extends _whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
236684
236935
  // user might have multiple watchTickers promises
236685
236936
  // watchTickers ( ['LTC/USDT', 'ETH/USDT'] ), watchTickers ( ['ETC/USDT', 'DOGE/USDT'] )
236686
236937
  // and we want to make sure we resolve only the correct ones
236687
- client.resolve(ticker, messageHash);
236938
+ client.resolve(ticker, currentMessageHash);
236688
236939
  }
236689
236940
  }
236690
236941
  return message;
@@ -237142,15 +237393,15 @@ class whitebit extends _whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
237142
237393
  }
237143
237394
  else {
237144
237395
  // resubscribe
237145
- let marketIds = [];
237146
- marketIds = Object.keys(subscription);
237396
+ let marketIdsNew = [];
237397
+ marketIdsNew = Object.keys(subscription);
237147
237398
  if (isNested) {
237148
- marketIds = [marketIds];
237399
+ marketIdsNew = [marketIdsNew];
237149
237400
  }
237150
237401
  const resubRequest = {
237151
237402
  'id': id,
237152
237403
  'method': method,
237153
- 'params': marketIds,
237404
+ 'params': marketIdsNew,
237154
237405
  };
237155
237406
  if (method in client.subscriptions) {
237156
237407
  delete client.subscriptions[method];
@@ -238469,14 +238720,14 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
238469
238720
  }
238470
238721
  const precision = this.parsePrecision(this.safeString(network, 'precision'));
238471
238722
  const withdrawFee = this.safeValue(network, 'withdrawal_fee', []);
238472
- const fee = this.safeValue(withdrawFee, 0, {});
238723
+ const networkfee = this.safeValue(withdrawFee, 0, {});
238473
238724
  networkList[networkCode] = {
238474
238725
  'id': networkId,
238475
238726
  'network': networkCode,
238476
238727
  'active': currentActive,
238477
238728
  'deposit': currentDeposit,
238478
238729
  'withdraw': currentWithdraw,
238479
- 'fee': this.safeNumber(fee, 'amount'),
238730
+ 'fee': this.safeNumber(networkfee, 'amount'),
238480
238731
  'precision': this.parseNumber(precision),
238481
238732
  'limits': {
238482
238733
  'withdraw': {
@@ -273769,7 +274020,7 @@ SOFTWARE.
273769
274020
 
273770
274021
  //-----------------------------------------------------------------------------
273771
274022
  // this is updated by vss.js when building
273772
- const version = '4.0.99';
274023
+ const version = '4.0.101';
273773
274024
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
273774
274025
  //-----------------------------------------------------------------------------
273775
274026