ccxt 4.2.78 → 4.2.80

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 (75) hide show
  1. package/README.md +5 -5
  2. package/dist/ccxt.browser.js +517 -79
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +35 -3
  6. package/dist/cjs/src/binance.js +1 -1
  7. package/dist/cjs/src/bingx.js +39 -5
  8. package/dist/cjs/src/bitstamp.js +21 -26
  9. package/dist/cjs/src/bybit.js +101 -0
  10. package/dist/cjs/src/coinbaseinternational.js +2 -2
  11. package/dist/cjs/src/deribit.js +155 -0
  12. package/dist/cjs/src/gate.js +15 -4
  13. package/dist/cjs/src/hyperliquid.js +54 -10
  14. package/dist/cjs/src/pro/alpaca.js +1 -1
  15. package/dist/cjs/src/pro/binance.js +5 -5
  16. package/dist/cjs/src/pro/bitfinex2.js +1 -1
  17. package/dist/cjs/src/pro/bitget.js +1 -1
  18. package/dist/cjs/src/pro/bitmart.js +1 -1
  19. package/dist/cjs/src/pro/bitmex.js +1 -1
  20. package/dist/cjs/src/pro/bitopro.js +2 -1
  21. package/dist/cjs/src/pro/blockchaincom.js +1 -1
  22. package/dist/cjs/src/pro/bybit.js +16 -1
  23. package/dist/cjs/src/pro/cex.js +9 -5
  24. package/dist/cjs/src/pro/cryptocom.js +1 -1
  25. package/dist/cjs/src/pro/gemini.js +3 -2
  26. package/dist/cjs/src/pro/hitbtc.js +1 -1
  27. package/dist/cjs/src/pro/htx.js +1 -1
  28. package/dist/cjs/src/pro/okcoin.js +1 -1
  29. package/dist/cjs/src/pro/onetrading.js +1 -1
  30. package/dist/cjs/src/pro/phemex.js +7 -2
  31. package/dist/cjs/src/pro/woo.js +38 -0
  32. package/dist/cjs/src/upbit.js +2 -0
  33. package/js/ccxt.d.ts +3 -3
  34. package/js/ccxt.js +1 -1
  35. package/js/src/abstract/bingx.d.ts +1 -0
  36. package/js/src/abstract/gate.d.ts +1 -0
  37. package/js/src/abstract/gateio.d.ts +1 -0
  38. package/js/src/abstract/upbit.d.ts +1 -0
  39. package/js/src/base/Exchange.d.ts +14 -5
  40. package/js/src/base/Exchange.js +35 -3
  41. package/js/src/base/types.d.ts +21 -0
  42. package/js/src/binance.d.ts +2 -2
  43. package/js/src/binance.js +1 -1
  44. package/js/src/bingx.js +39 -5
  45. package/js/src/bitstamp.js +21 -26
  46. package/js/src/bybit.d.ts +12 -1
  47. package/js/src/bybit.js +101 -0
  48. package/js/src/coinbaseinternational.js +2 -2
  49. package/js/src/deribit.d.ts +22 -1
  50. package/js/src/deribit.js +155 -0
  51. package/js/src/gate.js +15 -4
  52. package/js/src/hyperliquid.d.ts +1 -0
  53. package/js/src/hyperliquid.js +54 -10
  54. package/js/src/pro/alpaca.js +1 -1
  55. package/js/src/pro/binance.js +5 -5
  56. package/js/src/pro/bitfinex2.js +1 -1
  57. package/js/src/pro/bitget.js +1 -1
  58. package/js/src/pro/bitmart.js +1 -1
  59. package/js/src/pro/bitmex.js +1 -1
  60. package/js/src/pro/bitopro.js +2 -1
  61. package/js/src/pro/blockchaincom.js +1 -1
  62. package/js/src/pro/bybit.js +16 -1
  63. package/js/src/pro/cex.js +9 -5
  64. package/js/src/pro/cryptocom.js +1 -1
  65. package/js/src/pro/gemini.d.ts +2 -2
  66. package/js/src/pro/gemini.js +3 -2
  67. package/js/src/pro/hitbtc.js +1 -1
  68. package/js/src/pro/htx.js +1 -1
  69. package/js/src/pro/okcoin.js +1 -1
  70. package/js/src/pro/onetrading.js +1 -1
  71. package/js/src/pro/phemex.js +7 -2
  72. package/js/src/pro/woo.js +38 -0
  73. package/js/src/upbit.js +2 -0
  74. package/package.json +1 -1
  75. package/skip-tests.json +7 -2
