ccxt 4.5.38 → 4.5.40

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 (117) hide show
  1. package/README.md +5 -7
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -6
  4. package/dist/cjs/src/base/Exchange.js +62 -5
  5. package/dist/cjs/src/binance.js +151 -2
  6. package/dist/cjs/src/bingx.js +137 -120
  7. package/dist/cjs/src/bitget.js +47 -1
  8. package/dist/cjs/src/bitmart.js +23 -8
  9. package/dist/cjs/src/bitmex.js +416 -0
  10. package/dist/cjs/src/bitstamp.js +264 -43
  11. package/dist/cjs/src/bitvavo.js +10 -0
  12. package/dist/cjs/src/blofin.js +85 -0
  13. package/dist/cjs/src/btcmarkets.js +1 -1
  14. package/dist/cjs/src/bybit.js +135 -0
  15. package/dist/cjs/src/coinspot.js +77 -7
  16. package/dist/cjs/src/delta.js +367 -0
  17. package/dist/cjs/src/htx.js +265 -2
  18. package/dist/cjs/src/hyperliquid.js +37 -8
  19. package/dist/cjs/src/krakenfutures.js +4 -0
  20. package/dist/cjs/src/kucoinfutures.js +121 -0
  21. package/dist/cjs/src/mexc.js +9 -1
  22. package/dist/cjs/src/phemex.js +359 -0
  23. package/dist/cjs/src/poloniex.js +5 -0
  24. package/dist/cjs/src/pro/binance.js +111 -26
  25. package/dist/cjs/src/pro/bingx.js +33 -33
  26. package/dist/cjs/src/pro/bitget.js +48 -90
  27. package/dist/cjs/src/pro/bitmart.js +68 -0
  28. package/dist/cjs/src/pro/blofin.js +52 -1
  29. package/dist/cjs/src/pro/bybit.js +2 -2
  30. package/dist/cjs/src/pro/coinbaseinternational.js +5 -2
  31. package/dist/cjs/src/pro/mexc.js +72 -0
  32. package/dist/cjs/src/pro/okx.js +8 -5
  33. package/dist/cjs/src/pro/paradex.js +137 -0
  34. package/dist/cjs/src/pro/woo.js +43 -0
  35. package/dist/cjs/src/tokocrypto.js +23 -0
  36. package/dist/cjs/src/toobit.js +20 -0
  37. package/dist/cjs/src/whitebit.js +11 -10
  38. package/dist/cjs/src/woo.js +103 -3
  39. package/js/ccxt.d.ts +3 -9
  40. package/js/ccxt.js +2 -6
  41. package/js/src/abstract/binance.d.ts +5 -0
  42. package/js/src/abstract/binancecoinm.d.ts +5 -0
  43. package/js/src/abstract/binanceus.d.ts +5 -0
  44. package/js/src/abstract/binanceusdm.d.ts +5 -0
  45. package/js/src/abstract/bitget.d.ts +47 -1
  46. package/js/src/abstract/bitstamp.d.ts +1 -1
  47. package/js/src/abstract/bitvavo.d.ts +10 -0
  48. package/js/src/abstract/coinspot.d.ts +45 -0
  49. package/js/src/base/Exchange.d.ts +11 -8
  50. package/js/src/base/Exchange.js +65 -5
  51. package/js/src/base/types.d.ts +9 -0
  52. package/js/src/binance.d.ts +26 -1
  53. package/js/src/binance.js +151 -2
  54. package/js/src/bingx.d.ts +113 -108
  55. package/js/src/bingx.js +137 -120
  56. package/js/src/bitget.js +47 -1
  57. package/js/src/bitmart.js +23 -8
  58. package/js/src/bitmex.d.ts +50 -1
  59. package/js/src/bitmex.js +416 -0
  60. package/js/src/bitstamp.d.ts +52 -1
  61. package/js/src/bitstamp.js +264 -43
  62. package/js/src/bitvavo.js +10 -0
  63. package/js/src/blofin.d.ts +12 -1
  64. package/js/src/blofin.js +85 -0
  65. package/js/src/btcmarkets.js +1 -1
  66. package/js/src/bybit.d.ts +12 -1
  67. package/js/src/bybit.js +135 -0
  68. package/js/src/coinspot.js +77 -7
  69. package/js/src/delta.d.ts +12 -1
  70. package/js/src/delta.js +367 -0
  71. package/js/src/htx.d.ts +15 -1
  72. package/js/src/htx.js +265 -2
  73. package/js/src/hyperliquid.js +37 -8
  74. package/js/src/krakenfutures.js +4 -0
  75. package/js/src/kucoinfutures.d.ts +12 -1
  76. package/js/src/kucoinfutures.js +121 -0
  77. package/js/src/mexc.js +9 -1
  78. package/js/src/phemex.d.ts +16 -1
  79. package/js/src/phemex.js +359 -0
  80. package/js/src/poloniex.js +5 -0
  81. package/js/src/pro/binance.d.ts +13 -0
  82. package/js/src/pro/binance.js +111 -26
  83. package/js/src/pro/bingx.d.ts +33 -33
  84. package/js/src/pro/bingx.js +33 -33
  85. package/js/src/pro/bitget.d.ts +6 -6
  86. package/js/src/pro/bitget.js +48 -90
  87. package/js/src/pro/bitmart.d.ts +22 -1
  88. package/js/src/pro/bitmart.js +69 -1
  89. package/js/src/pro/blofin.d.ts +12 -1
  90. package/js/src/pro/blofin.js +52 -1
  91. package/js/src/pro/bybit.d.ts +1 -1
  92. package/js/src/pro/bybit.js +2 -2
  93. package/js/src/pro/coinbaseinternational.d.ts +2 -2
  94. package/js/src/pro/coinbaseinternational.js +6 -3
  95. package/js/src/pro/mexc.d.ts +22 -1
  96. package/js/src/pro/mexc.js +72 -0
  97. package/js/src/pro/okx.d.ts +4 -4
  98. package/js/src/pro/okx.js +8 -5
  99. package/js/src/pro/paradex.d.ts +23 -1
  100. package/js/src/pro/paradex.js +137 -0
  101. package/js/src/pro/woo.d.ts +12 -1
  102. package/js/src/pro/woo.js +43 -0
  103. package/js/src/tokocrypto.js +23 -0
  104. package/js/src/toobit.js +20 -0
  105. package/js/src/whitebit.js +8 -8
  106. package/js/src/woo.d.ts +12 -1
  107. package/js/src/woo.js +103 -3
  108. package/package.json +1 -1
  109. package/dist/cjs/src/abstract/probit.js +0 -11
  110. package/dist/cjs/src/pro/probit.js +0 -594
  111. package/dist/cjs/src/probit.js +0 -1936
  112. package/js/src/abstract/probit.d.ts +0 -26
  113. package/js/src/abstract/probit.js +0 -11
  114. package/js/src/pro/probit.d.ts +0 -91
  115. package/js/src/pro/probit.js +0 -593
  116. package/js/src/probit.d.ts +0 -283
  117. package/js/src/probit.js +0 -1935
