ccxt 4.5.20 → 4.5.21

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 (71) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/ascendex.js +7 -0
  5. package/dist/cjs/src/base/Exchange.js +6 -0
  6. package/dist/cjs/src/binance.js +1 -0
  7. package/dist/cjs/src/bingx.js +10 -0
  8. package/dist/cjs/src/bitfinex.js +5 -0
  9. package/dist/cjs/src/bitflyer.js +20 -0
  10. package/dist/cjs/src/bitget.js +19 -0
  11. package/dist/cjs/src/bybit.js +12 -6
  12. package/dist/cjs/src/defx.js +1 -0
  13. package/dist/cjs/src/deribit.js +102 -0
  14. package/dist/cjs/src/hyperliquid.js +30 -6
  15. package/dist/cjs/src/pro/bittrade.js +2 -0
  16. package/dist/cjs/src/pro/bybit.js +2 -0
  17. package/dist/cjs/src/pro/cex.js +2 -0
  18. package/dist/cjs/src/pro/coinex.js +2 -0
  19. package/dist/cjs/src/pro/deepcoin.js +2 -0
  20. package/dist/cjs/src/pro/exmo.js +2 -0
  21. package/dist/cjs/src/pro/gate.js +5 -3
  22. package/dist/cjs/src/pro/htx.js +2 -0
  23. package/dist/cjs/src/pro/kraken.js +2 -0
  24. package/dist/cjs/src/pro/kucoin.js +2 -0
  25. package/dist/cjs/src/pro/kucoinfutures.js +2 -0
  26. package/dist/cjs/src/pro/lbank.js +2 -0
  27. package/dist/cjs/src/pro/phemex.js +2 -0
  28. package/dist/cjs/src/pro/upbit.js +24 -13
  29. package/dist/cjs/src/pro/xt.js +10 -9
  30. package/dist/cjs/src/upbit.js +4 -3
  31. package/js/ccxt.d.ts +1 -1
  32. package/js/ccxt.js +1 -1
  33. package/js/src/abstract/binance.d.ts +1 -0
  34. package/js/src/abstract/binancecoinm.d.ts +1 -0
  35. package/js/src/abstract/binanceus.d.ts +1 -0
  36. package/js/src/abstract/binanceusdm.d.ts +1 -0
  37. package/js/src/abstract/bingx.d.ts +10 -0
  38. package/js/src/abstract/bitget.d.ts +19 -0
  39. package/js/src/abstract/upbit.d.ts +2 -1
  40. package/js/src/ascendex.js +7 -0
  41. package/js/src/base/Exchange.d.ts +2 -0
  42. package/js/src/base/Exchange.js +6 -0
  43. package/js/src/binance.js +1 -0
  44. package/js/src/bingx.js +10 -0
  45. package/js/src/bitfinex.js +5 -0
  46. package/js/src/bitflyer.js +20 -0
  47. package/js/src/bitget.js +19 -0
  48. package/js/src/bybit.d.ts +1 -0
  49. package/js/src/bybit.js +12 -6
  50. package/js/src/defx.js +1 -0
  51. package/js/src/deribit.d.ts +11 -0
  52. package/js/src/deribit.js +102 -0
  53. package/js/src/hyperliquid.d.ts +3 -0
  54. package/js/src/hyperliquid.js +30 -6
  55. package/js/src/pro/bittrade.js +2 -0
  56. package/js/src/pro/bybit.js +2 -0
  57. package/js/src/pro/cex.js +2 -0
  58. package/js/src/pro/coinex.js +2 -0
  59. package/js/src/pro/deepcoin.js +2 -0
  60. package/js/src/pro/exmo.js +2 -0
  61. package/js/src/pro/gate.js +5 -3
  62. package/js/src/pro/htx.js +2 -0
  63. package/js/src/pro/kraken.js +2 -0
  64. package/js/src/pro/kucoin.js +2 -0
  65. package/js/src/pro/kucoinfutures.js +2 -0
  66. package/js/src/pro/lbank.js +2 -0
  67. package/js/src/pro/phemex.js +2 -0
  68. package/js/src/pro/upbit.js +24 -13
  69. package/js/src/pro/xt.js +10 -9
  70. package/js/src/upbit.js +4 -3
  71. package/package.json +1 -1
package/dist/cjs/ccxt.js CHANGED
@@ -194,7 +194,7 @@ var xt$1 = require('./src/pro/xt.js');
194
194
 