@@ -7672,6 +7672,8 @@ class Exchange {
7672
7672
  'fetchOpenOrder': undefined,
7673
7673
  'fetchOpenOrders': undefined,
7674
7674
  'fetchOpenOrdersWs': undefined,
7675
+ 'fetchOption': undefined,
7676
+ 'fetchOptionChain': undefined,
7675
7677
  'fetchOrder': undefined,
7676
7678
  'fetchOrderBook': true,
7677
7679
  'fetchOrderBooks': undefined,
@@ -8643,6 +8645,12 @@ class Exchange {
8643
8645
  intToBase16(elem) {
8644
8646
  return elem.toString(16);
8645
8647
  }
8648
+ extendExchangeOptions(newOptions) {
8649
+ this.options = this.extend(this.options, newOptions);
8650
+ }
8651
+ createSafeDictionary() {
8652
+ return {};
8653
+ }
8646
8654
  /* eslint-enable */
8647
8655
  // ------------------------------------------------------------------------
8648
8656
  // ########################################################################
@@ -10343,7 +10351,7 @@ class Exchange {
10343
10351
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.BadResponse(errorMessage);
10344
10352
  }
10345
10353
  }
10346
- marketIds(symbols) {
10354
+ marketIds(symbols = undefined) {
10347
10355
  if (symbols === undefined) {
10348
10356
  return symbols;
10349
10357
  }
@@ -10353,7 +10361,7 @@ class Exchange {
10353
10361
  }
10354
10362
  return result;
10355
10363
  }
10356
- marketSymbols(symbols, type = undefined, allowEmpty = true, sameTypeOnly = false, sameSubTypeOnly = false) {
10364
+ marketSymbols(symbols = undefined, type = undefined, allowEmpty = true, sameTypeOnly = false, sameSubTypeOnly = false) {
10357
10365
  if (symbols === undefined) {
10358
10366
  if (!allowEmpty) {
10359
10367
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' empty list of symbols is not supported');
@@ -10394,7 +10402,7 @@ class Exchange {
10394
10402
  }
10395
10403
  return result;
10396
10404
  }
10397
- marketCodes(codes) {
10405
+ marketCodes(codes = undefined) {
10398
10406
  if (codes === undefined) {
10399
10407
  return codes;
10400
10408
  }
@@ -11334,6 +11342,9 @@ class Exchange {
11334
11342
  async fetchOrderBooks(symbols = undefined, limit = undefined, params = {}) {
11335
11343
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchOrderBooks() is not supported yet');
11336
11344
  }
11345
+ async watchBidsAsks(symbols = undefined, params = {}) {
11346
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' watchBidsAsks() is not supported yet');
11347
+ }
11337
11348
  async watchTickers(symbols = undefined, params = {}) {
11338
11349
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' watchTickers() is not supported yet');
11339
11350
  }
@@ -11686,6 +11697,12 @@ class Exchange {
11686
11697
  async fetchGreeks(symbol, params = {}) {
11687
11698
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchGreeks() is not supported yet');
11688
11699
  }
11700
+ async fetchOptionChain(code, params = {}) {
11701
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchOptionChain() is not supported yet');
11702
+ }
11703
+ async fetchOption(symbol, params = {}) {
11704
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchOption() is not supported yet');
11705
+ }
11689
11706
  async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
11690
11707
  /**
11691
11708
  * @method
@@ -12864,6 +12881,21 @@ class Exchange {
12864
12881
  parseGreeks(greeks, market = undefined) {
12865
12882
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' parseGreeks () is not supported yet');
12866
12883
  }
12884
+ parseOption(chain, currency = undefined, market = undefined) {
12885
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' parseOption () is not supported yet');
12886
+ }
12887
+ parseOptionChain(response, currencyKey = undefined, symbolKey = undefined) {
12888
+ const optionStructures = {};
12889
+ for (let i = 0; i < response.length; i++) {
12890
+ const info = response[i];
12891
+ const currencyId = this.safeString(info, currencyKey);
12892
+ const currency = this.safeCurrency(currencyId);
12893
+ const marketId = this.safeString(info, symbolKey);
12894
+ const market = this.safeMarket(marketId, undefined, undefined, 'option');
12895
+ optionStructures[market['symbol']] = this.parseOption(info, currency, market);
12896
+ }
12897
+ return optionStructures;
12898
+ }
12867
12899
  parseMarginModes(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
12868
12900
  const marginModeStructures = {};
12869
12901
  for (let i = 0; i < response.length; i++) {
@@ -20818,7 +20850,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20818
20850
  }
20819
20851
  isInverse(type, subType = undefined) {
20820
20852
  if (subType === undefined) {
20821
- return type === 'delivery';
20853
+ return (type === 'delivery');
20822
20854
  }
20823
20855
  else {
20824
20856
  return subType === 'inverse';
@@ -31354,6 +31386,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
31354
31386
  'post': {
31355
31387
  'trade/cancelReplace': 1,
31356
31388
  'positionSide/dual': 1,
31389
+ 'trade/closePosition': 1,
31357
31390
  },
31358
31391
  },
31359
31392
  },
@@ -33335,6 +33368,8 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
33335
33368
  'SELL': 'sell',
33336
33369
  'SHORT': 'sell',
33337
33370
  'LONG': 'buy',
33371
+ 'ask': 'sell',
33372
+ 'bid': 'buy',
33338
33373
  };
33339
33374
  return this.safeString(sides, side, side);
33340
33375
  }
@@ -35082,14 +35117,45 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
35082
35117
  * @param {string} symbol Unified CCXT market symbol
35083
35118
  * @param {string} [side] not used by bingx
35084
35119
  * @param {object} [params] extra parameters specific to the bingx api endpoint
35120
+ * @param {string|undefined} [params.positionId] it is recommended to fill in this parameter when closing a position
35085
35121
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
35086
35122
  */
35087
35123
  await this.loadMarkets();
35088
- const market = this.market(symbol);
35089
- const request = {
35090
- 'symbol': market['id'],
35091
- };
35092
- const response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
35124
+ const positionId = this.safeString(params, 'positionId');
35125
+ params = this.omit(params, 'positionId');
35126
+ let response = undefined;
35127
+ if (positionId !== undefined) {
35128
+ const request = {
35129
+ 'positionId': positionId,
35130
+ };
35131
+ response = await this.swapV1PrivatePostTradeClosePosition(this.extend(request, params));
35132
+ }
35133
+ else {
35134
+ const market = this.market(symbol);
35135
+ const request = {
35136
+ 'symbol': market['id'],
35137
+ };
35138
+ response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
35139
+ }
35140
+ //
35141
+ // swapV1PrivatePostTradeClosePosition
35142
+ //
35143
+ // {
35144
+ // "code": 0,
35145
+ // "msg": "",
35146
+ // "timestamp": 1710992264190,
35147
+ // "data": {
35148
+ // "orderId": 1770656007907930112,
35149
+ // "positionId": "1751667128353910784",
35150
+ // "symbol": "LTC-USDT",
35151
+ // "side": "Ask",
35152
+ // "type": "MARKET",
35153
+ // "positionSide": "Long",
35154
+ // "origQty": "0.2"
35155
+ // }
35156
+ // }
35157
+ //
35158
+ // swapV2PrivatePostTradeCloseAllPositions
35093
35159
  //
35094
35160
  // {
35095
35161
  // "code": 0,
@@ -70180,16 +70246,18 @@ class bitstamp extends _abstract_bitstamp_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
70180
70246
  'timestamp': undefined,
70181
70247
  'datetime': undefined,
70182
70248
  };
70183
- const codes = Object.keys(this.currencies);
70184
- for (let i = 0; i < codes.length; i++) {
70185
- const code = codes[i];
70186
- const currency = this.currency(code);
70187
- const currencyId = currency['id'];
70249
+ if (response === undefined) {
70250
+ response = [];
70251
+ }
70252
+ for (let i = 0; i < response.length; i++) {
70253
+ const currencyBalance = response[i];
70254
+ const currencyId = this.safeString(currencyBalance, 'currency');
70255
+ const currencyCode = this.safeCurrencyCode(currencyId);
70188
70256
  const account = this.account();
70189
- account['free'] = this.safeString(response, currencyId + '_available');
70190
- account['used'] = this.safeString(response, currencyId + '_reserved');
70191
- account['total'] = this.safeString(response, currencyId + '_balance');
70192
- result[code] = account;
70257
+ account['free'] = this.safeString(currencyBalance, 'available');
70258
+ account['used'] = this.safeString(currencyBalance, 'reserved');
70259
+ account['total'] = this.safeString(currencyBalance, 'total');
70260
+ result[currencyCode] = account;
70193
70261
  }
70194
70262
  return this.safeBalance(result);
70195
70263
  }
@@ -70203,24 +70271,17 @@ class bitstamp extends _abstract_bitstamp_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
70203
70271
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
70204
70272
  */
70205
70273
  await this.loadMarkets();
70206
- const response = await this.privatePostBalance(params);
70274
+ const response = await this.privatePostAccountBalances(params);
70207
70275
  //
70208
- // {
70209
- // "aave_available": "0.00000000",
70210
- // "aave_balance": "0.00000000",
70211
- // "aave_reserved": "0.00000000",
70212
- // "aave_withdrawal_fee": "0.07000000",
70213
- // "aavebtc_fee": "0.000",
70214
- // "aaveeur_fee": "0.000",
70215
- // "aaveusd_fee": "0.000",
70216
- // "bat_available": "0.00000000",
70217
- // "bat_balance": "0.00000000",
70218
- // "bat_reserved": "0.00000000",
70219
- // "bat_withdrawal_fee": "5.00000000",
70220
- // "batbtc_fee": "0.000",
70221
- // "bateur_fee": "0.000",
70222
- // "batusd_fee": "0.000",
70223
- // }
70276
+ // [
70277
+ // {
70278
+ // "currency": "usdt",
70279
+ // "total": "7.00000",
70280
+ // "available": "7.00000",
70281
+ // "reserved": "0.00000"
70282
+ // },
70283
+ // ...
70284
+ // ]
70224
70285
  //
70225
70286
  return this.parseBalance(response);
70226
70287
  }
@@ -83546,6 +83607,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
83546
83607
  'fetchDeposits': true,
83547
83608
  'fetchDepositWithdrawFee': 'emulated',
83548
83609
  'fetchDepositWithdrawFees': true,
83610
+ 'fetchFundingHistory': true,
83549
83611
  'fetchFundingRate': true,
83550
83612
  'fetchFundingRateHistory': true,
83551
83613
  'fetchFundingRates': true,
@@ -91586,6 +91648,106 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
91586
91648
  }
91587
91649
  return tiers;
91588
91650
  }
91651
+ async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
91652
+ /**
91653
+ * @method
91654
+ * @name bybit#fetchFundingHistory
91655
+ * @description fetch the history of funding payments paid and received on this account
91656
+ * @see https://bybit-exchange.github.io/docs/api-explorer/v5/position/execution
91657
+ * @param {string} [symbol] unified market symbol
91658
+ * @param {int} [since] the earliest time in ms to fetch funding history for
91659
+ * @param {int} [limit] the maximum number of funding history structures to retrieve
91660
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
91661
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
91662
+ * @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
91663
+ */
91664
+ await this.loadMarkets();
91665
+ let paginate = false;
91666
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingHistory', 'paginate');
91667
+ if (paginate) {
91668
+ return await this.fetchPaginatedCallCursor('fetchFundingHistory', symbol, since, limit, params, 'nextPageCursor', 'cursor', undefined, 100);
91669
+ }
91670
+ let request = {
91671
+ 'execType': 'Funding',
91672
+ };
91673
+ let market = undefined;
91674
+ if (symbol !== undefined) {
91675
+ market = this.market(symbol);
91676
+ request['symbol'] = market['id'];
91677
+ }
91678
+ let type = undefined;
91679
+ [type, params] = this.getBybitType('fetchFundingHistory', market, params);
91680
+ request['category'] = type;
91681
+ if (symbol !== undefined) {
91682
+ request['symbol'] = market['id'];
91683
+ }
91684
+ if (since !== undefined) {
91685
+ request['startTime'] = since;
91686
+ }
91687
+ if (limit !== undefined) {
91688
+ request['size'] = limit;
91689
+ }
91690
+ else {
91691
+ request['size'] = 100;
91692
+ }
91693
+ [request, params] = this.handleUntilOption('endTime', request, params);
91694
+ const response = await this.privateGetV5ExecutionList(this.extend(request, params));
91695
+ const fundings = this.addPaginationCursorToResult(response);
91696
+ return this.parseIncomes(fundings, market, since, limit);
91697
+ }
91698
+ parseIncome(income, market = undefined) {
91699
+ //
91700
+ // {
91701
+ // "symbol": "XMRUSDT",
91702
+ // "orderType": "UNKNOWN",
91703
+ // "underlyingPrice": "",
91704
+ // "orderLinkId": "",
91705
+ // "orderId": "a11e5fe2-1dbf-4bab-a9b2-af80a14efc5d",
91706
+ // "stopOrderType": "UNKNOWN",
91707
+ // "execTime": "1710950400000",
91708
+ // "feeCurrency": "",
91709
+ // "createType": "",
91710
+ // "feeRate": "-0.000761",
91711
+ // "tradeIv": "",
91712
+ // "blockTradeId": "",
91713
+ // "markPrice": "136.79",
91714
+ // "execPrice": "137.11",
91715
+ // "markIv": "",
91716
+ // "orderQty": "0",
91717
+ // "orderPrice": "0",
91718
+ // "execValue": "134.3678",
91719
+ // "closedSize": "0",
91720
+ // "execType": "Funding",
91721
+ // "seq": "28097658790",
91722
+ // "side": "Sell",
91723
+ // "indexPrice": "",
91724
+ // "leavesQty": "0",
91725
+ // "isMaker": false,
91726
+ // "execFee": "-0.10232512",
91727
+ // "execId": "8d1ef156-4ec6-4445-9a6c-1c0c24dbd046",
91728
+ // "marketUnit": "",
91729
+ // "execQty": "0.98",
91730
+ // "nextPageCursor": "5774437%3A0%2C5771289%3A0"
91731
+ // }
91732
+ //
91733
+ const marketId = this.safeString(income, 'symbol');
91734
+ market = this.safeMarket(marketId, market, undefined, 'contract');
91735
+ let code = 'USDT';
91736
+ if (market['inverse']) {
91737
+ code = market['quote'];
91738
+ }
91739
+ const timestamp = this.safeInteger(income, 'execTime');
91740
+ return {
91741
+ 'info': income,
91742
+ 'symbol': this.safeSymbol(marketId, market, '-', 'swap'),
91743
+ 'code': code,
91744
+ 'timestamp': timestamp,
91745
+ 'datetime': this.iso8601(timestamp),
91746
+ 'id': this.safeString(income, 'execId'),
91747
+ 'amount': this.safeNumber(income, 'execQty'),
91748
+ 'rate': this.safeNumber(income, 'feeRate'),
91749
+ };
91750
+ }
91589
91751
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
91590
91752
  let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
91591
91753
  if (api === 'public') {
@@ -97476,10 +97638,10 @@ class coinbaseinternational extends _abstract_coinbaseinternational_js__WEBPACK_
97476
97638
  },
97477
97639
  'www': 'https://international.coinbase.com',
97478
97640
  'doc': [
97479
- 'https://docs.cloud.coinbaseinternational.com/intx/docs',
97641
+ 'https://docs.cloud.coinbase.com/intx/docs',
97480
97642
  ],
97481
97643
  'fees': [
97482
- 'https://help.coinbaseinternational.com/en/international-exchange/trading-deposits-withdrawals/international-exchange-fees',
97644
+ 'https://help.coinbase.com/en/international-exchange/trading-deposits-withdrawals/international-exchange-fees',
97483
97645
  ],
97484
97646
  'referral': '',
97485
97647
  },
