ccxt 4.5.39 → 4.5.41

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 (138) hide show
  1. package/README.md +6 -5
  2. package/dist/ccxt.browser.min.js +18 -18
  3. package/dist/cjs/ccxt.js +6 -1
  4. package/dist/cjs/src/abstract/lighter.js +11 -0
  5. package/dist/cjs/src/ascendex.js +73 -1
  6. package/dist/cjs/src/base/Exchange.js +211 -22
  7. package/dist/cjs/src/base/functions/generic.js +1 -0
  8. package/dist/cjs/src/base/functions/io.js +160 -0
  9. package/dist/cjs/src/base/functions.js +6 -0
  10. package/dist/cjs/src/base/ws/Client.js +1 -0
  11. package/dist/cjs/src/base/ws/WsClient.js +1 -0
  12. package/dist/cjs/src/binance.js +143 -0
  13. package/dist/cjs/src/bingx.js +150 -123
  14. package/dist/cjs/src/bitmart.js +20 -6
  15. package/dist/cjs/src/bitmex.js +436 -0
  16. package/dist/cjs/src/blofin.js +86 -1
  17. package/dist/cjs/src/bybit.js +135 -0
  18. package/dist/cjs/src/coinspot.js +7 -2
  19. package/dist/cjs/src/delta.js +367 -0
  20. package/dist/cjs/src/gate.js +11 -4
  21. package/dist/cjs/src/gemini.js +76 -1
  22. package/dist/cjs/src/htx.js +266 -3
  23. package/dist/cjs/src/hyperliquid.js +20 -7
  24. package/dist/cjs/src/independentreserve.js +7 -7
  25. package/dist/cjs/src/kraken.js +1 -1
  26. package/dist/cjs/src/krakenfutures.js +96 -5
  27. package/dist/cjs/src/kucoin.js +3 -3
  28. package/dist/cjs/src/kucoinfutures.js +121 -0
  29. package/dist/cjs/src/lighter.js +2931 -0
  30. package/dist/cjs/src/mexc.js +9 -2
  31. package/dist/cjs/src/phemex.js +359 -0
  32. package/dist/cjs/src/poloniex.js +5 -0
  33. package/dist/cjs/src/pro/binance.js +2 -2
  34. package/dist/cjs/src/pro/bingx.js +248 -35
  35. package/dist/cjs/src/pro/bitget.js +49 -90
  36. package/dist/cjs/src/pro/bitmart.js +68 -0
  37. package/dist/cjs/src/pro/blofin.js +52 -1
  38. package/dist/cjs/src/pro/coinbaseinternational.js +5 -2
  39. package/dist/cjs/src/pro/defx.js +1 -1
  40. package/dist/cjs/src/pro/kucoinfutures.js +1 -1
  41. package/dist/cjs/src/pro/lighter.js +787 -0
  42. package/dist/cjs/src/pro/mexc.js +73 -1
  43. package/dist/cjs/src/pro/okx.js +7 -4
  44. package/dist/cjs/src/pro/paradex.js +138 -1
  45. package/dist/cjs/src/pro/woo.js +43 -0
  46. package/dist/cjs/src/static_dependencies/ethers/abi-coder.js +1 -0
  47. package/dist/cjs/src/static_dependencies/ethers/address/address.js +1 -0
  48. package/dist/cjs/src/static_dependencies/ethers/coders/abstract-coder.js +1 -0
  49. package/dist/cjs/src/static_dependencies/ethers/coders/address.js +1 -0
  50. package/dist/cjs/src/static_dependencies/ethers/coders/array.js +1 -0
  51. package/dist/cjs/src/static_dependencies/ethers/coders/bytes.js +1 -0
  52. package/dist/cjs/src/static_dependencies/ethers/coders/fixed-bytes.js +1 -0
  53. package/dist/cjs/src/static_dependencies/ethers/coders/number.js +1 -0
  54. package/dist/cjs/src/static_dependencies/ethers/fragments.js +1 -0
  55. package/dist/cjs/src/static_dependencies/ethers/index.js +1 -0
  56. package/dist/cjs/src/static_dependencies/ethers/interface.js +1 -0
  57. package/dist/cjs/src/static_dependencies/ethers/typed.js +1 -0
  58. package/dist/cjs/src/static_dependencies/ethers/utils/index.js +1 -0
  59. package/dist/cjs/src/whitebit.js +118 -16
  60. package/dist/cjs/src/woo.js +103 -3
  61. package/js/ccxt.d.ts +9 -3
  62. package/js/ccxt.js +6 -2
  63. package/js/src/abstract/gemini.d.ts +27 -0
  64. package/js/src/abstract/lighter.d.ts +53 -0
  65. package/js/src/abstract/lighter.js +5 -0
  66. package/js/src/ascendex.d.ts +12 -1
  67. package/js/src/ascendex.js +73 -1
  68. package/js/src/base/Exchange.d.ts +29 -14
  69. package/js/src/base/Exchange.js +216 -23
  70. package/js/src/base/functions/generic.js +1 -0
  71. package/js/src/base/functions/io.d.ts +32 -0
  72. package/js/src/base/functions/io.js +131 -0
  73. package/js/src/base/functions.d.ts +1 -0
  74. package/js/src/base/functions.js +1 -0
  75. package/js/src/base/types.d.ts +9 -0
  76. package/js/src/binance.d.ts +27 -1
  77. package/js/src/binance.js +143 -0
  78. package/js/src/bingx.d.ts +113 -108
  79. package/js/src/bingx.js +150 -123
  80. package/js/src/bitmart.js +20 -6
  81. package/js/src/bitmex.d.ts +50 -1
  82. package/js/src/bitmex.js +436 -0
  83. package/js/src/blofin.d.ts +12 -1
  84. package/js/src/blofin.js +86 -1
  85. package/js/src/bybit.d.ts +12 -1
  86. package/js/src/bybit.js +135 -0
  87. package/js/src/coinspot.js +7 -2
  88. package/js/src/delta.d.ts +12 -1
  89. package/js/src/delta.js +367 -0
  90. package/js/src/gate.d.ts +1 -0
  91. package/js/src/gate.js +11 -4
  92. package/js/src/gemini.d.ts +11 -0
  93. package/js/src/gemini.js +76 -1
  94. package/js/src/htx.d.ts +15 -1
  95. package/js/src/htx.js +266 -3
  96. package/js/src/hyperliquid.js +20 -7
  97. package/js/src/independentreserve.js +7 -7
  98. package/js/src/kraken.js +1 -1
  99. package/js/src/krakenfutures.d.ts +1 -1
  100. package/js/src/krakenfutures.js +96 -5
  101. package/js/src/kucoin.d.ts +3 -3
  102. package/js/src/kucoin.js +3 -3
  103. package/js/src/kucoinfutures.d.ts +12 -1
  104. package/js/src/kucoinfutures.js +121 -0
  105. package/js/src/lighter.d.ts +424 -0
  106. package/js/src/lighter.js +2924 -0
  107. package/js/src/mexc.js +9 -2
  108. package/js/src/phemex.d.ts +16 -1
  109. package/js/src/phemex.js +359 -0
  110. package/js/src/poloniex.js +5 -0
  111. package/js/src/pro/binance.js +2 -2
  112. package/js/src/pro/bingx.d.ts +50 -34
  113. package/js/src/pro/bingx.js +249 -36
  114. package/js/src/pro/bitget.d.ts +6 -6
  115. package/js/src/pro/bitget.js +49 -90
  116. package/js/src/pro/bitmart.d.ts +22 -1
  117. package/js/src/pro/bitmart.js +69 -1
  118. package/js/src/pro/blofin.d.ts +12 -1
  119. package/js/src/pro/blofin.js +52 -1
  120. package/js/src/pro/coinbaseinternational.d.ts +2 -2
  121. package/js/src/pro/coinbaseinternational.js +6 -3
  122. package/js/src/pro/defx.js +1 -1
  123. package/js/src/pro/kucoinfutures.js +1 -1
  124. package/js/src/pro/lighter.d.ts +161 -0
  125. package/js/src/pro/lighter.js +780 -0
  126. package/js/src/pro/mexc.d.ts +22 -1
  127. package/js/src/pro/mexc.js +73 -1
  128. package/js/src/pro/okx.d.ts +4 -4
  129. package/js/src/pro/okx.js +7 -4
  130. package/js/src/pro/paradex.d.ts +23 -1
  131. package/js/src/pro/paradex.js +138 -1
  132. package/js/src/pro/woo.d.ts +12 -1
  133. package/js/src/pro/woo.js +43 -0
  134. package/js/src/whitebit.d.ts +2 -1
  135. package/js/src/whitebit.js +118 -16
  136. package/js/src/woo.d.ts +12 -1
  137. package/js/src/woo.js +103 -3
  138. package/package.json +1 -1