@@ -302,6 +302,7 @@ class bitget extends bitget$1["default"] {
302
302
  'v3/market/tickers': 1,
303
303
  'v3/market/orderbook': 1,
304
304
  'v3/market/fills': 1,
305
+ 'v3/market/proof-of-reserves': 1,
305
306
  'v3/market/open-interest': 1,
306
307
  'v3/market/candles': 1,
307
308
  'v3/market/history-candles': 1,
@@ -312,6 +313,7 @@ class bitget extends bitget$1["default"] {
312
313
  'v3/market/margin-loans': 1,
313
314
  'v3/market/position-tier': 1,
314
315
  'v3/market/oi-limit': 2,
316
+ 'v3/market/index-components': 2,
315
317
  },
316
318
  },
317
319
  },
@@ -349,6 +351,7 @@ class bitget extends bitget$1["default"] {
349
351
  'v2/spot/wallet/deposit-address': 2,
350
352
  'v2/spot/wallet/deposit-records': 2,
351
353
  'v2/spot/wallet/withdrawal-records': 2,
354
+ 'v2/spot/account/upgrade-status': 20,
352
355
  },
353
356
  'post': {
354
357
  'spot/v1/wallet/transfer': 4,
@@ -418,6 +421,7 @@ class bitget extends bitget$1["default"] {
418
421
  'v2/spot/wallet/withdrawal': 2,
419
422
  'v2/spot/wallet/cancel-withdrawal': 2,
420
423
  'v2/spot/wallet/modify-deposit-account': 2,
424
+ 'v2/spot/account/upgrade': 20,
421
425
  },
422
426
  },