@@ -125308,6 +125470,8 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
125308
125470
  'fetchMyTrades': true,
125309
125471
  'fetchOHLCV': true,
125310
125472
  'fetchOpenOrders': true,
125473
+ 'fetchOption': true,
125474
+ 'fetchOptionChain': true,
125311
125475
  'fetchOrder': true,
125312
125476
  'fetchOrderBook': true,
125313
125477
  'fetchOrders': false,
@@ -128694,6 +128858,159 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
128694
128858
  'info': greeks,
128695
128859
  };
128696
128860
  }
128861
+ async fetchOption(symbol, params = {}) {
128862
+ /**
128863
+ * @method
128864
+ * @name deribit#fetchOption
128865
+ * @description fetches option data that is commonly found in an option chain
128866
+ * @see https://docs.deribit.com/#public-get_book_summary_by_instrument
128867
+ * @param {string} symbol unified market symbol
128868
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
128869
+ * @returns {object} an [option chain structure]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
128870
+ */
128871
+ await this.loadMarkets();
128872
+ const market = this.market(symbol);
128873
+ const request = {
128874
+ 'instrument_name': market['id'],
128875
+ };
128876
+ const response = await this.publicGetGetBookSummaryByInstrument(this.extend(request, params));
128877
+ //
128878
+ // {
128879
+ // "jsonrpc": "2.0",
128880
+ // "result": [
128881
+ // {
128882
+ // "mid_price": 0.04025,
128883
+ // "volume_usd": 11045.12,
128884
+ // "quote_currency": "BTC",
128885
+ // "estimated_delivery_price": 65444.72,
128886
+ // "creation_timestamp": 1711100949273,
128887
+ // "base_currency": "BTC",
128888
+ // "underlying_index": "BTC-27DEC24",
128889
+ // "underlying_price": 73742.14,
128890
+ // "volume": 4.0,
128891
+ // "interest_rate": 0.0,
128892
+ // "price_change": -6.9767,
128893
+ // "open_interest": 274.2,
128894
+ // "ask_price": 0.042,
128895
+ // "bid_price": 0.0385,
128896
+ // "instrument_name": "BTC-27DEC24-240000-C",
128897
+ // "mark_price": 0.04007735,
128898
+ // "last": 0.04,
128899
+ // "low": 0.04,
128900
+ // "high": 0.043
128901
+ // }
128902
+ // ],
128903
+ // "usIn": 1711100949273223,
128904
+ // "usOut": 1711100949273580,
128905
+ // "usDiff": 357,
128906
+ // "testnet": false
128907
+ // }
128908
+ //
128909
+ const result = this.safeList(response, 'result', []);
128910
+ const chain = this.safeDict(result, 0, {});
128911
+ return this.parseOption(chain, undefined, market);
128912
+ }
128913
+ async fetchOptionChain(code, params = {}) {
128914
+ /**
128915
+ * @method
128916
+ * @name deribit#fetchOptionChain
128917
+ * @description fetches data for an underlying asset that is commonly found in an option chain
128918
+ * @see https://docs.deribit.com/#public-get_book_summary_by_currency
128919
+ * @param {string} currency base currency to fetch an option chain for
128920
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
128921
+ * @returns {object} a list of [option chain structures]{@link https://docs.ccxt.com/#/?id=option-chain-structure}
128922
+ */
128923
+ await this.loadMarkets();
128924
+ const currency = this.currency(code);
128925
+ const request = {
128926
+ 'currency': currency['id'],
128927
+ 'kind': 'option',
128928
+ };
128929
+ const response = await this.publicGetGetBookSummaryByCurrency(this.extend(request, params));
128930
+ //
128931
+ // {
128932
+ // "jsonrpc": "2.0",
128933
+ // "result": [
128934
+ // {
128935
+ // "mid_price": 0.4075,
128936
+ // "volume_usd": 2836.83,
128937
+ // "quote_currency": "BTC",
128938
+ // "estimated_delivery_price": 65479.26,
128939
+ // "creation_timestamp": 1711101594477,
128940
+ // "base_currency": "BTC",
128941
+ // "underlying_index": "BTC-28JUN24",
128942
+ // "underlying_price": 68827.27,
128943
+ // "volume": 0.1,
128944
+ // "interest_rate": 0.0,
128945
+ // "price_change": 0.0,
128946
+ // "open_interest": 364.1,
128947
+ // "ask_price": 0.411,
128948
+ // "bid_price": 0.404,
128949
+ // "instrument_name": "BTC-28JUN24-42000-C",
128950
+ // "mark_price": 0.40752052,
128951
+ // "last": 0.423,
128952
+ // "low": 0.423,
128953
+ // "high": 0.423
128954
+ // }
128955
+ // ],
128956
+ // "usIn": 1711101594456388,
128957
+ // "usOut": 1711101594484065,
128958
+ // "usDiff": 27677,
128959
+ // "testnet": false
128960
+ // }
128961
+ //
128962
+ const result = this.safeList(response, 'result', []);
128963
+ return this.parseOptionChain(result, 'base_currency', 'instrument_name');
128964
+ }
128965
+ parseOption(chain, currency = undefined, market = undefined) {
128966
+ //
128967
+ // {
128968
+ // "mid_price": 0.04025,
128969
+ // "volume_usd": 11045.12,
128970
+ // "quote_currency": "BTC",
128971
+ // "estimated_delivery_price": 65444.72,
128972
+ // "creation_timestamp": 1711100949273,
128973
+ // "base_currency": "BTC",
128974
+ // "underlying_index": "BTC-27DEC24",
128975
+ // "underlying_price": 73742.14,
128976
+ // "volume": 4.0,
128977
+ // "interest_rate": 0.0,
128978
+ // "price_change": -6.9767,
128979
+ // "open_interest": 274.2,
128980
+ // "ask_price": 0.042,
128981
+ // "bid_price": 0.0385,
128982
+ // "instrument_name": "BTC-27DEC24-240000-C",
128983
+ // "mark_price": 0.04007735,
128984
+ // "last": 0.04,
128985
+ // "low": 0.04,
128986
+ // "high": 0.043
128987
+ // }
128988
+ //
128989
+ const marketId = this.safeString(chain, 'instrument_name');
128990
+ market = this.safeMarket(marketId, market);
128991
+ const currencyId = this.safeString(chain, 'base_currency');
128992
+ const code = this.safeCurrencyCode(currencyId, currency);
128993
+ const timestamp = this.safeInteger(chain, 'timestamp');
128994
+ return {
128995
+ 'info': chain,
128996
+ 'currency': code['code'],
128997
+ 'symbol': market['symbol'],
128998
+ 'timestamp': timestamp,
128999
+ 'datetime': this.iso8601(timestamp),
129000
+ 'impliedVolatility': undefined,
129001
+ 'openInterest': this.safeNumber(chain, 'open_interest'),
129002
+ 'bidPrice': this.safeNumber(chain, 'bid_price'),
129003
+ 'askPrice': this.safeNumber(chain, 'ask_price'),
129004
+ 'midPrice': this.safeNumber(chain, 'mid_price'),
129005
+ 'markPrice': this.safeNumber(chain, 'mark_price'),
129006
+ 'lastPrice': this.safeNumber(chain, 'last'),
129007
+ 'underlyingPrice': this.safeNumber(chain, 'underlying_price'),
129008
+ 'change': undefined,
129009
+ 'percentage': this.safeNumber(chain, 'price_change'),
129010
+ 'baseVolume': this.safeNumber(chain, 'volume'),
129011
+ 'quoteVolume': this.safeNumber(chain, 'volume_usd'),
129012
+ };
129013
+ }
128697
129014
  nonce() {
128698
129015
  return this.milliseconds();
128699
129016
  }