195
195
  //-----------------------------------------------------------------------------
196
196
  // this is updated by vss.js when building
197
- const version = '4.5.20';
197
+ const version = '4.5.21';
198
198
  Exchange["default"].ccxtVersion = version;
199
199
  const exchanges = {
200
200
  'alpaca': alpaca["default"],
@@ -46,7 +46,12 @@ class ascendex extends ascendex$1["default"] {
46
46
  'fetchAccounts': true,
47
47
  'fetchAllGreeks': false,
48
48
  'fetchBalance': true,
49
+ 'fetchBorrowRate': false,
50
+ 'fetchBorrowRateHistory': false,
51
+ 'fetchBorrowRates': false,
49
52
  'fetchClosedOrders': true,
53
+ 'fetchCrossBorrowRate': false,
54
+ 'fetchCrossBorrowRates': false,
50
55
  'fetchCurrencies': true,
51
56
  'fetchDepositAddress': true,
52
57
  'fetchDepositAddresses': false,
@@ -61,6 +66,8 @@ class ascendex extends ascendex$1["default"] {
61
66
  'fetchFundingRates': true,
62
67
  'fetchGreeks': false,
63
68
  'fetchIndexOHLCV': false,
69
+ 'fetchIsolatedBorrowRate': false,
70
+ 'fetchIsolatedBorrowRates': false,
64
71
  'fetchLeverage': 'emulated',
65
72
  'fetchLeverages': true,
66
73
  'fetchLeverageTiers': true,
@@ -1542,6 +1542,12 @@ class Exchange {
1542
1542
  binaryLength(binary) {
1543
1543
  return binary.length;
1544
1544
  }
1545
+ lockId() {
1546
+ return undefined; // c# stub
1547
+ }
1548
+ unlockId() {
1549
+ return undefined; // c# stub
1550
+ }
1545
1551
  /* eslint-enable */
1546
1552
  // ------------------------------------------------------------------------
1547
1553
  // ########################################################################
@@ -879,6 +879,7 @@ class binance extends binance$1["default"] {
879
879
  'commissionRate': 20,
880
880
  'rateLimit/order': 1,
881
881
  'apiTradingStatus': 1,
882
+ 'symbolAdlRisk': 1,
882
883
  'multiAssetsMargin': 30,
883
884
  // broker endpoints
884
885
  'apiReferral/ifNewUser': 1,
@@ -258,6 +258,7 @@ class bingx extends bingx$1["default"] {
258
258
  'user/marginAssets': 5,
259
259
  },
260
260
  'post': {
261
+ 'trade/amend': 2,
261
262
  'trade/cancelReplace': 2,
262
263
  'positionSide/dual': 5,
263
264
  'trade/batchCancelReplace': 5,
@@ -473,10 +474,19 @@ class bingx extends bingx$1["default"] {
473
474
  'private': {
474
475
  'get': {
475
476
  'swap/trace/currentTrack': 2,
477
+ 'PFutures/traderDetail': 2,
478
+ 'PFutures/profitHistorySummarys': 2,
479
+ 'PFutures/profitDetail': 2,
480
+ 'PFutures/tradingPairs': 2,
481
+ 'spot/traderDetail': 2,
482
+ 'spot/profitHistorySummarys': 2,
483
+ 'spot/profitDetail': 2,
484
+ 'spot/historyOrder': 2,
476
485
  },
477
486
  'post': {
478
487
  'swap/trace/closeTrackOrder': 2,
479
488
  'swap/trace/setTPSL': 2,
489
+ 'PFutures/setCommission': 2,
480
490
  'spot/trader/sellOrder': 10,
481
491
  },
482
492
  },
@@ -50,6 +50,7 @@ class bitfinex extends bitfinex$1["default"] {
50
50
  'createTrailingPercentOrder': false,
51
51
  'createTriggerOrder': true,
52
52
  'editOrder': true,
53
+ 'fetchAllGreeks': false,
53
54
  'fetchBalance': true,
54
55
  'fetchBorrowInterest': false,
55
56
  'fetchBorrowRate': false,
@@ -70,6 +71,7 @@ class bitfinex extends bitfinex$1["default"] {
70
71
  'fetchFundingRate': 'emulated',
71
72
  'fetchFundingRateHistory': true,
72
73
  'fetchFundingRates': true,
74
+ 'fetchGreeks': false,
73
75
  'fetchIndexOHLCV': false,
74
76
  'fetchIsolatedBorrowRate': false,
75
77
  'fetchIsolatedBorrowRates': false,
@@ -87,6 +89,8 @@ class bitfinex extends bitfinex$1["default"] {
87
89
  'fetchOpenInterests': true,
88
90
  'fetchOpenOrder': true,
89
91
  'fetchOpenOrders': true,
92
+ 'fetchOption': false,
93
+ 'fetchOptionChain': false,
90
94
  'fetchOrder': true,
91
95
  'fetchOrderBook': true,
92
96
  'fetchOrderBooks': false,
@@ -102,6 +106,7 @@ class bitfinex extends bitfinex$1["default"] {
102
106
  'fetchTradingFees': true,
103
107
  'fetchTransactionFees': undefined,
104
108
  'fetchTransactions': 'emulated',
109
+ 'fetchVolatilityHistory': false,
105
110
  'reduceMargin': false,
106
111
  'repayCrossMargin': false,
107
112
  'repayIsolatedMargin': false,
@@ -30,20 +30,37 @@ class bitflyer extends bitflyer$1["default"] {
30
30
  'swap': undefined,
31
31
  'future': undefined,
32
32
  'option': false,
33
+ 'borrowCrossMargin': false,
34
+ 'borrowIsolatedMargin': false,
35
+ 'borrowMargin': false,
33
36
  'cancelAllOrders': undefined,
34
37
  'cancelOrder': true,
35
38
  'createOrder': true,
39
+ 'fetchAllGreeks': false,
36
40
  'fetchBalance': true,
41
+ 'fetchBorrowInterest': false,
42
+ 'fetchBorrowRate': false,
43
+ 'fetchBorrowRateHistories': false,
44
+ 'fetchBorrowRateHistory': false,
45
+ 'fetchBorrowRates': false,
46
+ 'fetchBorrowRatesPerSymbol': false,
37
47
  'fetchClosedOrders': 'emulated',
48
+ 'fetchCrossBorrowRate': false,
49
+ 'fetchCrossBorrowRates': false,
38
50
  'fetchCurrencies': false,
39
51
  'fetchDeposits': true,
40
52
  'fetchFundingRate': true,
41
53
  'fetchFundingRateHistory': false,
42
54
  'fetchFundingRates': false,
55
+ 'fetchGreeks': false,
56
+ 'fetchIsolatedBorrowRate': false,
57
+ 'fetchIsolatedBorrowRates': false,
43
58
  'fetchMarginMode': false,
44
59
  'fetchMarkets': true,
45
60
  'fetchMyTrades': true,
46
61
  'fetchOpenOrders': 'emulated',
62
+ 'fetchOption': false,
63
+ 'fetchOptionChain': false,
47
64
  'fetchOrder': 'emulated',
48
65
  'fetchOrderBook': true,
49
66
  'fetchOrders': true,
@@ -55,7 +72,10 @@ class bitflyer extends bitflyer$1["default"] {
55
72
  'fetchTradingFees': false,
56
73
  'fetchTransfer': false,
57
74
  'fetchTransfers': false,
75
+ 'fetchVolatilityHistory': false,
58
76
  'fetchWithdrawals': true,
77
+ 'repayCrossMargin': false,
78
+ 'repayIsolatedMargin': false,
59
79
  'transfer': false,
60
80
  'withdraw': true,
61
81
  },
@@ -256,6 +256,9 @@ class bitget extends bitget$1["default"] {
256
256
  'mix/v1/market/history-mark-candles': 1,
257
257
  'mix/v1/market/merge-depth': 1,
258
258
  'v2/mix/market/vip-fee-rate': 2,
259
+ 'v2/mix/market/union-interest-rate-history': 4,
260
+ 'v2/mix/market/exchange-rate': 4,
261
+ 'v2/mix/market/discount-rate': 4,
259
262
  'v2/mix/market/merge-depth': 1,
260
263
  'v2/mix/market/ticker': 1,
261
264
  'v2/mix/market/tickers': 1,
@@ -270,6 +273,7 @@ class bitget extends bitget$1["default"] {
270
273
  'v2/mix/market/symbol-price': 1,
271
274
  'v2/mix/market/history-fund-rate': 1,
272
275
  'v2/mix/market/current-fund-rate': 1,
276
+ 'v2/mix/market/oi-limit': 2,
273
277
  'v2/mix/market/contracts': 1,
274
278
  'v2/mix/market/query-position-lever': 2,
275
279
  'v2/mix/market/account-long-short': 20,
@@ -452,17 +456,26 @@ class bitget extends bitget$1["default"] {
452
456
  'v2/mix/account/account': 2,
453
457
  'v2/mix/account/accounts': 2,
454
458
  'v2/mix/account/sub-account-assets': 200,
459
+ 'v2/mix/account/interest-history': 4,
460
+ 'v2/mix/account/max-open': 1,
461
+ 'v2/mix/account/liq-price': 1,
455
462
  'v2/mix/account/open-count': 2,
456
463
  'v2/mix/account/bill': 2,
464
+ 'v2/mix/account/transfer-limits': 20,
465
+ 'v2/mix/account/union-config': 20,
466
+ 'v2/mix/account/switch-union-usdt': 20,
467
+ 'v2/mix/account/isolated-symbols': 2,
457
468
  'v2/mix/market/query-position-lever': 2,
458
469
  'v2/mix/position/single-position': 2,
459
470
  'v2/mix/position/all-position': 4,
471
+ 'v2/mix/position/adlRank': 4,
460
472
  'v2/mix/position/history-position': 1,
461
473
  'v2/mix/order/detail': 2,
462
474
  'v2/mix/order/fills': 2,
463
475
  'v2/mix/order/fill-history': 2,
464
476
  'v2/mix/order/orders-pending': 2,
465
477
  'v2/mix/order/orders-history': 2,
478
+ 'v2/mix/order/plan-sub-order': 2,
466
479
  'v2/mix/order/orders-plan-pending': 2,
467
480
  'v2/mix/order/orders-plan-history': 2,
468
481
  'v2/mix/market/position-long-short': 20,
@@ -510,9 +523,13 @@ class bitget extends bitget$1["default"] {
510
523
  'mix/v1/trace/report/order/currentList': 2,
511
524
  'mix/v1/trace/queryTraderTpslRatioConfig': 2,
512
525
  'mix/v1/trace/traderUpdateTpslRatioConfig': 2,
526
+ 'v2/mix/account/set-auto-margin': 4,
513
527
  'v2/mix/account/set-leverage': 4,
528
+ 'v2/mix/account/set-all-leverage': 4,
514
529
  'v2/mix/account/set-margin': 4,
530
+ 'v2/mix/account/set-asset-mode': 10,
515
531
  'v2/mix/account/set-margin-mode': 4,
532
+ 'v2/mix/account/union-convert': 20,
516
533
  'v2/mix/account/set-position-mode': 4,
517
534
  'v2/mix/order/place-order': 2,
518
535
  'v2/mix/order/click-backhand': 20,
@@ -521,7 +538,9 @@ class bitget extends bitget$1["default"] {
521
538
  'v2/mix/order/cancel-order': 2,
522
539
  'v2/mix/order/batch-cancel-orders': 2,
523
540
  'v2/mix/order/close-positions': 20,
541
+ 'v2/mix/order/cancel-all-orders': 20,
524
542
  'v2/mix/order/place-tpsl-order': 2,
543
+ 'v2/mix/order/place-pos-tpsl': 2,
525
544
  'v2/mix/order/place-plan-order': 2,
526
545
  'v2/mix/order/modify-tpsl-order': 2,
527
546
  'v2/mix/order/modify-plan-order': 2,
@@ -4385,7 +4385,7 @@ class bybit extends bybit$1["default"] {
4385
4385
  const market = this.market(symbol);
4386
4386
  const request = {
4387
4387
  'symbol': market['id'],
4388
- 'orderId': id,
4388
+ // 'orderId': id,
4389
4389
  // 'orderLinkId': 'string', // unique client order id, max 36 characters
4390
4390
  // 'takeProfit': 123.45, // take profit price, only take effect upon opening the position
4391
4391
  // 'stopLoss': 123.45, // stop loss price, only take effect upon opening the position
@@ -4396,6 +4396,13 @@ class bybit extends bybit$1["default"] {
4396
4396
  // Valid for option only.
4397
4397
  // 'orderIv': '0', // Implied volatility; parameters are passed according to the real value; for example, for 10%, 0.1 is passed
4398
4398
  };
4399
+ const clientOrderId = this.safeString2(params, 'orderLinkId', 'clientOrderId');
4400
+ if (clientOrderId === undefined) {
4401
+ request['orderId'] = id;
4402
+ }
4403
+ else {
4404
+ request['orderLinkId'] = clientOrderId;
4405
+ }
4399
4406
  let category = undefined;
4400
4407
  [category, params] = this.getBybitType('editOrderRequest', market, params);
4401
4408
  request['category'] = category;
@@ -4439,10 +4446,6 @@ class bybit extends bybit$1["default"] {
4439
4446
  request['tpTriggerBy'] = tpTriggerBy;
4440
4447
  }
4441
4448
  }
4442
- const clientOrderId = this.safeString(params, 'clientOrderId');
4443
- if (clientOrderId !== undefined) {
4444
- request['orderLinkId'] = clientOrderId;
4445
- }
4446
4449
  params = this.omit(params, ['stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerPrice', 'clientOrderId', 'stopLoss', 'takeProfit']);
4447
4450
  return request;
4448
4451
  }
@@ -4460,6 +4463,7 @@ class bybit extends bybit$1["default"] {
4460
4463
  * @param {float} amount how much of currency you want to trade in units of base currency
4461
4464
  * @param {float} price the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
4462
4465
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4466
+ * @param {string} [params.clientOrderId] unique client order id
4463
4467
  * @param {float} [params.triggerPrice] The price that a trigger order is triggered at
4464
4468
  * @param {float} [params.stopLossPrice] The price that a stop loss order is triggered at
4465
4469
  * @param {float} [params.takeProfitPrice] The price that a take profit order is triggered at
@@ -4477,6 +4481,7 @@ class bybit extends bybit$1["default"] {
4477
4481
  if (symbol === undefined) {
4478
4482
  throw new errors.ArgumentsRequired(this.id + ' editOrder() requires a symbol argument');
4479
4483
  }
4484
+ const market = this.market(symbol);
4480
4485
  const request = this.editOrderRequest(id, symbol, type, side, amount, price, params);
4481
4486
  const response = await this.privatePostV5OrderAmend(this.extend(request, params));
4482
4487
  //
@@ -4495,7 +4500,8 @@ class bybit extends bybit$1["default"] {
4495
4500
  return this.safeOrder({
4496
4501
  'info': response,
4497
4502
  'id': this.safeString(result, 'orderId'),
4498
- });
4503
+ 'clientOrderId': this.safeString(result, 'orderLinkId'),
4504
+ }, market);
4499
4505
  }
4500
4506
  /**
4501
4507
  * @method
@@ -343,6 +343,7 @@ class defx extends defx$1["default"] {
343
343
  'exact': {
344
344
  '404': errors.BadRequest,
345
345
  'missing_auth_signature': errors.AuthenticationError,
346
+ 'leverage_higher_than_capped_leverage': errors.BadRequest,
346
347
  'order_rejected': errors.InvalidOrder,
347
348
  'invalid_order_id': errors.InvalidOrder,
348
349
  'filter_lotsize_maxqty': errors.InvalidOrder,
@@ -75,6 +75,8 @@ class deribit extends deribit$1["default"] {
75
75
  'fetchMyTrades': true,
76
76
  'fetchOHLCV': true,
77
77
  'fetchOpenOrders': true,
78
+ 'fetchOpenInterest': true,
79
+ 'fetchOpenInterests': false,
78
80
  'fetchOption': true,
79
81
  'fetchOptionChain': true,
80
82
  'fetchOrder': true,
@@ -3740,6 +3742,106 @@ class deribit extends deribit$1["default"] {
3740
3742
  'quoteVolume': this.safeNumber(chain, 'volume_usd'),
3741
3743
  };
3742
3744
  }
3745
+ /**
3746
+ * @method
3747
+ * @name deribit#fetchOpenInterest
3748
+ * @description Retrieves the open interest of a symbol
3749
+ * @see https://docs.deribit.com/?shell#public-get_book_summary_by_instrument
3750
+ * @param {string} symbol unified CCXT market symbol
3751
+ * @param {object} [params] exchange specific parameters
3752
+ * @returns {object} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure}
3753
+ */
3754
+ async fetchOpenInterest(symbol, params = {}) {
3755
+ await this.loadMarkets();
3756
+ const market = this.market(symbol);
3757
+ if (!market['contract']) {
3758
+ throw new errors.BadRequest(this.id + ' fetchOpenInterest() supports contract markets only');
3759
+ }
3760
+ const request = {
3761
+ 'instrument_name': market['id'],
3762
+ };
3763
+ const response = await this.publicGetGetBookSummaryByInstrument(this.extend(request, params));
3764
+ //
3765
+ // {
3766
+ // "jsonrpc": "2.0",
3767
+ // "result": [
3768
+ // {
3769
+ // "high": 93099.5,
3770
+ // "low": 81773.0,
3771
+ // "last": 87197.0,
3772
+ // "instrument_name": "BTC-PERPETUAL",
3773
+ // "bid_price": 87083.0,
3774
+ // "ask_price": 87149.5,
3775
+ // "open_interest": 9978911260,
3776
+ // "mark_price": 87102.01,
3777
+ // "creation_timestamp": 1763674177068,
3778
+ // "price_change": -3.2032,
3779
+ // "volume": 7377.18657991,
3780
+ // "estimated_delivery_price": 87047.2,
3781
+ // "base_currency": "BTC",
3782
+ // "quote_currency": "USD",
3783
+ // "volume_usd": 661040250.0,
3784
+ // "volume_notional": 661040250.0,
3785
+ // "current_funding": 1.2966e-4,
3786
+ // "funding_8h": -8.1069e-4,
3787
+ // "mid_price": 87116.25
3788
+ // }
3789
+ // ],
3790
+ // "usIn": 1763674177068845,
3791
+ // "usOut": 1763674177068996,
3792
+ // "usDiff": 151,
3793
+ // "testnet": true
3794
+ // }
3795
+ //
3796
+ const result = this.safeList(response, 'result', []);
3797
+ const data = this.safeDict(result, 0, {});
3798
+ return this.parseOpenInterest(data, market);
3799
+ }
3800
+ parseOpenInterest(interest, market = undefined) {
3801
+ //
3802
+ // {
3803
+ // "high": 93099.5,
3804
+ // "low": 81773.0,
3805
+ // "last": 87197.0,
3806
+ // "instrument_name": "BTC-PERPETUAL",
3807
+ // "bid_price": 87083.0,
3808
+ // "ask_price": 87149.5,
3809
+ // "open_interest": 9978911260,
3810
+ // "mark_price": 87102.01,
3811
+ // "creation_timestamp": 1763674177068,
3812
+ // "price_change": -3.2032,
3813
+ // "volume": 7377.18657991,
3814
+ // "estimated_delivery_price": 87047.2,
3815
+ // "base_currency": "BTC",
3816
+ // "quote_currency": "USD",
3817
+ // "volume_usd": 661040250.0,
3818
+ // "volume_notional": 661040250.0,
3819
+ // "current_funding": 1.2966e-4,
3820
+ // "funding_8h": -8.1069e-4,
3821
+ // "mid_price": 87116.25
3822
+ // }
3823
+ //
3824
+ const timestamp = this.safeInteger(interest, 'creation_timestamp');
3825
+ const marketId = this.safeString(interest, 'instrument_name');
3826
+ market = this.safeMarket(marketId, market);
3827
+ const openInterest = this.safeNumber(interest, 'open_interest');
3828
+ let openInterestAmount = undefined;
3829
+ let openInterestValue = undefined;
3830
+ if (market['option'] || (market['future'] && market['linear'])) {
3831
+ openInterestAmount = openInterest;
3832
+ }
3833
+ else {
3834
+ openInterestValue = openInterest;
3835
+ }
3836
+ return this.safeOpenInterest({
3837
+ 'symbol': this.safeSymbol(marketId, market),
3838
+ 'openInterestAmount': openInterestAmount,
3839
+ 'openInterestValue': openInterestValue,
3840
+ 'timestamp': timestamp,
3841
+ 'datetime': this.iso8601(timestamp),
3842
+ 'info': interest,
3843
+ }, market);
3844
+ }
3743
3845
  nonce() {
3744
3846
  return this.milliseconds();
3745
3847
  }
@@ -2551,6 +2551,15 @@ class hyperliquid extends hyperliquid$1["default"] {
2551
2551
  const sorted = this.sortBy(result, 'timestamp');
2552
2552
  return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
2553
2553
  }
2554
+ getDexFromHip3Symbol(market) {
2555
+ const baseName = this.safeString(market, 'baseName', '');
2556
+ const part = baseName.split(':');
2557
+ const partsLength = part.length;
2558
+ if (partsLength > 1) {
2559
+ return this.safeString(part, 0);
2560
+ }
2561
+ return undefined;
2562
+ }
2554
2563
  /**
2555
2564
  * @method
2556
2565
  * @name hyperliquid#fetchOpenOrders
@@ -2580,11 +2589,9 @@ class hyperliquid extends hyperliquid$1["default"] {
2580
2589
  if (symbol !== undefined) {
2581
2590
  market = this.market(symbol);
2582
2591
  // check if is hip3 symbol
2583
- const baseName = this.safeString(market, 'baseName', '');
2584
- const part = baseName.split(':');
2585
- const partsLength = part.length;
2586
- if (partsLength > 1) {
2587
- request['dex'] = this.safeString(part, 0);
2592
+ const dexName = this.getDexFromHip3Symbol(market);
2593
+ if (dexName !== undefined) {
2594
+ request['dex'] = dexName;
2588
2595
  }
2589
2596
  }
2590
2597
  const response = await this.publicPostInfo(this.extend(request, params));
@@ -2673,17 +2680,26 @@ class hyperliquid extends hyperliquid$1["default"] {
2673
2680
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2674
2681
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
2675
2682
  * @param {string} [params.subAccountAddress] sub account user address
2683
+ * @param {string} [params.dex] perp dex name. default is null
2676
2684
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2677
2685
  */
2678
2686
  async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2679
2687
  let userAddress = undefined;
2680
2688
  [userAddress, params] = this.handlePublicAddress('fetchOrders', params);
2681
2689
  await this.loadMarkets();
2682
- const market = this.safeMarket(symbol);
2690
+ let market = undefined;
2683
2691
  const request = {
2684
2692
  'type': 'historicalOrders',
2685
2693
  'user': userAddress,
2686
2694
  };
2695
+ if (symbol !== undefined) {
2696
+ market = this.market(symbol);
2697
+ // check if is hip3 symbol
2698
+ const dexName = this.getDexFromHip3Symbol(market);
2699
+ if (dexName !== undefined) {
2700
+ request['dex'] = dexName;
2701
+ }
2702
+ }
2687
2703
  const response = await this.publicPostInfo(this.extend(request, params));
2688
2704
  //
2689
2705
  // [
@@ -3087,6 +3103,7 @@ class hyperliquid extends hyperliquid$1["default"] {
3087
3103
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3088
3104
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
3089
3105
  * @param {string} [params.subAccountAddress] sub account user address
3106
+ * @param {string} [params.dex] perp dex name, eg: XYZ
3090
3107
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
3091
3108
  */
3092
3109
  async fetchPositions(symbols = undefined, params = {}) {
@@ -3098,6 +3115,13 @@ class hyperliquid extends hyperliquid$1["default"] {
3098
3115
  'type': 'clearinghouseState',
3099
3116
  'user': userAddress,
3100
3117
  };
3118
+ if (symbols !== undefined) {
3119
+ const market = this.market(symbols[0]);
3120
+ const dexName = this.getDexFromHip3Symbol(market);
3121
+ if (dexName !== undefined) {
3122
+ request['dex'] = dexName;
3123
+ }
3124
+ }
3101
3125
  const response = await this.publicPostInfo(this.extend(request, params));
3102
3126
  //
3103
3127
  // {
@@ -42,8 +42,10 @@ class bittrade extends bittrade$1["default"] {
42
42
  });
43
43
  }
44
44
  requestId() {
45
+ this.lockId();
45
46
  const requestId = this.sum(this.safeInteger(this.options, 'requestId', 0), 1);
46
47
  this.options['requestId'] = requestId;
48
+ this.unlockId();
47
49
  return requestId.toString();
48
50
  }
49
51
  /**
@@ -167,8 +167,10 @@ class bybit extends bybit$1["default"] {
167
167
  });
168
168
  }
169
169
  requestId() {
170
+ this.lockId();
170
171
  const requestId = this.sum(this.safeInteger(this.options, 'requestId', 0), 1);
171
172
  this.options['requestId'] = requestId;
173
+ this.unlockId();
172
174
  return requestId;
173
175
  }
174
176
  async getUrlByMarketType(symbol = undefined, isPrivate = false, method = undefined, params = {}) {
@@ -47,8 +47,10 @@ class cex extends cex$1["default"] {
47
47
  });
48
48
  }
49
49
  requestId() {
50
+ this.lockId();
50
51
  const requestId = this.sum(this.safeInteger(this.options, 'requestId', 0), 1);
51
52
  this.options['requestId'] = requestId;
53
+ this.unlockId();
52
54
  return requestId.toString();
53
55
  }
54
56
  /**
@@ -87,8 +87,10 @@ class coinex extends coinex$1["default"] {
87
87
  });
88
88
  }
89
89
  requestId() {
90
+ this.lockId();
90
91
  const requestId = this.sum(this.safeInteger(this.options, 'requestId', 0), 1);
91
92
  this.options['requestId'] = requestId;
93
+ this.unlockId();
92
94
  return requestId;
93
95
  }
94
96
  handleTicker(client, message) {
@@ -94,9 +94,11 @@ class deepcoin extends deepcoin$1["default"] {
94
94
  return message;
95
95
  }
96
96
  requestId() {
97
+ this.lockId();
97
98
  const previousValue = this.safeInteger(this.options, 'lastRequestId', 0);
98
99
  const newValue = this.sum(previousValue, 1);
99
100
  this.options['lastRequestId'] = newValue;
101
+ this.unlockId();
100
102
  return newValue;
101
103
  }
102
104
  createPublicRequest(market, requestId, topicID, suffix = '', unWatch = false) {
@@ -38,8 +38,10 @@ class exmo extends exmo$1["default"] {
38
38
  });
39
39
  }
40
40
  requestId() {
41
+ this.lockId();
41
42
  const requestId = this.sum(this.safeInteger(this.options, 'requestId', 0), 1);
42
43
  this.options['requestId'] = requestId;
44
+ this.unlockId();
43
45
  return requestId;
44
46
  }
45
47
  /**
@@ -885,8 +885,8 @@ class gate extends gate$1["default"] {
885
885
  const ohlcv = result[i];
886
886
  const subscription = this.safeString(ohlcv, 'n', '');
887
887
  const parts = subscription.split('_');
888
- const timeframe = this.safeString(parts, 0);
889
- const timeframeId = this.findTimeframe(timeframe);
888
+ const timeframeId = this.safeString(parts, 0);
889
+ const timeframe = this.findTimeframe(timeframeId);
890
890
  const prefix = timeframe + '_';
891
891
  const marketId = subscription.replace(prefix, '');
892
892
  const symbol = this.safeSymbol(marketId, undefined, '_', marketType);
@@ -896,7 +896,7 @@ class gate extends gate$1["default"] {
896
896
  if (stored === undefined) {
897
897
  const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
898
898
  stored = new Cache.ArrayCacheByTimestamp(limit);
899
- this.ohlcvs[symbol][timeframeId] = stored;
899
+ this.ohlcvs[symbol][timeframe] = stored;
900
900
  }
901
901
  stored.append(parsed);
902
902
  marketIds[symbol] = timeframe;
@@ -1963,8 +1963,10 @@ class gate extends gate$1["default"] {
1963
1963
  }
1964
1964
  requestId() {
1965
1965
  // their support said that reqid must be an int32, not documented
1966
+ this.lockId();
1966
1967
  const reqid = this.sum(this.safeInteger(this.options, 'reqid', 0), 1);
1967
1968
  this.options['reqid'] = reqid;
1969
+ this.unlockId();
1968
1970
  return reqid;
1969
1971
  }
1970
1972
  async subscribePublic(url, messageHash, payload, channel, params = {}, subscription = undefined) {
@@ -130,8 +130,10 @@ class htx extends htx$1["default"] {
130
130
  });
131
131
  }
132
132
  requestId() {
133
+ this.lockId();
133
134
  const requestId = this.sum(this.safeInteger(this.options, 'requestId', 0), 1);
134
135
  this.options['requestId'] = requestId;
136
+ this.unlockId();
135
137
  return requestId.toString();
136
138
  }
137
139
  /**
@@ -647,8 +647,10 @@ class kraken extends kraken$1["default"] {
647
647
  }
648
648
  requestId() {
649
649
  // their support said that reqid must be an int32, not documented
650
+ this.lockId();
650
651
  const reqid = this.sum(this.safeInteger(this.options, 'reqid', 0), 1);
651
652
  this.options['reqid'] = reqid;
653
+ this.unlockId();
652
654
  return reqid;
653
655
  }
654
656
  /**
@@ -124,8 +124,10 @@ class kucoin extends kucoin$1["default"] {
124
124
  return undefined;
125
125
  }
126
126
  requestId() {
127
+ this.lockId();
127
128
  const requestId = this.sum(this.safeInteger(this.options, 'requestId', 0), 1);
128
129
  this.options['requestId'] = requestId;
130
+ this.unlockId();
129
131
  return requestId;
130
132
  }
131
133
  async subscribe(url, messageHash, subscriptionHash, params = {}, subscription = undefined) {