423
427
  'mix': {
@@ -826,14 +830,29 @@ class bitget extends bitget$1["default"] {
826
830
  'uta': {
827
831
  'get': {
828
832
  'v3/account/assets': 1,
833
+ 'v3/account/funding-assets': 1,
829
834
  'v3/account/settings': 1,
830
- 'v3/account/deposit-records': 2,
831
835
  'v3/account/financial-records': 1,
832
836
  'v3/account/repayable-coins': 2,
833
837
  'v3/account/payment-coins': 2,
834
838
  'v3/account/convert-records': 1,
839
+ 'v3/account/deduct-info': 20,
840
+ 'v3/account/fee-rate': 6.6667,
841
+ 'v3/account/switch-status': 4,
842
+ 'v3/account/max-transferable': 6.6667,
843
+ 'v3/account/open-interest-limit': 4,
844
+ 'v3/account/sub-unified-assets': 20,
835
845
  'v3/account/transferable-coins': 2,
836
846
  'v3/account/sub-transfer-record': 4,
847
+ 'v3/account/deposit-address': 2,
848
+ 'v3/account/sub-deposit-address': 2,
849
+ 'v3/account/deposit-records': 2,
850
+ 'v3/account/sub-deposit-records': 2,
851
+ 'v3/account/withdrawal-records': 2,
852
+ 'v3/broker/sub-list': 1,
853
+ 'v3/broker/all-sub-deposit-withdrawal': 1,
854
+ 'v3/broker/commission': 1,
855
+ 'v3/broker/query-sub-apikey': 1,
837
856
  'v3/ins-loan/transfered': 6.6667,
838
857
  'v3/ins-loan/symbols': 6.6667,
839
858
  'v3/ins-loan/risk-unit': 6.6667,
@@ -842,8 +861,18 @@ class bitget extends bitget$1["default"] {
842
861
  'v3/ins-loan/loan-order': 6.6667,
843
862
  'v3/ins-loan/ltv-convert': 6.6667,
844
863
  'v3/ins-loan/ensure-coins-convert': 6.6667,
864
+ 'v3/loan/coins': 2,
865
+ 'v3/loan/interest': 2,
866
+ 'v3/loan/borrow-ongoing': 2,
867
+ 'v3/loan/borrow-history': 2,
868
+ 'v3/loan/repay-history': 2,
869
+ 'v3/loan/pledge-rate-history': 2,
870
+ 'v3/loan/debts': 2,
871
+ 'v3/loan/reduces': 2,
845
872
  'v3/position/current-position': 1,
846
873
  'v3/position/history-position': 1,
874
+ 'v3/position/adlRank': 20,
875
+ 'v3/tax/records': 20,
847
876
  'v3/trade/order-info': 1,
848
877
  'v3/trade/unfilled-orders': 1,
849
878
  'v3/trade/unfilled-strategy-orders': 1,
@@ -857,10 +886,26 @@ class bitget extends bitget$1["default"] {
857
886
  'v3/account/set-leverage': 2,
858
887
  'v3/account/set-hold-mode': 2,
859
888
  'v3/account/repay': 4,
889
+ 'v3/account/switch-deduct': 20,
890
+ 'v3/account/deposit-account': 20,
891
+ 'v3/account/switch': 20,
892
+ 'v3/account/adjust-account-mode': 20,
860
893
  'v3/account/transfer': 4,
861
894
  'v3/account/sub-transfer': 4,
895
+ 'v3/account/sub-master-transfer': 4,
862
896
  'v3/account/max-open-available': 4,
897
+ 'v3/account/withdrawal': 20,
898
+ 'v3/broker/create-sub': 1,
899
+ 'v3/broker/modify-sub': 1,
900
+ 'v3/broker/sub-withdrawal': 1,
901
+ 'v3/broker/sub-deposit-address': 1,
902
+ 'v3/broker/create-sub-apikey': 1,
903
+ 'v3/broker/modify-sub-apikey': 1,
904
+ 'v3/broker/delete-sub-apikey': 1,
863
905
  'v3/ins-loan/bind-uid': 6.6667,
906
+ 'v3/loan/borrow': 2,
907
+ 'v3/loan/repay': 2,
908
+ 'v3/loan/revise-pledge': 2,
864
909
  'v3/trade/place-order': 2,
865
910
  'v3/trade/place-strategy-order': 2,
866
911
  'v3/trade/modify-order': 2,
@@ -872,6 +917,7 @@ class bitget extends bitget$1["default"] {
872
917
  'v3/trade/cancel-batch': 4,
873
918
  'v3/trade/cancel-symbol-order': 4,
874
919
  'v3/trade/close-positions': 4,
920
+ 'v3/trade/countdown-cancel-all': 20,
875
921
  'v3/user/create-sub': 2,
876
922
  'v3/user/freeze-sub': 2,
877
923
  'v3/user/create-sub-api': 2,
@@ -1182,8 +1182,9 @@ class bitmart extends bitmart$1["default"] {
1182
1182
  if (this.options['adjustForTimeDifference']) {
1183
1183
  await this.loadTimeDifference();
1184
1184
  }
1185
- const spot = await this.fetchSpotMarkets(params);
1186
- const contract = await this.fetchContractMarkets(params);
1185
+ const spotPromise = this.fetchSpotMarkets(params);
1186
+ const contractPromise = this.fetchContractMarkets(params);
1187
+ const [spot, contract] = await Promise.all([spotPromise, contractPromise]);
1187
1188
  return this.arrayConcat(spot, contract);
1188
1189
  }
1189
1190
  /**
@@ -4838,9 +4839,23 @@ class bitmart extends bitmart$1["default"] {
4838
4839
  // "timestamp": 1761291544336
4839
4840
  // }
4840
4841
  //
4842
+ // watchFundingRates
4843
+ //
4844
+ // {
4845
+ // "symbol": "BTCUSDT",
4846
+ // "fundingRate": "0.0000561",
4847
+ // "fundingTime": 1770978448000,
4848
+ // "nextFundingRate": "-0.0000195",
4849
+ // "nextFundingTime": 1770998400000,
4850
+ // "funding_upper_limit": "0.0375",
4851
+ // "funding_lower_limit": "-0.0375",
4852
+ // "ts": 1770978448970
4853
+ // }
4854
+ //
4841
4855
  const marketId = this.safeString(contract, 'symbol');
4842
- const timestamp = this.safeInteger(contract, 'timestamp');
4843
- const fundingTimestamp = this.safeInteger(contract, 'funding_time');
4856
+ const timestamp = this.safeInteger2(contract, 'timestamp', 'ts');
4857
+ const fundingTimestamp = this.safeInteger2(contract, 'funding_time', 'fundingTime');
4858
+ const nextFundingTimestamp = this.safeInteger(contract, 'nextFundingTime');
4844
4859
  return {
4845
4860
  'info': contract,
4846
4861
  'symbol': this.safeSymbol(marketId, market),
@@ -4850,12 +4865,12 @@ class bitmart extends bitmart$1["default"] {
4850
4865
  'estimatedSettlePrice': undefined,
4851
4866
  'timestamp': timestamp,
4852
4867
  'datetime': this.iso8601(timestamp),
4853
- 'fundingRate': this.safeNumber(contract, 'expected_rate'),
4868
+ 'fundingRate': this.safeNumber2(contract, 'expected_rate', 'fundingRate'),
4854
4869
  'fundingTimestamp': fundingTimestamp,
4855
4870
  'fundingDatetime': this.iso8601(fundingTimestamp),
4856
- 'nextFundingRate': undefined,
4857
- 'nextFundingTimestamp': undefined,
4858
- 'nextFundingDatetime': undefined,
4871
+ 'nextFundingRate': this.safeNumber(contract, 'nextFundingRate'),
4872
+ 'nextFundingTimestamp': nextFundingTimestamp,
4873
+ 'nextFundingDatetime': this.iso8601(nextFundingTimestamp),
4859
4874
  'previousFundingRate': this.safeNumber(contract, 'rate_value'),
4860
4875
  'previousFundingTimestamp': undefined,
4861
4876
  'previousFundingDatetime': undefined,
@@ -76,16 +76,21 @@ class bitmex extends bitmex$1["default"] {
76
76
  'fetchMyLiquidations': false,
77
77
  'fetchMyTrades': true,
78
78
  'fetchOHLCV': true,
79
+ 'fetchOpenInterest': 'emulated',
80
+ 'fetchOpenInterests': true,
79
81
  'fetchOpenOrders': true,
80
82
  'fetchOrder': true,
81
83
  'fetchOrderBook': true,
82
84
  'fetchOrders': true,
83
85
  'fetchPosition': false,
86
+ 'fetchPositionADLRank': true,
84
87
  'fetchPositionHistory': false,
85
88
  'fetchPositions': true,
89
+ 'fetchPositionsADLRank': true,
86
90
  'fetchPositionsHistory': false,
87
91
  'fetchPositionsRisk': false,
88
92
  'fetchPremiumIndexOHLCV': false,
93
+ 'fetchSettlementHistory': true,
89
94
  'fetchTicker': true,
90
95
  'fetchTickers': true,
91
96
  'fetchTrades': true,
@@ -2961,6 +2966,70 @@ class bitmex extends bitmex$1["default"] {
2961
2966
  //
2962
2967
  return this.parseDepositWithdrawFees(assets, codes, 'asset');
2963
2968
  }
2969
+ /**
2970
+ * @method
2971
+ * @name bitmex#fetchOpenInterests
2972
+ * @description Retrieves the open interest for a list of symbols
2973
+ * @see https://docs.bitmex.com/api-explorer/get-stats
2974
+ * @param {string[]} [symbols] a list of unified CCXT market symbols
2975
+ * @param {object} [params] exchange specific parameters
2976
+ * @returns {object[]} a list of [open interest structures]{@link https://docs.ccxt.com/?id=open-interest-structure}
2977
+ */
2978
+ async fetchOpenInterests(symbols = undefined, params = {}) {
2979
+ await this.loadMarkets();
2980
+ const request = {};
2981
+ let response = undefined;
2982
+ response = await this.publicGetStats(this.extend(request, params));
2983
+ //
2984
+ // [
2985
+ // {
2986
+ // currency: 'XBt',
2987
+ // openInterest: '0',
2988
+ // openValue: '323890820079',
2989
+ // rootSymbol: 'Total',
2990
+ // turnover24h: '447088001322',
2991
+ // volume24h: '0'
2992
+ // }
2993
+ // ...
2994
+ // ]
2995
+ //
2996
+ symbols = this.marketSymbols(symbols);
2997
+ return this.parseOpenInterests(response, symbols);
2998
+ }
2999
+ parseOpenInterest(interest, market = undefined) {
3000
+ //
3001
+ // fetchOpenInterest
3002
+ //
3003
+ // {
3004
+ // currency: 'XBt',
3005
+ // openInterest: '0',
3006
+ // openValue: '323890820079',
3007
+ // rootSymbol: 'Total',
3008
+ // turnover24h: '447088001322',
3009
+ // volume24h: '0'
3010
+ // }
3011
+ //
3012
+ const quoteId = this.safeString(interest, 'currency');
3013
+ const baseId = this.safeString(interest, 'rootSymbol');
3014
+ const quoteSymbol = this.safeCurrencyCode(quoteId);
3015
+ const baseSymbol = this.safeCurrencyCode(baseId);
3016
+ let symbol = baseSymbol;
3017
+ if (quoteSymbol !== undefined) {
3018
+ symbol = baseSymbol + '/' + quoteSymbol + ':' + quoteSymbol;
3019
+ }
3020
+ const openInterest = this.safeNumber(interest, 'openInterest');
3021
+ const openValue = this.safeNumber(interest, 'openValue');
3022
+ return this.safeOpenInterest({
3023
+ 'info': interest,
3024
+ 'symbol': symbol,
3025
+ 'baseVolume': openInterest,
3026
+ 'quoteVolume': openValue,
3027
+ 'openInterestAmount': openInterest,
3028
+ 'openInterestValue': openValue,
3029
+ 'timestamp': undefined,
3030
+ 'datetime': undefined,
3031
+ }, market);
3032
+ }
2964
3033
  calculateRateLimiterCost(api, method, path, params, config = {}) {
2965
3034
  const isAuthenticated = this.checkRequiredCredentials(false);
2966
3035
  const cost = this.safeValue(config, 'cost', 1);
@@ -3043,6 +3112,353 @@ class bitmex extends bitmex$1["default"] {
3043
3112
  'datetime': undefined,
3044
3113
  });
3045
3114
  }
3115
+ /**
3116
+ * @method
3117
+ * @name bitmex#fetchPositionsADLRank
3118
+ * @description fetches the auto deleveraging rank and risk percentage for a list of symbols
3119
+ * @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
3120
+ * @param {string[]} [symbols] list of unified market symbols
3121
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3122
+ * @returns {object[]} an [auto de leverage structure]{@link https://docs.ccxt.com/?id=auto-de-leverage-structure}
3123
+ */
3124
+ async fetchPositionsADLRank(symbols = undefined, params = {}) {
3125
+ await this.loadMarkets();
3126
+ symbols = this.marketSymbols(symbols, undefined, true, true, true);
3127
+ const response = await this.privateGetPosition(params);
3128
+ //
3129
+ // [
3130
+ // {
3131
+ // "account": 395724,
3132
+ // "symbol": "XBTUSDT",
3133
+ // "strategy": "OneWay",
3134
+ // "currency": "USDt",
3135
+ // "underlying": "XBT",
3136
+ // "quoteCurrency": "USDT",
3137
+ // "commission": 0.0005,
3138
+ // "initMarginReq": 0.01,
3139
+ // "maintMarginReq": 0.005,
3140
+ // "riskLimit": 1000000000000,
3141
+ // "leverage": 100,
3142
+ // "crossMargin": true,
3143
+ // "deleveragePercentile": 1,
3144
+ // "rebalancedPnl": -4319,
3145
+ // "prevRealisedPnl": 0,
3146
+ // "prevUnrealisedPnl": null,
3147
+ // "openingQty": null,
3148
+ // "openOrderBuyQty": 0,
3149
+ // "openOrderBuyCost": 0,
3150
+ // "openOrderBuyPremium": 0,
3151
+ // "openOrderSellQty": 0,
3152
+ // "openOrderSellCost": 0,
3153
+ // "openOrderSellPremium": 0,
3154
+ // "currentQty": 100,
3155
+ // "currentCost": 8639330,
3156
+ // "currentComm": 0,
3157
+ // "realisedCost": 0,
3158
+ // "unrealisedCost": 8639330,
3159
+ // "grossOpenPremium": 0,
3160
+ // "isOpen": true,
3161
+ // "markPrice": 88636.92,
3162
+ // "markValue": 8863692,
3163
+ // "riskValue": 8863692,
3164
+ // "homeNotional": 0.0001,
3165
+ // "foreignNotional": -8.863692,
3166
+ // "posCost": 8639330,
3167
+ // "posCross": 0,
3168
+ // "posComm": 0,
3169
+ // "posLoss": 0,
3170
+ // "posMargin": 44061,
3171
+ // "posMaint": 44061,
3172
+ // "posInit": 0,
3173
+ // "initMargin": 0,
3174
+ // "maintMargin": 44061,
3175
+ // "realisedPnl": 0,
3176
+ // "unrealisedPnl": 224362,
3177
+ // "unrealisedPnlPcnt": 0.026,
3178
+ // "unrealisedRoePcnt": 2.597,
3179
+ // "avgCostPrice": 86393.3,
3180
+ // "avgEntryPrice": 86393.3,
3181
+ // "breakEvenPrice": 86436.5,
3182
+ // "marginCallPrice": null,
3183
+ // "liquidationPrice": 0,
3184
+ // "bankruptPrice": 0,
3185
+ // "timestamp": "2025-12-31T07:55:50.505Z",
3186
+ // "positionReport": {
3187
+ // "account": 395724,
3188
+ // "avgCostPrice": 86393.3,
3189
+ // "avgEntryPrice": 86393.3,
3190
+ // "bankruptPrice": 0,
3191
+ // "breakEvenPrice": 86436.5,
3192
+ // "commission": 0.0005,
3193
+ // "crossMargin": true,
3194
+ // "currency": "USDt",
3195
+ // "currentComm": 0,
3196
+ // "currentCost": 8639330,
3197
+ // "currentQty": 100,
3198
+ // "deleveragePercentile": 1,
3199
+ // "foreignNotional": -8.863692,
3200
+ // "grossOpenPremium": 0,
3201
+ // "homeNotional": 0.0001,
3202
+ // "initMargin": 0,
3203
+ // "initMarginReq": 0.01,
3204
+ // "isOpen": true,
3205
+ // "leverage": 100,
3206
+ // "liquidationPrice": 0,
3207
+ // "maintMargin": 44061,
3208
+ // "maintMarginReq": 0.005,
3209
+ // "markPrice": 88636.92,
3210
+ // "markValue": 8863692,
3211
+ // "openOrderBuyCost": 0,
3212
+ // "openOrderBuyPremium": 0,
3213
+ // "openOrderBuyQty": 0,
3214
+ // "openOrderRealisedPnl": 0,
3215
+ // "openOrderSellCost": 0,
3216
+ // "openOrderSellPremium": 0,
3217
+ // "openOrderSellQty": 0,
3218
+ // "posComm": 0,
3219
+ // "posCost": 8639330,
3220
+ // "posCross": 0,
3221
+ // "posInit": 0,
3222
+ // "posLoss": 0,
3223
+ // "posMaint": 44061,
3224
+ // "posMargin": 44061,
3225
+ // "prevRealisedPnl": 0,
3226
+ // "quoteCurrency": "USDT",
3227
+ // "realisedCost": 0,
3228
+ // "realisedPnl": 0,
3229
+ // "rebalancedPnl": -4319,
3230
+ // "riskLimit": 1000000000000,
3231
+ // "riskValue": 8863692,
3232
+ // "strategy": "OneWay",
3233
+ // "symbol": "XBTUSDT",
3234
+ // "timestamp": "2025-12-31T07:55:50.505Z",
3235
+ // "underlying": "XBT",
3236
+ // "unrealisedCost": 8639330,
3237
+ // "unrealisedPnl": 224362,
3238
+ // "unrealisedPnlPcnt": 0.026,
3239
+ // "unrealisedRoePcnt": 2.597
3240
+ // }
3241
+ // }
3242
+ // ]
3243
+ //
3244
+ return this.parseADLRanks(response, symbols);
3245
+ }
3246
+ parseADLRank(info, market = undefined) {
3247
+ //
3248
+ // fetchPositionsADLRank
3249
+ //
3250
+ // {
3251
+ // "account": 395724,
3252
+ // "symbol": "XBTUSDT",
3253
+ // "strategy": "OneWay",
3254
+ // "currency": "USDt",
3255
+ // "underlying": "XBT",
3256
+ // "quoteCurrency": "USDT",
3257
+ // "commission": 0.0005,
3258
+ // "initMarginReq": 0.01,
3259
+ // "maintMarginReq": 0.005,
3260
+ // "riskLimit": 1000000000000,
3261
+ // "leverage": 100,
3262
+ // "crossMargin": true,
3263
+ // "deleveragePercentile": 1,
3264
+ // "rebalancedPnl": -4319,
3265
+ // "prevRealisedPnl": 0,
3266
+ // "prevUnrealisedPnl": null,
3267
+ // "openingQty": null,
3268
+ // "openOrderBuyQty": 0,
3269
+ // "openOrderBuyCost": 0,
3270
+ // "openOrderBuyPremium": 0,
3271
+ // "openOrderSellQty": 0,
3272
+ // "openOrderSellCost": 0,
3273
+ // "openOrderSellPremium": 0,
3274
+ // "currentQty": 100,
3275
+ // "currentCost": 8639330,
3276
+ // "currentComm": 0,
3277
+ // "realisedCost": 0,
3278
+ // "unrealisedCost": 8639330,
3279
+ // "grossOpenPremium": 0,
3280
+ // "isOpen": true,
3281
+ // "markPrice": 88636.92,
3282
+ // "markValue": 8863692,
3283
+ // "riskValue": 8863692,
3284
+ // "homeNotional": 0.0001,
3285
+ // "foreignNotional": -8.863692,
3286
+ // "posCost": 8639330,
3287
+ // "posCross": 0,
3288
+ // "posComm": 0,
3289
+ // "posLoss": 0,
3290
+ // "posMargin": 44061,
3291
+ // "posMaint": 44061,
3292
+ // "posInit": 0,
3293
+ // "initMargin": 0,
3294
+ // "maintMargin": 44061,
3295
+ // "realisedPnl": 0,
3296
+ // "unrealisedPnl": 224362,
3297
+ // "unrealisedPnlPcnt": 0.026,
3298
+ // "unrealisedRoePcnt": 2.597,
3299
+ // "avgCostPrice": 86393.3,
3300
+ // "avgEntryPrice": 86393.3,
3301
+ // "breakEvenPrice": 86436.5,
3302
+ // "marginCallPrice": null,
3303
+ // "liquidationPrice": 0,
3304
+ // "bankruptPrice": 0,
3305
+ // "timestamp": "2025-12-31T07:55:50.505Z",
3306
+ // "positionReport": {
3307
+ // "account": 395724,
3308
+ // "avgCostPrice": 86393.3,
3309
+ // "avgEntryPrice": 86393.3,
3310
+ // "bankruptPrice": 0,
3311
+ // "breakEvenPrice": 86436.5,
3312
+ // "commission": 0.0005,
3313
+ // "crossMargin": true,
3314
+ // "currency": "USDt",
3315
+ // "currentComm": 0,
3316
+ // "currentCost": 8639330,
3317
+ // "currentQty": 100,
3318
+ // "deleveragePercentile": 1,
3319
+ // "foreignNotional": -8.863692,
3320
+ // "grossOpenPremium": 0,
3321
+ // "homeNotional": 0.0001,
3322
+ // "initMargin": 0,
3323
+ // "initMarginReq": 0.01,
3324
+ // "isOpen": true,
3325
+ // "leverage": 100,
3326
+ // "liquidationPrice": 0,
3327
+ // "maintMargin": 44061,
3328
+ // "maintMarginReq": 0.005,
3329
+ // "markPrice": 88636.92,
3330
+ // "markValue": 8863692,
3331
+ // "openOrderBuyCost": 0,
3332
+ // "openOrderBuyPremium": 0,
3333
+ // "openOrderBuyQty": 0,
3334
+ // "openOrderRealisedPnl": 0,
3335
+ // "openOrderSellCost": 0,
3336
+ // "openOrderSellPremium": 0,
3337
+ // "openOrderSellQty": 0,
3338
+ // "posComm": 0,
3339
+ // "posCost": 8639330,
3340
+ // "posCross": 0,
3341
+ // "posInit": 0,
3342
+ // "posLoss": 0,
3343
+ // "posMaint": 44061,
3344
+ // "posMargin": 44061,
3345
+ // "prevRealisedPnl": 0,
3346
+ // "quoteCurrency": "USDT",
3347
+ // "realisedCost": 0,
3348
+ // "realisedPnl": 0,
3349
+ // "rebalancedPnl": -4319,
3350
+ // "riskLimit": 1000000000000,
3351
+ // "riskValue": 8863692,
3352
+ // "strategy": "OneWay",
3353
+ // "symbol": "XBTUSDT",
3354
+ // "timestamp": "2025-12-31T07:55:50.505Z",
3355
+ // "underlying": "XBT",
3356
+ // "unrealisedCost": 8639330,
3357
+ // "unrealisedPnl": 224362,
3358
+ // "unrealisedPnlPcnt": 0.026,
3359
+ // "unrealisedRoePcnt": 2.597
3360
+ // }
3361
+ // }
3362
+ //
3363
+ const marketId = this.safeString(info, 'symbol');
3364
+ const datetime = this.safeString(info, 'timestamp');
3365
+ return {
3366
+ 'info': info,
3367
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
3368
+ 'rank': this.safeInteger(info, 'deleveragePercentile'),
3369
+ 'rating': undefined,
3370
+ 'percentage': undefined,
3371
+ 'timestamp': this.parse8601(datetime),
3372
+ 'datetime': datetime,
3373
+ };
3374
+ }
3375
+ /**
3376
+ * @method
3377
+ * @name bitmex#fetchSettlementHistory
3378
+ * @description fetches historical settlement records
3379
+ * @see https://docs.bitmex.com/api-explorer/get-settlements
3380
+ * @param {string} symbol unified market symbol of the settlement history
3381
+ * @param {int} [since] timestamp in ms
3382
+ * @param {int} [limit] number of records
3383
+ * @param {object} [params] exchange specific params
3384
+ * @param {int} [params.until] timestamp in ms
3385
+ *
3386
+ * EXCHANGE SPECIFIC PARAMETERS
3387
+ * @param {string} [params.filter] generic table filter, send json key/value pairs, such as {"key": "value"}, you can key on individual fields, and do more advanced querying on timestamps, see the timestamp docs for more details, default value = {}
3388
+ * @param {string} [params.columns] array of column names to fetch, if omitted, will return all columns, note that this method will always return item keys, even when not specified, so you may receive more columns that you expect
3389
+ * @param {int} [params.start] possible values are >= 0 starting point for results, default value = 0
3390
+ * @param {boolean} [params.reverse] if true, will sort results newest first, default value = false
3391
+ * @returns {object[]} a list of [settlement history objects]{@link https://docs.ccxt.com/?id=settlement-history-structure}
3392
+ */
3393
+ async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3394
+ await this.loadMarkets();
3395
+ const request = {
3396
+ // symbol string Instrument symbol. Send a bare series (e.g. XBT) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. XBT:quarterly. Timeframes are nearest, daily, weekly, monthly, quarterly, biquarterly, and perpetual. Symbols are case-insensitive.
3397
+ // filter string Generic table filter. Send JSON key/value pairs, such as {"key": "value"}. You can key on individual fields, and do more advanced querying on timestamps. See the Timestamp Docs for more details. Default value: {}
3398
+ // columns string Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect.
3399
+ // count int32 Possible values: >= 1 and <= 500 Number of results to fetch. Must be a positive integer. Default value: 100
3400
+ // start int32 Possible values: >= 0 Starting point for results. Default value: 0
3401
+ // reverse boolean If true, will sort results newest first. Default value: false
3402
+ // startTime string Starting time filter for results.
3403
+ // endTime string Ending time filter for results.
3404
+ };
3405
+ let market = undefined;
3406
+ if (symbol !== undefined) {
3407
+ market = this.market(symbol);
3408
+ request['symbol'] = market['id'];
3409
+ }
3410
+ if (since !== undefined) {
3411
+ request['startTime'] = this.iso8601(since);
3412
+ }
3413
+ if (limit !== undefined) {
3414
+ request['count'] = limit;
3415
+ }
3416
+ const until = this.safeString(params, 'until');
3417
+ if (until !== undefined) {
3418
+ request['endTime'] = this.iso8601(since);
3419
+ params = this.omit(params, 'until');
3420
+ }
3421
+ const response = await this.publicGetSettlement(this.extend(request, params));
3422
+ //
3423
+ // [
3424
+ // {
3425
+ // timestamp: '2025-03-28T12:00:00.000Z',
3426
+ // symbol: 'ETHUSDH25',
3427
+ // settlementType: 'Settlement',
3428
+ // settledPrice: '1897.53'
3429
+ // }
3430
+ // ]
3431
+ //
3432
+ return this.parseSettlements(response, market, since, limit);
3433
+ }
3434
+ parseSettlements(settlements, market = undefined, since = undefined, limit = undefined) {
3435
+ const result = [];
3436
+ for (let i = 0; i < settlements.length; i++) {
3437
+ result.push(this.parseSettlement(settlements[i], market));
3438
+ }
3439
+ const sorted = this.sortBy(result, 'timestamp');
3440
+ const symbol = this.safeString(market, 'symbol');
3441
+ return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
3442
+ }
3443
+ parseSettlement(settlement, market = undefined) {
3444
+ //
3445
+ // {
3446
+ // timestamp: '2025-03-28T12:00:00.000Z',
3447
+ // symbol: 'ETHUSDH25',
3448
+ // settlementType: 'Settlement',
3449
+ // settledPrice: '1897.53'
3450
+ // }
3451
+ //
3452
+ const datetime = this.safeString(settlement, 'timestamp');
3453
+ const marketId = this.safeString(settlement, 'symbol');
3454
+ return {
3455
+ 'info': settlement,
3456
+ 'symbol': this.safeSymbol(marketId, market),
3457
+ 'price': this.safeNumber(settlement, 'settledPrice'),
3458
+ 'timestamp': this.parse8601(datetime),
3459
+ 'datetime': datetime,
3460
+ };
3461
+ }
3046
3462
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
3047
3463
  if (response === undefined) {
3048
3464
  return undefined;