@@ -136141,6 +136458,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
136141
136458
  'loan_records': 20 / 15,
136142
136459
  'interest_records': 20 / 15,
136143
136460
  'estimate_rate': 20 / 15,
136461
+ 'currency_discount_tiers': 20 / 15,
136144
136462
  },
136145
136463
  'post': {
136146
136464
  'account_mode': 20 / 15,
@@ -140061,7 +140379,17 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
140061
140379
  'account': account,
140062
140380
  };
140063
140381
  if (amount !== undefined) {
140064
- request['amount'] = this.amountToPrecision(symbol, amount);
140382
+ if (market['spot']) {
140383
+ request['amount'] = this.amountToPrecision(symbol, amount);
140384
+ }
140385
+ else {
140386
+ if (side === 'sell') {
140387
+ request['size'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringNeg(this.amountToPrecision(symbol, amount));
140388
+ }
140389
+ else {
140390
+ request['size'] = this.amountToPrecision(symbol, amount);
140391
+ }
140392
+ }
140065
140393
  }
140066
140394
  if (price !== undefined) {
140067
140395
  request['price'] = this.priceToPrecision(symbol, price);
@@ -140859,8 +141187,8 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
140859
141187
  */
140860
141188
  await this.loadMarkets();
140861
141189
  const market = (symbol === undefined) ? undefined : this.market(symbol);
140862
- const stop = this.safeValue(params, 'stop');
140863
- params = this.omit(params, 'stop');
141190
+ const stop = this.safeBool2(params, 'stop', 'trigger');
141191
+ params = this.omit(params, ['stop', 'trigger']);
140864
141192
  const [type, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
140865
141193
  const [request, requestParams] = (type === 'spot') ? this.multiOrderSpotPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
140866
141194
  let response = undefined;
@@ -141188,7 +141516,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
141188
141516
  'unrealizedPnl': this.parseNumber(unrealisedPnl),
141189
141517
  'realizedPnl': this.safeNumber(position, 'realised_pnl'),
141190
141518
  'contracts': this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(size)),
141191
- 'contractSize': this.safeValue(market, 'contractSize'),
141519
+ 'contractSize': this.safeNumber(market, 'contractSize'),
141192
141520
  // 'realisedPnl': position['realised_pnl'],
141193
141521
  'marginRatio': undefined,
141194
141522
  'liquidationPrice': this.safeNumber(position, 'liq_price'),
@@ -162560,6 +162888,8 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
162560
162888
  */
162561
162889
  await this.loadMarkets();
162562
162890
  const market = this.market(symbol);
162891
+ const vaultAddress = this.safeString(params, 'vaultAddress');
162892
+ params = this.omit(params, 'vaultAddress');
162563
162893
  symbol = market['symbol'];
162564
162894
  const order = {
162565
162895
  'symbol': symbol,
@@ -162569,7 +162899,11 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
162569
162899
  'price': price,
162570
162900
  'params': params,
162571
162901
  };
162572
- const response = await this.createOrders([order], params);
162902
+ const globalParams = {};
162903
+ if (vaultAddress !== undefined) {
162904
+ globalParams['vaultAddress'] = vaultAddress;
162905
+ }
162906
+ const response = await this.createOrders([order], globalParams);
162573
162907
  const first = this.safeDict(response, 0);
162574
162908
  return first;
162575
162909
  }
@@ -162620,7 +162954,6 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
162620
162954
  const amount = this.safeString(rawOrder, 'amount');
162621
162955
  const price = this.safeString(rawOrder, 'price');
162622
162956
  let orderParams = this.safeDict(rawOrder, 'params', {});
162623
- orderParams = this.extend(params, orderParams);
162624
162957
  const clientOrderId = this.safeString2(orderParams, 'clientOrderId', 'client_id');
162625
162958
  const slippage = this.safeString(orderParams, 'slippage', defaultSlippage);
162626
162959
  let defaultTimeInForce = (isMarket) ? 'ioc' : 'gtc';
@@ -162668,6 +163001,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
162668
163001
  'tif': timeInForce,
162669
163002
  };