@@ -4839,9 +4839,23 @@ class bitmart extends bitmart$1["default"] {
4839
4839
  // "timestamp": 1761291544336
4840
4840
  // }
4841
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
+ //
4842
4855
  const marketId = this.safeString(contract, 'symbol');
4843
- const timestamp = this.safeInteger(contract, 'timestamp');
4844
- 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');
4845
4859
  return {
4846
4860
  'info': contract,
4847
4861
  'symbol': this.safeSymbol(marketId, market),
@@ -4851,12 +4865,12 @@ class bitmart extends bitmart$1["default"] {
4851
4865
  'estimatedSettlePrice': undefined,
4852
4866
  'timestamp': timestamp,
4853
4867
  'datetime': this.iso8601(timestamp),
4854
- 'fundingRate': this.safeNumber(contract, 'expected_rate'),
4868
+ 'fundingRate': this.safeNumber2(contract, 'expected_rate', 'fundingRate'),
4855
4869
  'fundingTimestamp': fundingTimestamp,
4856
4870
  'fundingDatetime': this.iso8601(fundingTimestamp),
4857
- 'nextFundingRate': undefined,
4858
- 'nextFundingTimestamp': undefined,
4859
- 'nextFundingDatetime': undefined,
4871
+ 'nextFundingRate': this.safeNumber(contract, 'nextFundingRate'),
4872
+ 'nextFundingTimestamp': nextFundingTimestamp,
4873
+ 'nextFundingDatetime': this.iso8601(nextFundingTimestamp),
4860
4874
  'previousFundingRate': this.safeNumber(contract, 'rate_value'),
4861
4875
  'previousFundingTimestamp': undefined,
4862
4876
  'previousFundingDatetime': undefined,
@@ -38,6 +38,9 @@ class bitmex extends bitmex$1["default"] {
38
38
  'future': true,
39
39
  'option': false,
40
40
  'addMargin': undefined,
41
+ 'borrowCrossMargin': false,
42
+ 'borrowIsolatedMargin': false,
43
+ 'borrowMargin': false,
41
44
  'cancelAllOrders': true,
42
45
  'cancelAllOrdersAfter': true,
43
46
  'cancelOrder': true,
@@ -50,8 +53,17 @@ class bitmex extends bitmex$1["default"] {
50
53
  'createTrailingAmountOrder': true,
51
54
  'createTriggerOrder': true,
52
55
  'editOrder': true,
56
+ 'fetchAllGreeks': false,
53
57
  'fetchBalance': true,
58
+ 'fetchBorrowInterest': false,
59
+ 'fetchBorrowRate': false,
60
+ 'fetchBorrowRateHistories': false,
61
+ 'fetchBorrowRateHistory': false,
62
+ 'fetchBorrowRates': false,
63
+ 'fetchBorrowRatesPerSymbol': false,
54
64
  'fetchClosedOrders': true,
65
+ 'fetchCrossBorrowRate': false,
66
+ 'fetchCrossBorrowRates': false,
55
67
  'fetchCurrencies': true,
56
68
  'fetchDepositAddress': true,
57
69
  'fetchDepositAddresses': false,
@@ -63,7 +75,10 @@ class bitmex extends bitmex$1["default"] {
63
75
  'fetchFundingRate': 'emulated',
64
76
  'fetchFundingRateHistory': true,
65
77
  'fetchFundingRates': true,
78
+ 'fetchGreeks': false,
66
79
  'fetchIndexOHLCV': false,
80
+ 'fetchIsolatedBorrowRate': false,
81
+ 'fetchIsolatedBorrowRates': false,
67
82
  'fetchLedger': true,
68
83
  'fetchLeverage': 'emulated',
69
84
  'fetchLeverages': true,
@@ -76,24 +91,34 @@ class bitmex extends bitmex$1["default"] {
76
91
  'fetchMyLiquidations': false,
77
92
  'fetchMyTrades': true,
78
93
  'fetchOHLCV': true,
94
+ 'fetchOpenInterest': 'emulated',
95
+ 'fetchOpenInterests': true,
79
96
  'fetchOpenOrders': true,
97
+ 'fetchOption': false,
98
+ 'fetchOptionChain': false,
80
99
  'fetchOrder': true,
81
100
  'fetchOrderBook': true,
82
101
  'fetchOrders': true,
83
102
  'fetchPosition': false,
103
+ 'fetchPositionADLRank': true,
84
104
  'fetchPositionHistory': false,
85
105
  'fetchPositions': true,
106
+ 'fetchPositionsADLRank': true,
86
107
  'fetchPositionsHistory': false,
87
108
  'fetchPositionsRisk': false,
88
109
  'fetchPremiumIndexOHLCV': false,
110
+ 'fetchSettlementHistory': true,
89
111
  'fetchTicker': true,
90
112
  'fetchTickers': true,
91
113
  'fetchTrades': true,
92
114
  'fetchTransactions': 'emulated',
93
115
  'fetchTransfer': false,
94
116
  'fetchTransfers': false,
117
+ 'fetchVolatilityHistory': false,
95
118
  'index': true,
96
119
  'reduceMargin': undefined,
120
+ 'repayCrossMargin': false,
121
+ 'repayIsolatedMargin': false,
97
122
  'sandbox': true,
98
123
  'setLeverage': true,
99
124
  'setMargin': undefined,
@@ -2961,6 +2986,70 @@ class bitmex extends bitmex$1["default"] {
2961
2986
  //
2962
2987
  return this.parseDepositWithdrawFees(assets, codes, 'asset');
2963
2988
  }
2989
+ /**
2990
+ * @method
2991
+ * @name bitmex#fetchOpenInterests
2992
+ * @description Retrieves the open interest for a list of symbols
2993
+ * @see https://docs.bitmex.com/api-explorer/get-stats
2994
+ * @param {string[]} [symbols] a list of unified CCXT market symbols
2995
+ * @param {object} [params] exchange specific parameters
2996
+ * @returns {object[]} a list of [open interest structures]{@link https://docs.ccxt.com/?id=open-interest-structure}
2997
+ */
2998
+ async fetchOpenInterests(symbols = undefined, params = {}) {
2999
+ await this.loadMarkets();
3000
+ const request = {};
3001
+ let response = undefined;
3002
+ response = await this.publicGetStats(this.extend(request, params));
3003
+ //
3004
+ // [
3005
+ // {
3006
+ // currency: 'XBt',
3007
+ // openInterest: '0',
3008
+ // openValue: '323890820079',
3009
+ // rootSymbol: 'Total',
3010
+ // turnover24h: '447088001322',
3011
+ // volume24h: '0'
3012
+ // }
3013
+ // ...
3014
+ // ]
3015
+ //
3016
+ symbols = this.marketSymbols(symbols);
3017
+ return this.parseOpenInterests(response, symbols);
3018
+ }
3019
+ parseOpenInterest(interest, market = undefined) {
3020
+ //
3021
+ // fetchOpenInterest
3022
+ //
3023
+ // {
3024
+ // currency: 'XBt',
3025
+ // openInterest: '0',
3026
+ // openValue: '323890820079',
3027
+ // rootSymbol: 'Total',
3028
+ // turnover24h: '447088001322',
3029
+ // volume24h: '0'
3030
+ // }
3031
+ //
3032
+ const quoteId = this.safeString(interest, 'currency');
3033
+ const baseId = this.safeString(interest, 'rootSymbol');
3034
+ const quoteSymbol = this.safeCurrencyCode(quoteId);
3035
+ const baseSymbol = this.safeCurrencyCode(baseId);
3036
+ let symbol = baseSymbol;
3037
+ if (quoteSymbol !== undefined) {
3038
+ symbol = baseSymbol + '/' + quoteSymbol + ':' + quoteSymbol;
3039
+ }
3040
+ const openInterest = this.safeNumber(interest, 'openInterest');
3041
+ const openValue = this.safeNumber(interest, 'openValue');
3042
+ return this.safeOpenInterest({
3043
+ 'info': interest,
3044
+ 'symbol': symbol,
3045
+ 'baseVolume': openInterest,
3046
+ 'quoteVolume': openValue,
3047
+ 'openInterestAmount': openInterest,
3048
+ 'openInterestValue': openValue,
3049
+ 'timestamp': undefined,
3050
+ 'datetime': undefined,
3051
+ }, market);
3052
+ }
2964
3053
  calculateRateLimiterCost(api, method, path, params, config = {}) {
2965
3054
  const isAuthenticated = this.checkRequiredCredentials(false);
2966
3055
  const cost = this.safeValue(config, 'cost', 1);
@@ -3043,6 +3132,353 @@ class bitmex extends bitmex$1["default"] {
3043
3132
  'datetime': undefined,
3044
3133
  });
3045
3134
  }
3135
+ /**
3136
+ * @method
3137
+ * @name bitmex#fetchPositionsADLRank
3138
+ * @description fetches the auto deleveraging rank and risk percentage for a list of symbols
3139
+ * @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
3140
+ * @param {string[]} [symbols] list of unified market symbols
3141
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3142
+ * @returns {object[]} an [auto de leverage structure]{@link https://docs.ccxt.com/?id=auto-de-leverage-structure}
3143
+ */
3144
+ async fetchPositionsADLRank(symbols = undefined, params = {}) {
3145
+ await this.loadMarkets();
3146
+ symbols = this.marketSymbols(symbols, undefined, true, true, true);
3147
+ const response = await this.privateGetPosition(params);
3148
+ //
3149
+ // [
3150
+ // {
3151
+ // "account": 395724,
3152
+ // "symbol": "XBTUSDT",
3153
+ // "strategy": "OneWay",
3154
+ // "currency": "USDt",
3155
+ // "underlying": "XBT",
3156
+ // "quoteCurrency": "USDT",
3157
+ // "commission": 0.0005,
3158
+ // "initMarginReq": 0.01,
3159
+ // "maintMarginReq": 0.005,
3160
+ // "riskLimit": 1000000000000,
3161
+ // "leverage": 100,
3162
+ // "crossMargin": true,
3163
+ // "deleveragePercentile": 1,
3164
+ // "rebalancedPnl": -4319,
3165
+ // "prevRealisedPnl": 0,
3166
+ // "prevUnrealisedPnl": null,
3167
+ // "openingQty": null,
3168
+ // "openOrderBuyQty": 0,
3169
+ // "openOrderBuyCost": 0,
3170
+ // "openOrderBuyPremium": 0,
3171
+ // "openOrderSellQty": 0,
3172
+ // "openOrderSellCost": 0,
3173
+ // "openOrderSellPremium": 0,
3174
+ // "currentQty": 100,
3175
+ // "currentCost": 8639330,
3176
+ // "currentComm": 0,
3177
+ // "realisedCost": 0,
3178
+ // "unrealisedCost": 8639330,
3179
+ // "grossOpenPremium": 0,
3180
+ // "isOpen": true,
3181
+ // "markPrice": 88636.92,
3182
+ // "markValue": 8863692,
3183
+ // "riskValue": 8863692,
3184
+ // "homeNotional": 0.0001,
3185
+ // "foreignNotional": -8.863692,
3186
+ // "posCost": 8639330,
3187
+ // "posCross": 0,
3188
+ // "posComm": 0,
3189
+ // "posLoss": 0,
3190
+ // "posMargin": 44061,
3191
+ // "posMaint": 44061,
3192
+ // "posInit": 0,
3193
+ // "initMargin": 0,
3194
+ // "maintMargin": 44061,
3195
+ // "realisedPnl": 0,
3196
+ // "unrealisedPnl": 224362,
3197
+ // "unrealisedPnlPcnt": 0.026,
3198
+ // "unrealisedRoePcnt": 2.597,
3199
+ // "avgCostPrice": 86393.3,
3200
+ // "avgEntryPrice": 86393.3,
3201
+ // "breakEvenPrice": 86436.5,
3202
+ // "marginCallPrice": null,
3203
+ // "liquidationPrice": 0,
3204
+ // "bankruptPrice": 0,
3205
+ // "timestamp": "2025-12-31T07:55:50.505Z",
3206
+ // "positionReport": {
3207
+ // "account": 395724,
3208
+ // "avgCostPrice": 86393.3,
3209
+ // "avgEntryPrice": 86393.3,
3210
+ // "bankruptPrice": 0,
3211
+ // "breakEvenPrice": 86436.5,
3212
+ // "commission": 0.0005,
3213
+ // "crossMargin": true,
3214
+ // "currency": "USDt",
3215
+ // "currentComm": 0,
3216
+ // "currentCost": 8639330,
3217
+ // "currentQty": 100,
3218
+ // "deleveragePercentile": 1,
3219
+ // "foreignNotional": -8.863692,
3220
+ // "grossOpenPremium": 0,
3221
+ // "homeNotional": 0.0001,
3222
+ // "initMargin": 0,
3223
+ // "initMarginReq": 0.01,
3224
+ // "isOpen": true,
3225
+ // "leverage": 100,
3226
+ // "liquidationPrice": 0,
3227
+ // "maintMargin": 44061,
3228
+ // "maintMarginReq": 0.005,
3229
+ // "markPrice": 88636.92,
3230
+ // "markValue": 8863692,
3231
+ // "openOrderBuyCost": 0,
3232
+ // "openOrderBuyPremium": 0,
3233
+ // "openOrderBuyQty": 0,
3234
+ // "openOrderRealisedPnl": 0,
3235
+ // "openOrderSellCost": 0,
3236
+ // "openOrderSellPremium": 0,
3237
+ // "openOrderSellQty": 0,
3238
+ // "posComm": 0,
3239
+ // "posCost": 8639330,
3240
+ // "posCross": 0,
3241
+ // "posInit": 0,
3242
+ // "posLoss": 0,
3243
+ // "posMaint": 44061,
3244
+ // "posMargin": 44061,
3245
+ // "prevRealisedPnl": 0,
3246
+ // "quoteCurrency": "USDT",
3247
+ // "realisedCost": 0,
3248
+ // "realisedPnl": 0,
3249
+ // "rebalancedPnl": -4319,
3250
+ // "riskLimit": 1000000000000,
3251
+ // "riskValue": 8863692,
3252
+ // "strategy": "OneWay",
3253
+ // "symbol": "XBTUSDT",
3254
+ // "timestamp": "2025-12-31T07:55:50.505Z",
3255
+ // "underlying": "XBT",
3256
+ // "unrealisedCost": 8639330,
3257
+ // "unrealisedPnl": 224362,
3258
+ // "unrealisedPnlPcnt": 0.026,
3259
+ // "unrealisedRoePcnt": 2.597
3260
+ // }
3261
+ // }
3262
+ // ]
3263
+ //
3264
+ return this.parseADLRanks(response, symbols);
3265
+ }
3266
+ parseADLRank(info, market = undefined) {
3267
+ //
3268
+ // fetchPositionsADLRank
3269
+ //
3270
+ // {
3271
+ // "account": 395724,
3272
+ // "symbol": "XBTUSDT",
3273
+ // "strategy": "OneWay",
3274
+ // "currency": "USDt",
3275
+ // "underlying": "XBT",
3276
+ // "quoteCurrency": "USDT",
3277
+ // "commission": 0.0005,
3278
+ // "initMarginReq": 0.01,
3279
+ // "maintMarginReq": 0.005,
3280
+ // "riskLimit": 1000000000000,
3281
+ // "leverage": 100,
3282
+ // "crossMargin": true,
3283
+ // "deleveragePercentile": 1,
3284
+ // "rebalancedPnl": -4319,
3285
+ // "prevRealisedPnl": 0,
3286
+ // "prevUnrealisedPnl": null,
3287
+ // "openingQty": null,
3288
+ // "openOrderBuyQty": 0,
3289
+ // "openOrderBuyCost": 0,
3290
+ // "openOrderBuyPremium": 0,
3291
+ // "openOrderSellQty": 0,
3292
+ // "openOrderSellCost": 0,
3293
+ // "openOrderSellPremium": 0,
3294
+ // "currentQty": 100,
3295
+ // "currentCost": 8639330,
3296
+ // "currentComm": 0,
3297
+ // "realisedCost": 0,
3298
+ // "unrealisedCost": 8639330,
3299
+ // "grossOpenPremium": 0,
3300
+ // "isOpen": true,
3301
+ // "markPrice": 88636.92,
3302
+ // "markValue": 8863692,
3303
+ // "riskValue": 8863692,
3304
+ // "homeNotional": 0.0001,
3305
+ // "foreignNotional": -8.863692,
3306
+ // "posCost": 8639330,
3307
+ // "posCross": 0,
3308
+ // "posComm": 0,
3309
+ // "posLoss": 0,
3310
+ // "posMargin": 44061,
3311
+ // "posMaint": 44061,
3312
+ // "posInit": 0,
3313
+ // "initMargin": 0,
3314
+ // "maintMargin": 44061,
3315
+ // "realisedPnl": 0,
3316
+ // "unrealisedPnl": 224362,
3317
+ // "unrealisedPnlPcnt": 0.026,
3318
+ // "unrealisedRoePcnt": 2.597,
3319
+ // "avgCostPrice": 86393.3,
3320
+ // "avgEntryPrice": 86393.3,
3321
+ // "breakEvenPrice": 86436.5,
3322
+ // "marginCallPrice": null,
3323
+ // "liquidationPrice": 0,
3324
+ // "bankruptPrice": 0,
3325
+ // "timestamp": "2025-12-31T07:55:50.505Z",
3326
+ // "positionReport": {
3327
+ // "account": 395724,
3328
+ // "avgCostPrice": 86393.3,
3329
+ // "avgEntryPrice": 86393.3,
3330
+ // "bankruptPrice": 0,
3331
+ // "breakEvenPrice": 86436.5,
3332
+ // "commission": 0.0005,
3333
+ // "crossMargin": true,
3334
+ // "currency": "USDt",
3335
+ // "currentComm": 0,
3336
+ // "currentCost": 8639330,
3337
+ // "currentQty": 100,
3338
+ // "deleveragePercentile": 1,
3339
+ // "foreignNotional": -8.863692,
3340
+ // "grossOpenPremium": 0,
3341
+ // "homeNotional": 0.0001,
3342
+ // "initMargin": 0,
3343
+ // "initMarginReq": 0.01,
3344
+ // "isOpen": true,
3345
+ // "leverage": 100,
3346
+ // "liquidationPrice": 0,
3347
+ // "maintMargin": 44061,
3348
+ // "maintMarginReq": 0.005,
3349
+ // "markPrice": 88636.92,
3350
+ // "markValue": 8863692,
3351
+ // "openOrderBuyCost": 0,
3352
+ // "openOrderBuyPremium": 0,
3353
+ // "openOrderBuyQty": 0,
3354
+ // "openOrderRealisedPnl": 0,
3355
+ // "openOrderSellCost": 0,
3356
+ // "openOrderSellPremium": 0,
3357
+ // "openOrderSellQty": 0,
3358
+ // "posComm": 0,
3359
+ // "posCost": 8639330,
3360
+ // "posCross": 0,
3361
+ // "posInit": 0,
3362
+ // "posLoss": 0,
3363
+ // "posMaint": 44061,
3364
+ // "posMargin": 44061,
3365
+ // "prevRealisedPnl": 0,
3366
+ // "quoteCurrency": "USDT",
3367
+ // "realisedCost": 0,
3368
+ // "realisedPnl": 0,
3369
+ // "rebalancedPnl": -4319,
3370
+ // "riskLimit": 1000000000000,
3371
+ // "riskValue": 8863692,
3372
+ // "strategy": "OneWay",
3373
+ // "symbol": "XBTUSDT",
3374
+ // "timestamp": "2025-12-31T07:55:50.505Z",
3375
+ // "underlying": "XBT",
3376
+ // "unrealisedCost": 8639330,
3377
+ // "unrealisedPnl": 224362,
3378
+ // "unrealisedPnlPcnt": 0.026,
3379
+ // "unrealisedRoePcnt": 2.597
3380
+ // }
3381
+ // }
3382
+ //
3383
+ const marketId = this.safeString(info, 'symbol');
3384
+ const datetime = this.safeString(info, 'timestamp');
3385
+ return {
3386
+ 'info': info,
3387
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
3388
+ 'rank': this.safeInteger(info, 'deleveragePercentile'),
3389
+ 'rating': undefined,
3390
+ 'percentage': undefined,
3391
+ 'timestamp': this.parse8601(datetime),
3392
+ 'datetime': datetime,
3393
+ };
3394
+ }
3395
+ /**
3396
+ * @method
3397
+ * @name bitmex#fetchSettlementHistory
3398
+ * @description fetches historical settlement records
3399
+ * @see https://docs.bitmex.com/api-explorer/get-settlements
3400
+ * @param {string} symbol unified market symbol of the settlement history
3401
+ * @param {int} [since] timestamp in ms
3402
+ * @param {int} [limit] number of records
3403
+ * @param {object} [params] exchange specific params
3404
+ * @param {int} [params.until] timestamp in ms
3405
+ *
3406
+ * EXCHANGE SPECIFIC PARAMETERS
3407
+ * @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 = {}
3408
+ * @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
3409
+ * @param {int} [params.start] possible values are >= 0 starting point for results, default value = 0
3410
+ * @param {boolean} [params.reverse] if true, will sort results newest first, default value = false
3411
+ * @returns {object[]} a list of [settlement history objects]{@link https://docs.ccxt.com/?id=settlement-history-structure}
3412
+ */
3413
+ async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3414
+ await this.loadMarkets();
3415
+ const request = {
3416
+ // 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.
3417
+ // 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: {}
3418
+ // 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.
3419
+ // count int32 Possible values: >= 1 and <= 500 Number of results to fetch. Must be a positive integer. Default value: 100
3420
+ // start int32 Possible values: >= 0 Starting point for results. Default value: 0
3421
+ // reverse boolean If true, will sort results newest first. Default value: false
3422
+ // startTime string Starting time filter for results.
3423
+ // endTime string Ending time filter for results.
3424
+ };
3425
+ let market = undefined;
3426
+ if (symbol !== undefined) {
3427
+ market = this.market(symbol);
3428
+ request['symbol'] = market['id'];
3429
+ }
3430
+ if (since !== undefined) {
3431
+ request['startTime'] = this.iso8601(since);
3432
+ }
3433
+ if (limit !== undefined) {
3434
+ request['count'] = limit;
3435
+ }
3436
+ const until = this.safeString(params, 'until');
3437
+ if (until !== undefined) {
3438
+ request['endTime'] = this.iso8601(since);
3439
+ params = this.omit(params, 'until');
3440
+ }
3441
+ const response = await this.publicGetSettlement(this.extend(request, params));
3442
+ //
3443
+ // [
3444
+ // {
3445
+ // timestamp: '2025-03-28T12:00:00.000Z',
3446
+ // symbol: 'ETHUSDH25',
3447
+ // settlementType: 'Settlement',
3448
+ // settledPrice: '1897.53'
3449
+ // }
3450
+ // ]
3451
+ //
3452
+ return this.parseSettlements(response, market, since, limit);
3453
+ }
3454
+ parseSettlements(settlements, market = undefined, since = undefined, limit = undefined) {
3455
+ const result = [];
3456
+ for (let i = 0; i < settlements.length; i++) {
3457
+ result.push(this.parseSettlement(settlements[i], market));
3458
+ }
3459
+ const sorted = this.sortBy(result, 'timestamp');
3460
+ const symbol = this.safeString(market, 'symbol');
3461
+ return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
3462
+ }
3463
+ parseSettlement(settlement, market = undefined) {
3464
+ //
3465
+ // {
3466
+ // timestamp: '2025-03-28T12:00:00.000Z',
3467
+ // symbol: 'ETHUSDH25',
3468
+ // settlementType: 'Settlement',
3469
+ // settledPrice: '1897.53'
3470
+ // }
3471
+ //
3472
+ const datetime = this.safeString(settlement, 'timestamp');
3473
+ const marketId = this.safeString(settlement, 'symbol');
3474
+ return {
3475
+ 'info': settlement,
3476
+ 'symbol': this.safeSymbol(marketId, market),
3477
+ 'price': this.safeNumber(settlement, 'settledPrice'),
3478
+ 'timestamp': this.parse8601(datetime),
3479
+ 'datetime': datetime,
3480
+ };
3481
+ }
3046
3482
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
3047
3483
  if (response === undefined) {
3048
3484
  return undefined;
@@ -104,8 +104,10 @@ class blofin extends blofin$1["default"] {
104
104
  'fetchOrders': false,
105
105
  'fetchOrderTrades': true,
106
106
  'fetchPosition': true,
107
+ 'fetchPositionADLRank': true,
107
108
  'fetchPositionMode': true,
108
109
  'fetchPositions': true,
110
+ 'fetchPositionsADLRank': true,
109
111
  'fetchPositionsForSymbol': false,
110
112
  'fetchPositionsRisk': false,
111
113
  'fetchPremiumIndexOHLCV': false,
@@ -1748,7 +1750,7 @@ class blofin extends blofin$1["default"] {
1748
1750
  // {
1749
1751
  // "currency": "USDT",
1750
1752
  // "chain": "TRC20",
1751
- // "address": "TGfJLtnsh3B9EqekFEBZ1nR14QanBUf5Bi",
1753
+ // "address": "TGfJLtnsh3B9EqekFEBZ1nR14QanBUf5Be",
1752
1754
  // "txId": "892f4e0c32268b29b2e541ef30d32a30bbf10f902adcc4b1428319ed7c3758fd",
1753
1755
  // "type": "0",
1754
1756
  // "amount": "86.975843",
@@ -2501,6 +2503,89 @@ class blofin extends blofin$1["default"] {
2501
2503
  //
2502
2504
  return await this.privatePostAccountSetPositionMode(this.extend(request, params));
2503
2505
  }
2506
+ /**
2507
+ * @method
2508
+ * @name blofin#fetchPositionsADLRank
2509
+ * @description fetches the auto deleveraging rank and risk percentage for a list of symbols
2510
+ * @see https://docs.blofin.com/index.html#get-positions
2511
+ * @param {string[]} [symbols] a list of unified market symbols
2512
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2513
+ * @returns {object[]} an array of [auto de leverage structures]{@link https://docs.ccxt.com/?id=auto-de-leverage-structure}
2514
+ */
2515
+ async fetchPositionsADLRank(symbols = undefined, params = {}) {
2516
+ await this.loadMarkets();
2517
+ symbols = this.marketSymbols(symbols, undefined, true, true, true);
2518
+ const response = await this.privateGetAccountPositions(params);
2519
+ //
2520
+ // {
2521
+ // "code": "0",
2522
+ // "msg": "success",
2523
+ // "data": [
2524
+ // {
2525
+ // "positionId": "756786",
2526
+ // "instId": "BTC-USDT",
2527
+ // "instType": "SWAP",
2528
+ // "marginMode": "cross",
2529
+ // "positionSide": "net",
2530
+ // "adl": "1",
2531
+ // "positions": "0.1",
2532
+ // "availablePositions": "0.1",
2533
+ // "averagePrice": "88564.9",
2534
+ // "markPrice": "88546.3696492756",
2535
+ // "marginRatio": "822.305183525552961566",
2536
+ // "liquidationPrice": "",
2537
+ // "unrealizedPnl": "-0.00185303507244",
2538
+ // "unrealizedPnlRatio": "-0.000627687178252332",
2539
+ // "initialMargin": "2.951545654975853333",
2540
+ // "maintenanceMargin": "0.02656391089478268",
2541
+ // "createTime": "1767169876207",
2542
+ // "updateTime": "1767169876207",
2543
+ // "leverage": "3"
2544
+ // }
2545
+ // ]
2546
+ // }
2547
+ //
2548
+ const data = this.safeList(response, 'data', []);
2549
+ return this.parseADLRanks(data, symbols);
2550
+ }
2551
+ parseADLRank(info, market = undefined) {
2552
+ //
2553
+ // fetchPositionsADLRank
2554
+ //
2555
+ // {
2556
+ // "positionId": "756786",
2557
+ // "instId": "BTC-USDT",
2558
+ // "instType": "SWAP",
2559
+ // "marginMode": "cross",
2560
+ // "positionSide": "net",
2561
+ // "adl": "1",
2562
+ // "positions": "0.1",
2563
+ // "availablePositions": "0.1",
2564
+ // "averagePrice": "88564.9",
2565
+ // "markPrice": "88546.3696492756",
2566
+ // "marginRatio": "822.305183525552961566",
2567
+ // "liquidationPrice": "",
2568
+ // "unrealizedPnl": "-0.00185303507244",
2569
+ // "unrealizedPnlRatio": "-0.000627687178252332",
2570
+ // "initialMargin": "2.951545654975853333",
2571
+ // "maintenanceMargin": "0.02656391089478268",
2572
+ // "createTime": "1767169876207",
2573
+ // "updateTime": "1767169876207",
2574
+ // "leverage": "3"
2575
+ // }
2576
+ //
2577
+ const marketId = this.safeString(info, 'instId');
2578
+ const timestamp = this.safeIntegerOmitZero(info, 'createTime');
2579
+ return {
2580
+ 'info': info,
2581
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
2582
+ 'rank': this.safeInteger(info, 'adl'),
2583
+ 'rating': undefined,
2584
+ 'percentage': undefined,
2585
+ 'timestamp': timestamp,
2586
+ 'datetime': this.iso8601(timestamp),
2587
+ };
2588
+ }
2504
2589
  handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
2505
2590
  if (response === undefined) {
2506
2591
  return undefined; // fallback to default error handler