162670
163003
  }
163004
+ orderParams = this.omit(orderParams, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id']);
162671
163005
  const orderObj = {
162672
163006
  'a': this.parseToInt(market['baseId']),
162673
163007
  'b': isBuy,
@@ -162680,9 +163014,9 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
162680
163014
  if (clientOrderId !== undefined) {
162681
163015
  orderObj['c'] = clientOrderId;
162682
163016
  }
162683
- orderReq.push(orderObj);
163017
+ orderReq.push(this.extend(orderObj, orderParams));
162684
163018
  }
162685
- const vaultAddress = this.safeString(params, 'vaultAddress');
163019
+ const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
162686
163020
  const orderAction = {
162687
163021
  'type': 'order',
162688
163022
  'orders': orderReq,
@@ -162699,6 +163033,10 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
162699
163033
  'signature': signature,
162700
163034
  // 'vaultAddress': vaultAddress,
162701
163035
  };
163036
+ if (vaultAddress !== undefined) {
163037
+ params = this.omit(params, 'vaultAddress');
163038
+ request['vaultAddress'] = vaultAddress;
163039
+ }
162702
163040
  const response = await this.privatePostExchange(this.extend(request, params));
162703
163041
  //
162704
163042
  // {
@@ -162791,10 +163129,14 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
162791
163129
  }
162792
163130
  }
162793
163131
  cancelAction['cancels'] = cancelReq;
162794
- const vaultAddress = this.safeString(params, 'vaultAddress');
163132
+ const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
162795
163133
  const signature = this.signL1Action(cancelAction, nonce, vaultAddress);
162796
163134
  request['action'] = cancelAction;
162797
163135
  request['signature'] = signature;
163136
+ if (vaultAddress !== undefined) {
163137
+ params = this.omit(params, 'vaultAddress');
163138
+ request['vaultAddress'] = vaultAddress;
163139
+ }
162798
163140
  const response = await this.privatePostExchange(this.extend(request, params));
162799
163141
  //
162800
163142
  // {
@@ -162912,7 +163254,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
162912
163254
  'type': 'batchModify',
162913
163255
  'modifies': [modifyReq],
162914
163256
  };
162915
- const vaultAddress = this.safeString(params, 'vaultAddress');
163257
+ const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
162916
163258
  const signature = this.signL1Action(modifyAction, nonce, vaultAddress);
162917
163259
  const request = {
162918
163260
  'action': modifyAction,
@@ -162920,6 +163262,10 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
162920
163262
  'signature': signature,
162921
163263
  // 'vaultAddress': vaultAddress,
162922
163264
  };
163265
+ if (vaultAddress !== undefined) {
163266
+ params = this.omit(params, 'vaultAddress');
163267
+ request['vaultAddress'] = vaultAddress;
163268
+ }
162923
163269
  const response = await this.privatePostExchange(this.extend(request, params));
162924
163270
  //
162925
163271
  // {
@@ -163518,7 +163864,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
163518
163864
  'isolated': isIsolated,
163519
163865
  'hedged': undefined,
163520
163866
  'side': side,
163521
- 'contracts': this.parseNumber(quantity),
163867
+ 'contracts': this.safeNumber(entry, 'szi'),
163522
163868
  'contractSize': undefined,
163523
163869
  'entryPrice': this.safeNumber(entry, 'entryPx'),
163524
163870
  'markPrice': undefined,
@@ -163565,7 +163911,13 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
163565
163911
  'isCross': isCross,
163566
163912
  'leverage': leverage,
163567
163913
  };
163568
- const vaultAddress = this.safeString(params, 'vaultAddress');
163914
+ let vaultAddress = this.safeString(params, 'vaultAddress');
163915
+ if (vaultAddress !== undefined) {
163916
+ params = this.omit(params, 'vaultAddress');
163917
+ if (vaultAddress.startsWith('0x')) {
163918
+ vaultAddress = vaultAddress.replace('0x', '');
163919
+ }
163920
+ }
163569
163921
  const signature = this.signL1Action(updateAction, nonce, vaultAddress);
163570
163922
  const request = {
163571
163923
  'action': updateAction,
@@ -163573,6 +163925,9 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
163573
163925
  'signature': signature,
163574
163926
  // 'vaultAddress': vaultAddress,
163575
163927
  };
163928
+ if (vaultAddress !== undefined) {
163929
+ request['vaultAddress'] = vaultAddress;
163930
+ }
163576
163931
  const response = await this.privatePostExchange(this.extend(request, params));
163577
163932
  //
163578
163933
  // {
@@ -163611,7 +163966,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
163611
163966
  'isCross': isCross,
163612
163967
  'leverage': leverage,
163613
163968
  };
163614
- const vaultAddress = this.safeString(params, 'vaultAddress');
163969
+ const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
163615
163970
  const signature = this.signL1Action(updateAction, nonce, vaultAddress);
163616
163971
  const request = {
163617
163972
  'action': updateAction,
@@ -163619,6 +163974,10 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
163619
163974
  'signature': signature,
163620
163975
  // 'vaultAddress': vaultAddress,
163621
163976
  };
163977
+ if (vaultAddress !== undefined) {
163978
+ params = this.omit(params, 'vaultAddress');
163979
+ request['vaultAddress'] = vaultAddress;
163980
+ }
163622
163981
  const response = await this.privatePostExchange(this.extend(request, params));
163623
163982
  //
163624
163983
  // {
@@ -163671,7 +164030,7 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
163671
164030
  'isBuy': true,
163672
164031
  'ntli': sz,
163673
164032
  };
163674
- const vaultAddress = this.safeString(params, 'vaultAddress');
164033
+ const vaultAddress = this.formatVaultAddress(this.safeString(params, 'vaultAddress'));
163675
164034
  const signature = this.signL1Action(updateAction, nonce, vaultAddress);
163676
164035
  const request = {
163677
164036
  'action': updateAction,
@@ -163679,6 +164038,10 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
163679
164038
  'signature': signature,
163680
164039
  // 'vaultAddress': vaultAddress,
163681
164040
  };
164041
+ if (vaultAddress !== undefined) {
164042
+ params = this.omit(params, 'vaultAddress');
164043
+ request['vaultAddress'] = vaultAddress;
164044
+ }
163682
164045
  const response = await this.privatePostExchange(this.extend(request, params));
163683
164046
  //
163684
164047
  // {
@@ -163777,6 +164140,15 @@ class hyperliquid extends _abstract_hyperliquid_js__WEBPACK_IMPORTED_MODULE_0__/
163777
164140
  const response = await this.privatePostExchange(this.extend(request, params));
163778
164141
  return response;
163779
164142
  }
164143
+ formatVaultAddress(address = undefined) {
164144
+ if (address === undefined) {
164145
+ return undefined;
164146
+ }
164147
+ if (address.startsWith('0x')) {
164148
+ return address.replace('0x', '');
164149
+ }
164150
+ return address;
164151
+ }
163780
164152
  handlePublicAddress(methodName, params) {
163781
164153
  let userAux = undefined;
163782
164154
  [userAux, params] = this.handleOptionAndParams(params, methodName, 'user');
@@ -225407,7 +225779,7 @@ class alpaca extends _alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
225407
225779
  }
225408
225780
  this.watch(url, messageHash, request, messageHash, future);
225409
225781
  }
225410
- return future;
225782
+ return await future;
225411
225783
  }
225412
225784
  handleErrorMessage(client, message) {
225413
225785
  //
@@ -226664,7 +227036,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
226664
227036
  'future': 200,
226665
227037
  'delivery': 200,
226666
227038
  },
226667
- 'streamBySubscriptionsHash': {},
227039
+ 'streamBySubscriptionsHash': this.createSafeDictionary(),
226668
227040
  'streamIndex': -1,
226669
227041
  // get updates every 1000ms or 100ms
226670
227042
  // or every 0ms in real-time for futures
@@ -226672,7 +227044,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
226672
227044
  'tradesLimit': 1000,
226673
227045
  'ordersLimit': 1000,
226674
227046
  'OHLCVLimit': 1000,
226675
- 'requestId': {},
227047
+ 'requestId': this.createSafeDictionary(),
226676
227048
  'watchOrderBookLimit': 1000,
226677
227049
  'watchTrades': {
226678
227050
  'name': 'trade', // 'trade' or 'aggTrade'
@@ -226706,14 +227078,14 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
226706
227078
  });
226707
227079
  }
226708
227080
  requestId(url) {
226709
- const options = this.safeValue(this.options, 'requestId', {});
227081
+ const options = this.safeDict(this.options, 'requestId', this.createSafeDictionary());
226710
227082
  const previousValue = this.safeInteger(options, url, 0);
226711
227083
  const newValue = this.sum(previousValue, 1);
226712
227084
  this.options['requestId'][url] = newValue;
226713
227085
  return newValue;
226714
227086
  }
226715
227087
  stream(type, subscriptionHash, numSubscriptions = 1) {
226716
- const streamBySubscriptionsHash = this.safeValue(this.options, 'streamBySubscriptionsHash', {});
227088
+ const streamBySubscriptionsHash = this.safeDict(this.options, 'streamBySubscriptionsHash', this.createSafeDictionary());
226717
227089
  let stream = this.safeString(streamBySubscriptionsHash, subscriptionHash);
226718
227090
  if (stream === undefined) {
226719
227091
  let streamIndex = this.safeInteger(this.options, 'streamIndex', -1);
@@ -226726,7 +227098,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
226726
227098
  this.options['streamBySubscriptionsHash'][subscriptionHash] = stream;
226727
227099
  const subscriptionsByStreams = this.safeValue(this.options, 'numSubscriptionsByStream');
226728
227100
  if (subscriptionsByStreams === undefined) {
226729
- this.options['numSubscriptionsByStream'] = {};
227101
+ this.options['numSubscriptionsByStream'] = this.createSafeDictionary();
226730
227102
  }
226731
227103
  const subscriptionsByStream = this.safeInteger(this.options['numSubscriptionsByStream'], stream, 0);
226732
227104
  const newNumSubscriptions = subscriptionsByStream + numSubscriptions;
@@ -232496,7 +232868,7 @@ class bitfinex2 extends _bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
232496
232868
  const message = this.extend(request, params);
232497
232869
  this.watch(url, messageHash, message, messageHash);
232498
232870
  }
232499
- return future;
232871
+ return await future;
232500
232872
  }
232501
232873
  handleAuthenticationMessage(client, message) {
232502
232874
  const messageHash = 'authenticated';
@@ -234410,7 +234782,7 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
234410
234782
  const message = this.extend(request, params);
234411
234783
  this.watch(url, messageHash, message, messageHash);
234412
234784
  }
234413
- return future;
234785
+ return await future;
234414
234786
  }
234415
234787
  async watchPrivate(messageHash, subscriptionHash, args, params = {}) {
234416
234788
  await this.authenticate();
@@ -235975,7 +236347,7 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
235975
236347
  const message = this.extend(request, params);
235976
236348
  this.watch(url, messageHash, message, messageHash);
235977
236349
  }
235978
- return future;
236350
+ return await future;
235979
236351
  }
235980
236352
  handleSubscriptionStatus(client, message) {
235981
236353
  //
@@ -236745,7 +237117,7 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
236745
237117
  const message = this.extend(request, params);
236746
237118
  this.watch(url, messageHash, message, messageHash);
236747
237119
  }
236748
- return future;
237120
+ return await future;
236749
237121
  }
236750
237122
  handleAuthenticationMessage(client, message) {
236751
237123
  const authenticated = this.safeBool(message, 'success', false);
@@ -238139,7 +238511,8 @@ class bitopro extends _bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
238139
238511
  },
238140
238512
  },
238141
238513
  };
238142
- this.options = this.extend(defaultOptions, this.options);
238514
+ // this.options = this.extend (defaultOptions, this.options);
238515
+ this.extendExchangeOptions(defaultOptions);
238143
238516
  const originalHeaders = this.options['ws']['options']['headers'];
238144
238517
  const headers = {
238145
238518
  'X-BITOPRO-API': 'ccxt',
@@ -241419,7 +241792,7 @@ class blockchaincom extends _blockchaincom_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
241419
241792
  };
241420
241793
  return this.watch(url, messageHash, this.extend(request, params), messageHash);
241421
241794
  }
241422
- return future;
241795
+ return await future;
241423
241796
  }
241424
241797
  }
241425
241798
 
@@ -242472,8 +242845,23 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
242472
242845
  for (let i = 0; i < rawPositions.length; i++) {
242473
242846
  const rawPosition = rawPositions[i];
242474
242847
  const position = this.parsePosition(rawPosition);
242848
+ const side = this.safeString(position, 'side');
242849
+ // hacky solution to handle closing positions
242850
+ // without crashing, we should handle this properly later
242475
242851
  newPositions.push(position);
242476
- cache.append(position);
242852
+ if (side === undefined || side === '') {
242853
+ // closing update, adding both sides to "reset" both sides
242854
+ // since we don't know which side is being closed
242855
+ position['side'] = 'long';
242856
+ cache.append(position);
242857
+ position['side'] = 'short';
242858
+ cache.append(position);
242859
+ position['side'] = undefined;
242860
+ }
242861
+ else {
242862
+ // regular update
242863
+ cache.append(position);
242864
+ }
242477
242865
  }
242478
242866
  const messageHashes = this.findMessageHashes(client, 'positions::');
242479
242867
  for (let i = 0; i < messageHashes.length; i++) {
@@ -243459,16 +243847,20 @@ class cex extends _cex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
243459
243847
  // {
243460
243848
  // "e": "history",
243461
243849
  // "data": [
243462
- // "sell:1665467367741:3888551:19058.8:14541219",
243463
- // "buy:1665467367741:1059339:19071.5:14541218",
243850
+ // 'buy:1710255706095:444444:71222.2:14892622'
243851
+ // 'sell:1710255658251:42530:71300:14892621'
243852
+ // 'buy:1710252424241:87913:72800:14892620'
243853
+ // ... timestamp descending
243464
243854
  // ]
243465
243855
  // }
243466
243856
  //
243467
- const data = this.safeValue(message, 'data', []);
243857
+ const data = this.safeList(message, 'data', []);
243468
243858
  const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
243469
243859
  const stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCache */ .ZL(limit);
243470
- for (let i = 0; i < data.length; i++) {
243471
- const rawTrade = data[i];
243860
+ const dataLength = data.length;
243861
+ for (let i = 0; i < dataLength; i++) {
243862
+ const index = dataLength - 1 - i;
243863
+ const rawTrade = data[index];
243472
243864
  const parsed = this.parseWsOldTrade(rawTrade);
243473
243865
  stored.append(parsed);
243474
243866
  }
@@ -249782,7 +250174,7 @@ class cryptocom extends _cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
249782
250174
  const message = this.extend(request, params);
249783
250175
  this.watch(url, messageHash, message, messageHash);
249784
250176
  }
249785
- return future;
250177
+ return await future;
249786
250178
  }
249787
250179
  handlePing(client, message) {
249788
250180
  this.spawn(this.pong, client, message);
@@ -253798,7 +254190,7 @@ class gemini extends _gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
253798
254190
  const orderbook = await this.helperForWatchMultipleConstruct('orderbook', symbols, params);
253799
254191
  return orderbook.limit();
253800
254192
  }
253801
- async watchBidsAsks(symbols, limit = undefined, params = {}) {
254193
+ async watchBidsAsks(symbols = undefined, params = {}) {
253802
254194
  /**
253803
254195
  * @method
253804
254196
  * @name gemini#watchBidsAsks
@@ -254294,7 +254686,8 @@ class gemini extends _gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
254294
254686
  },
254295
254687
  },
254296
254688
  };
254297
- this.options = this.extend(defaultOptions, this.options);
254689
+ // this.options = this.extend (defaultOptions, this.options);
254690
+ this.extendExchangeOptions(defaultOptions);
254298
254691
  const originalHeaders = this.options['ws']['options']['headers'];
254299
254692
  const headers = {
254300
254693
  'X-GEMINI-APIKEY': this.apiKey,
@@ -254432,7 +254825,7 @@ class hitbtc extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
254432
254825
  // }
254433
254826
  //
254434
254827
  }
254435
- return future;
254828
+ return await future;
254436
254829
  }
254437
254830
  async subscribePublic(name, messageHashPrefix, symbols = undefined, params = {}) {
254438
254831
  /**
@@ -258620,7 +259013,7 @@ class htx extends _htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
258620
259013
  };
258621
259014
  this.watch(url, messageHash, request, messageHash, subscription);
258622
259015
  }
258623
- return future;
259016
+ return await future;
258624
259017
  }
258625
259018
  }
258626
259019
 
@@ -269277,7 +269670,7 @@ class okcoin extends _okcoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
269277
269670
  };
269278
269671
  this.spawn(this.watch, url, messageHash, request, messageHash, future);
269279
269672
  }
269280
- return future;
269673
+ return await future;
269281
269674
  }
269282
269675
  async watchBalance(params = {}) {
269283
269676
  /**
@@ -272541,7 +272934,7 @@ class onetrading extends _onetrading_js__WEBPACK_IMPORTED_MODULE_0__/* ["default
272541
272934
  };
272542
272935
  this.watch(url, messageHash, this.extend(request, params), messageHash);
272543
272936
  }
272544
- return future;
272937
+ return await future;
272545
272938
  }
272546
272939
  }
272547
272940
 
@@ -273020,7 +273413,11 @@ class phemex extends _phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
273020
273413
  'watchOrders': true,
273021
273414
  'watchOrderBook': true,
273022
273415
  'watchOHLCV': true,
273023
- 'watchPositions': undefined, // TODO
273416
+ 'watchPositions': undefined,
273417
+ // mutli-endpoints are not supported: https://github.com/ccxt/ccxt/pull/21490
273418
+ 'watchOrderBookForSymbols': false,
273419
+ 'watchTradesForSymbols': false,
273420
+ 'watchOHLCVForSymbols': false,
273024
273421
  },
273025
273422
  'urls': {
273026
273423
  'test': {
@@ -273560,9 +273957,10 @@ class phemex extends _phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
273560
273957
  /**
273561
273958
  * @method
273562
273959
  * @name phemex#watchOrderBook
273960
+ * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Spot-API-en.md#subscribe-orderbook
273563
273961
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#subscribe-orderbook-for-new-model
273564
273962
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#subscribe-30-levels-orderbook
273565
- * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Spot-API-en.md#subscribe-orderbook
273963
+ * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#subscribe-full-orderbook
273566
273964
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
273567
273965
  * @param {string} symbol unified symbol of the market to fetch the order book for
273568
273966
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -279473,6 +279871,15 @@ class woo extends _woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
279473
279871
  return await this.watch(url, messageHash, request, messageHash, subscribe);
279474
279872
  }
279475
279873
  async watchOrderBook(symbol, limit = undefined, params = {}) {
279874
+ /**
279875
+ * @method
279876
+ * @name woo#watchOrderBook
279877
+ * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
279878
+ * @param {string} symbol unified symbol of the market to fetch the order book for
279879
+ * @param {int} [limit] the maximum amount of order book entries to return.
279880
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
279881
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
279882
+ */
279476
279883
  await this.loadMarkets();
279477
279884
  const name = 'orderbook';
279478
279885
  const market = this.market(symbol);
@@ -279522,9 +279929,18 @@ class woo extends _woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
279522
279929
  client.resolve(orderbook, topic);
279523
279930
  }
279524
279931
  async watchTicker(symbol, params = {}) {
279932
+ /**
279933
+ * @method
279934
+ * @name woo#watchTicker
279935
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
279936
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
279937
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
279938
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
279939
+ */
279525
279940
  await this.loadMarkets();
279526
279941
  const name = 'ticker';
279527
279942
  const market = this.market(symbol);
279943
+ symbol = market['symbol'];
279528
279944
  const topic = market['id'] + '@' + name;
279529
279945
  const request = {
279530
279946
  'event': 'subscribe',
@@ -279599,7 +280015,16 @@ class woo extends _woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
279599
280015
  return message;
279600
280016
  }
279601
280017
  async watchTickers(symbols = undefined, params = {}) {
280018
+ /**
280019
+ * @method
280020
+ * @name woo#watchTickers
280021
+ * @description n watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
280022
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
280023
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
280024
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
280025
+ */
279602
280026
  await this.loadMarkets();
280027
+ symbols = this.marketSymbols(symbols);
279603
280028
  const name = 'tickers';
279604
280029
  const topic = name;
279605
280030
  const request = {
@@ -279718,8 +280143,19 @@ class woo extends _woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
279718
280143
  client.resolve(stored, topic);
279719
280144
  }
279720
280145
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
280146
+ /**
280147
+ * @method
280148
+ * @name woo#watchTrades
280149
+ * @description watches information on multiple trades made in a market
280150
+ * @param {string} symbol unified market symbol of the market trades were made in
280151
+ * @param {int} [since] the earliest time in ms to fetch trades for
280152
+ * @param {int} [limit] the maximum number of trade structures to retrieve
280153
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
280154
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
280155
+ */
279721
280156
  await this.loadMarkets();
279722
280157
  const market = this.market(symbol);
280158
+ symbol = market['symbol'];
279723
280159
  const topic = market['id'] + '@trade';
279724
280160
  const request = {
279725
280161
  'event': 'subscribe',
@@ -300861,6 +301297,7 @@ class upbit extends _abstract_upbit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
300861
301297
  '1m': 'minutes',
300862
301298
  '3m': 'minutes',
300863
301299
  '5m': 'minutes',
301300
+ '10m': 'minutes',
300864
301301
  '15m': 'minutes',
300865
301302
  '30m': 'minutes',
300866
301303
  '1h': 'minutes',
@@ -300890,6 +301327,7 @@ class upbit extends _abstract_upbit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
300890
301327
  'candles/minutes/1',
300891
301328
  'candles/minutes/3',
300892
301329
  'candles/minutes/5',
301330
+ 'candles/minutes/10',
300893
301331
  'candles/minutes/15',
300894
301332
  'candles/minutes/30',
300895
301333
  'candles/minutes/60',
@@ -322090,7 +322528,7 @@ SOFTWARE.
322090
322528
 
322091
322529
  //-----------------------------------------------------------------------------
322092
322530
  // this is updated by vss.js when building
322093
- const version = '4.2.78';
322531
+ const version = '4.2.80';
322094
322532
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
322095
322533
  //-----------------------------------------------------------------------------
322096
322534