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
@@ -116,8 +116,10 @@ class bybit extends bybit$1["default"] {
116
116
  'fetchOrders': false,
117
117
  'fetchOrderTrades': true,
118
118
  'fetchPosition': true,
119
+ 'fetchPositionADLRank': true,
119
120
  'fetchPositionHistory': 'emulated',
120
121
  'fetchPositions': true,
122
+ 'fetchPositionsADLRank': true,
121
123
  'fetchPositionsHistory': true,
122
124
  'fetchPremiumIndexOHLCV': true,
123
125
  'fetchSettlementHistory': true,
@@ -9434,6 +9436,139 @@ class bybit extends bybit$1["default"] {
9434
9436
  'longShortRatio': this.parseToNumeric(Precise["default"].stringDiv(longString, shortString)),
9435
9437
  };
9436
9438
  }
9439
+ /**
9440
+ * @method
9441
+ * @name bybit#fetchPositionsADLRank
9442
+ * @description fetches the auto deleveraging rank and risk percentage for a list of symbols
9443
+ * @see https://bybit-exchange.github.io/docs/v5/position#response-parameters
9444
+ * @param {string[]} [symbols] list of unified market symbols
9445
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
9446
+ * @returns {object[]} an array of [auto de leverage structures]{@link https://docs.ccxt.com/?id=auto-de-leverage-structure}
9447
+ */
9448
+ async fetchPositionsADLRank(symbols = undefined, params = {}) {
9449
+ if (symbols === undefined) {
9450
+ throw new errors.ArgumentsRequired(this.id + ' fetchPositionsADLRank() requires a symbols argument');
9451
+ }
9452
+ await this.loadMarkets();
9453
+ symbols = this.marketSymbols(symbols, undefined, true, true, true);
9454
+ const market = this.getMarketFromSymbols(symbols);
9455
+ const request = {};
9456
+ if (market !== undefined) {
9457
+ request['symbol'] = market['id'];
9458
+ }
9459
+ let type = undefined;
9460
+ [type, params] = this.getBybitType('fetchPositionsADLRank', market, params);
9461
+ request['category'] = type;
9462
+ const response = await this.privateGetV5PositionList(this.extend(request, params));
9463
+ //
9464
+ // {
9465
+ // "retCode": 0,
9466
+ // "retMsg": "OK",
9467
+ // "result": {
9468
+ // "nextPageCursor": "BTCUSDT%2C1767085496112%2C0",
9469
+ // "category": "linear",
9470
+ // "list": [
9471
+ // {
9472
+ // "symbol": "BTCUSDT",
9473
+ // "leverage": "",
9474
+ // "autoAddMargin": 0,
9475
+ // "avgPrice": "177489.6",
9476
+ // "liqPrice": "",
9477
+ // "riskLimitValue": "",
9478
+ // "takeProfit": "",
9479
+ // "positionValue": "1774.896",
9480
+ // "isReduceOnly": false,
9481
+ // "positionIMByMp": "",
9482
+ // "tpslMode": "Full",
9483
+ // "riskId": 0,
9484
+ // "trailingStop": "0",
9485
+ // "unrealisedPnl": "-3.016",
9486
+ // "markPrice": "177188",
9487
+ // "adlRankIndicator": 2,
9488
+ // "cumRealisedPnl": "-9782.391468",
9489
+ // "positionMM": "",
9490
+ // "createdTime": "1699928551230",
9491
+ // "positionIdx": 0,
9492
+ // "positionIM": "",
9493
+ // "positionMMByMp": "",
9494
+ // "seq": 9558506126,
9495
+ // "updatedTime": "1767085496112",
9496
+ // "side": "Buy",
9497
+ // "bustPrice": "",
9498
+ // "positionBalance": "",
9499
+ // "leverageSysUpdatedTime": "",
9500
+ // "curRealisedPnl": "-0.9761928",
9501
+ // "size": "0.01",
9502
+ // "positionStatus": "Normal",
9503
+ // "mmrSysUpdatedTime": "",
9504
+ // "stopLoss": "",
9505
+ // "tradeMode": 0,
9506
+ // "sessionAvgPrice": ""
9507
+ // }
9508
+ // ]
9509
+ // },
9510
+ // "retExtInfo": {},
9511
+ // "time": 1767085741416
9512
+ // }
9513
+ //
9514
+ const result = this.safeDict(response, 'result', {});
9515
+ const ranks = this.safeList(result, 'list', []);
9516
+ return this.parseADLRanks(ranks, symbols);
9517
+ }
9518
+ parseADLRank(info, market = undefined) {
9519
+ //
9520
+ // fetchPositionsADLRank
9521
+ //
9522
+ // {
9523
+ // "symbol": "BTCUSDT",
9524
+ // "leverage": "",
9525
+ // "autoAddMargin": 0,
9526
+ // "avgPrice": "177489.6",
9527
+ // "liqPrice": "",
9528
+ // "riskLimitValue": "",
9529
+ // "takeProfit": "",
9530
+ // "positionValue": "1774.896",
9531
+ // "isReduceOnly": false,
9532
+ // "positionIMByMp": "",
9533
+ // "tpslMode": "Full",
9534
+ // "riskId": 0,
9535
+ // "trailingStop": "0",
9536
+ // "unrealisedPnl": "-3.016",
9537
+ // "markPrice": "177188",
9538
+ // "adlRankIndicator": 2,
9539
+ // "cumRealisedPnl": "-9782.391468",
9540
+ // "positionMM": "",
9541
+ // "createdTime": "1699928551230",
9542
+ // "positionIdx": 0,
9543
+ // "positionIM": "",
9544
+ // "positionMMByMp": "",
9545
+ // "seq": 9558506126,
9546
+ // "updatedTime": "1767085496112",
9547
+ // "side": "Buy",
9548
+ // "bustPrice": "",
9549
+ // "positionBalance": "",
9550
+ // "leverageSysUpdatedTime": "",
9551
+ // "curRealisedPnl": "-0.9761928",
9552
+ // "size": "0.01",
9553
+ // "positionStatus": "Normal",
9554
+ // "mmrSysUpdatedTime": "",
9555
+ // "stopLoss": "",
9556
+ // "tradeMode": 0,
9557
+ // "sessionAvgPrice": ""
9558
+ // }
9559
+ //
9560
+ const marketId = this.safeString(info, 'symbol');
9561
+ const timestamp = this.safeInteger(info, 'updatedTime');
9562
+ return {
9563
+ 'info': info,
9564
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
9565
+ 'rank': this.safeInteger(info, 'adlRankIndicator'),
9566
+ 'rating': undefined,
9567
+ 'percentage': undefined,
9568
+ 'timestamp': timestamp,
9569
+ 'datetime': this.iso8601(timestamp),
9570
+ };
9571
+ }
9437
9572
  /**
9438
9573
  * @method
9439
9574
  * @name bybit#fetchMarginMode
@@ -706,8 +706,13 @@ class coinspot extends coinspot$1["default"] {
706
706
  });
707
707
  }
708
708
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
709
- const url = this.urls['api'][api] + '/' + path;
710
- if (api === 'private') {
709
+ const isVersionedApi = Array.isArray(api);
710
+ const version = isVersionedApi ? api[0] : undefined;
711
+ const accessType = isVersionedApi ? api[1] : api;
712
+ const endpoint = '/' + this.implodeParams(path, params);
713
+ const fullPath = (version !== undefined) ? '/' + version + endpoint : endpoint;
714
+ const url = this.urls['api'][accessType] + fullPath;
715
+ if (accessType === 'private') {
711
716
  this.checkRequiredCredentials();
712
717
  const nonce = this.nonce();
713
718
  body = this.json(this.extend({ 'nonce': nonce }, params));
@@ -70,8 +70,10 @@ class delta extends delta$1["default"] {
70
70
  'fetchOrder': true,
71
71
  'fetchOrderBook': true,
72
72
  'fetchPosition': true,
73
+ 'fetchPositionADLRank': true,
73
74
  'fetchPositionMode': false,
74
75
  'fetchPositions': true,
76
+ 'fetchPositionsADLRank': true,
75
77
  'fetchPremiumIndexOHLCV': false,
76
78
  'fetchSettlementHistory': true,
77
79
  'fetchStatus': true,
@@ -3695,6 +3697,371 @@ class delta extends delta$1["default"] {
3695
3697
  'quoteVolume': undefined,
3696
3698
  };
3697
3699
  }
3700
+ /**
3701
+ * @method
3702
+ * @name delta#fetchPositionsADLRank
3703
+ * @description fetches the auto deleveraging rank and risk percentage for a list of symbols
3704
+ * @see https://docs.delta.exchange/#get-margined-positions
3705
+ * @param {string[]} [symbols] a list of unified market symbols
3706
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3707
+ * @returns {object[]} an array of [auto de leverage structures]{@link https://docs.ccxt.com/?id=auto-de-leverage-structure}
3708
+ */
3709
+ async fetchPositionsADLRank(symbols = undefined, params = {}) {
3710
+ await this.loadMarkets();
3711
+ symbols = this.marketSymbols(symbols, undefined, true, true, true);
3712
+ const response = await this.privateGetPositionsMargined(params);
3713
+ //
3714
+ // {
3715
+ // "result":
3716
+ // [
3717
+ // {
3718
+ // "adl_level": null,
3719
+ // "auto_topup": false,
3720
+ // "bankruptcy_price": "88618.22667",
3721
+ // "commission": "0.03797924",
3722
+ // "created_at": "2026-01-14T11:24:35.801586Z",
3723
+ // "entry_price": "94948.1",
3724
+ // "liquidation_price": "89092.96717",
3725
+ // "margin": "6.32987333",
3726
+ // "margin_mode": "isolated",
3727
+ // "mark_price": "94942.90888022",
3728
+ // "product": {
3729
+ // "trading_status": "operational",
3730
+ // "short_description": null,
3731
+ // "quoting_asset": {
3732
+ // "base_withdrawal_fee": "0.000000000000000000",
3733
+ // "id": 4,
3734
+ // "interest_credit": false,
3735
+ // "interest_slabs": null,
3736
+ // "kyc_deposit_limit": "0.000000000000000000",
3737
+ // "kyc_withdrawal_limit": "0.000000000000000000",
3738
+ // "min_withdrawal_amount": "0.000000000000000000",
3739
+ // "minimum_precision": 2,
3740
+ // "name": "Tether",
3741
+ // "networks": [],
3742
+ // "precision": 8,
3743
+ // "sort_priority": null,
3744
+ // "symbol": "USDT",
3745
+ // "variable_withdrawal_fee": "0.000000000000000000"
3746
+ // },
3747
+ // "symbol": "BTCUSDT",
3748
+ // "taker_commission_rate": "0.0004",
3749
+ // "maintenance_margin_scaling_factor": "0",
3750
+ // "spot_index": {
3751
+ // "config": {
3752
+ // "impact_size": {
3753
+ // "max_impact_size": 150000,
3754
+ // "min_impact_size": 5000,
3755
+ // "step_value": 5000
3756
+ // },
3757
+ // "quoting_asset": "USDT",
3758
+ // "service_id": 1,
3759
+ // "underlying_asset": "BTC"
3760
+ // },
3761
+ // "constituent_exchanges": [
3762
+ // {
3763
+ // "exchange": "binance",
3764
+ // "health_interval": 3000,
3765
+ // "health_priority": 1,
3766
+ // "weight": 1
3767
+ // },
3768
+ // {
3769
+ // "exchange": "gateio",
3770
+ // "health_interval": 3000,
3771
+ // "health_priority": 3,
3772
+ // "weight": 1
3773
+ // },
3774
+ // {
3775
+ // "exchange": "bybit",
3776
+ // "health_interval": 3000,
3777
+ // "health_priority": 2,
3778
+ // "weight": 1
3779
+ // }
3780
+ // ],
3781
+ // "constituent_indices": null,
3782
+ // "description": "BTC Spot",
3783
+ // "health_interval": 300,
3784
+ // "id": 2,
3785
+ // "impact_size": "1.000000000000000000",
3786
+ // "index_type": "spot_pair",
3787
+ // "is_composite": false,
3788
+ // "price_method": "ltp",
3789
+ // "quoting_asset_id": 4,
3790
+ // "symbol": ".DEXBTUSDT",
3791
+ // "tick_size": "0.100000000000000000",
3792
+ // "underlying_asset_id": 2
3793
+ // },
3794
+ // "liquidation_penalty_factor": "1",
3795
+ // "auction_start_time": "2025-12-22T12:18:52Z",
3796
+ // "is_quanto": false,
3797
+ // "state": "live",
3798
+ // "id": 84,
3799
+ // "settling_asset": {
3800
+ // "base_withdrawal_fee": "0.000000000000000000",
3801
+ // "id": 4,
3802
+ // "interest_credit": false,
3803
+ // "interest_slabs": null,
3804
+ // "kyc_deposit_limit": "0.000000000000000000",
3805
+ // "kyc_withdrawal_limit": "0.000000000000000000",
3806
+ // "min_withdrawal_amount": "0.000000000000000000",
3807
+ // "minimum_precision": 2,
3808
+ // "name": "Tether",
3809
+ // "networks": [],
3810
+ // "precision": 8,
3811
+ // "sort_priority": null,
3812
+ // "symbol": "USDT",
3813
+ // "variable_withdrawal_fee": "0.000000000000000000"
3814
+ // },
3815
+ // "tick_size": "0.1",
3816
+ // "impact_size": 4000,
3817
+ // "insurance_fund_margin_contribution": "5",
3818
+ // "maker_commission_rate": "0.0002",
3819
+ // "ui_config": {
3820
+ // "default_trading_view_candle": "15",
3821
+ // "leverage_slider_values": [1,2,3,5,10,50,100],
3822
+ // "price_clubbing_values": [0.1,1,10,50],
3823
+ // "show_bracket_orders": false,
3824
+ // "sort_priority": 1
3825
+ // },
3826
+ // "annualized_funding": "0",
3827
+ // "strike_price": null,
3828
+ // "price_band": "100",
3829
+ // "funding_method": "mark_price",
3830
+ // "contract_value": "0.001",
3831
+ // "auction_finish_time": null,
3832
+ // "product_specs": {
3833
+ // "vol_expiry_time": 172800
3834
+ // },
3835
+ // "launch_time": "2020-04-20T08:37:05Z",
3836
+ // "basis_factor_max_limit": "1000",
3837
+ // "initial_margin": "1",
3838
+ // "notional_type": "vanilla",
3839
+ // "contract_unit_currency": "BTC",
3840
+ // "disruption_reason": null,
3841
+ // "underlying_asset": {
3842
+ // "base_withdrawal_fee": "0.000000000000000000",
3843
+ // "id": 2,
3844
+ // "interest_credit": false,
3845
+ // "interest_slabs": null,
3846
+ // "kyc_deposit_limit": "0.000000000000000000",
3847
+ // "kyc_withdrawal_limit": "0.000000000000000000",
3848
+ // "min_withdrawal_amount": "0.000000000000000000",
3849
+ // "minimum_precision": 4,
3850
+ // "name": "Bitcoin",
3851
+ // "networks": [],
3852
+ // "precision": 8,
3853
+ // "sort_priority": 1,
3854
+ // "symbol": "BTC",
3855
+ // "variable_withdrawal_fee": "0.000000000000000000"
3856
+ // },
3857
+ // "initial_margin_scaling_factor": "0",
3858
+ // "position_size_limit": 10000000,
3859
+ // "max_leverage_notional": "10000",
3860
+ // "settlement_price": null,
3861
+ // "barrier_price": null,
3862
+ // "maintenance_margin": "0.5",
3863
+ // "default_leverage": "50.000000000000000000",
3864
+ // "settlement_time": null,
3865
+ // "description": "BTCUSDT-Bitcoin Perpetual futures, quoted,settled & margined in Tether(USDT)",
3866
+ // "contract_type": "perpetual_futures"
3867
+ // },
3868
+ // "product_id": 84,
3869
+ // "product_symbol": "BTCUSDT",
3870
+ // "realized_cashflow": "0.000000000000000000",
3871
+ // "realized_funding": "0",
3872
+ // "realized_holding_cost": "0",
3873
+ // "realized_pnl": "0",
3874
+ // "size": 1,
3875
+ // "unrealized_pnl": "-0.00519112",
3876
+ // "updated_at": "2026-01-14T11:24:35.801586Z",
3877
+ // "user_id": 30084879
3878
+ // }
3879
+ // ],
3880
+ // "success": true
3881
+ // }
3882
+ //
3883
+ const result = this.safeList(response, 'result', []);
3884
+ return this.parseADLRanks(result, symbols);
3885
+ }
3886
+ parseADLRank(info, market = undefined) {
3887
+ //
3888
+ // fetchPositionsADLRank
3889
+ //
3890
+ // {
3891
+ // "adl_level": null,
3892
+ // "auto_topup": false,
3893
+ // "bankruptcy_price": "88618.22667",
3894
+ // "commission": "0.03797924",
3895
+ // "created_at": "2026-01-14T11:24:35.801586Z",
3896
+ // "entry_price": "94948.1",
3897
+ // "liquidation_price": "89092.96717",
3898
+ // "margin": "6.32987333",
3899
+ // "margin_mode": "isolated",
3900
+ // "mark_price": "94942.90888022",
3901
+ // "product": {
3902
+ // "trading_status": "operational",
3903
+ // "short_description": null,
3904
+ // "quoting_asset": {
3905
+ // "base_withdrawal_fee": "0.000000000000000000",
3906
+ // "id": 4,
3907
+ // "interest_credit": false,
3908
+ // "interest_slabs": null,
3909
+ // "kyc_deposit_limit": "0.000000000000000000",
3910
+ // "kyc_withdrawal_limit": "0.000000000000000000",
3911
+ // "min_withdrawal_amount": "0.000000000000000000",
3912
+ // "minimum_precision": 2,
3913
+ // "name": "Tether",
3914
+ // "networks": [],
3915
+ // "precision": 8,
3916
+ // "sort_priority": null,
3917
+ // "symbol": "USDT",
3918
+ // "variable_withdrawal_fee": "0.000000000000000000"
3919
+ // },
3920
+ // "symbol": "BTCUSDT",
3921
+ // "taker_commission_rate": "0.0004",
3922
+ // "maintenance_margin_scaling_factor": "0",
3923
+ // "spot_index": {
3924
+ // "config": {
3925
+ // "impact_size": {
3926
+ // "max_impact_size": 150000,
3927
+ // "min_impact_size": 5000,
3928
+ // "step_value": 5000
3929
+ // },
3930
+ // "quoting_asset": "USDT",
3931
+ // "service_id": 1,
3932
+ // "underlying_asset": "BTC"
3933
+ // },
3934
+ // "constituent_exchanges": [
3935
+ // {
3936
+ // "exchange": "binance",
3937
+ // "health_interval": 3000,
3938
+ // "health_priority": 1,
3939
+ // "weight": 1
3940
+ // },
3941
+ // {
3942
+ // "exchange": "gateio",
3943
+ // "health_interval": 3000,
3944
+ // "health_priority": 3,
3945
+ // "weight": 1
3946
+ // },
3947
+ // {
3948
+ // "exchange": "bybit",
3949
+ // "health_interval": 3000,
3950
+ // "health_priority": 2,
3951
+ // "weight": 1
3952
+ // }
3953
+ // ],
3954
+ // "constituent_indices": null,
3955
+ // "description": "BTC Spot",
3956
+ // "health_interval": 300,
3957
+ // "id": 2,
3958
+ // "impact_size": "1.000000000000000000",
3959
+ // "index_type": "spot_pair",
3960
+ // "is_composite": false,
3961
+ // "price_method": "ltp",
3962
+ // "quoting_asset_id": 4,
3963
+ // "symbol": ".DEXBTUSDT",
3964
+ // "tick_size": "0.100000000000000000",
3965
+ // "underlying_asset_id": 2
3966
+ // },
3967
+ // "liquidation_penalty_factor": "1",
3968
+ // "auction_start_time": "2025-12-22T12:18:52Z",
3969
+ // "is_quanto": false,
3970
+ // "state": "live",
3971
+ // "id": 84,
3972
+ // "settling_asset": {
3973
+ // "base_withdrawal_fee": "0.000000000000000000",
3974
+ // "id": 4,
3975
+ // "interest_credit": false,
3976
+ // "interest_slabs": null,
3977
+ // "kyc_deposit_limit": "0.000000000000000000",
3978
+ // "kyc_withdrawal_limit": "0.000000000000000000",
3979
+ // "min_withdrawal_amount": "0.000000000000000000",
3980
+ // "minimum_precision": 2,
3981
+ // "name": "Tether",
3982
+ // "networks": [],
3983
+ // "precision": 8,
3984
+ // "sort_priority": null,
3985
+ // "symbol": "USDT",
3986
+ // "variable_withdrawal_fee": "0.000000000000000000"
3987
+ // },
3988
+ // "tick_size": "0.1",
3989
+ // "impact_size": 4000,
3990
+ // "insurance_fund_margin_contribution": "5",
3991
+ // "maker_commission_rate": "0.0002",
3992
+ // "ui_config": {
3993
+ // "default_trading_view_candle": "15",
3994
+ // "leverage_slider_values": [1,2,3,5,10,50,100],
3995
+ // "price_clubbing_values": [0.1,1,10,50],
3996
+ // "show_bracket_orders": false,
3997
+ // "sort_priority": 1
3998
+ // },
3999
+ // "annualized_funding": "0",
4000
+ // "strike_price": null,
4001
+ // "price_band": "100",
4002
+ // "funding_method": "mark_price",
4003
+ // "contract_value": "0.001",
4004
+ // "auction_finish_time": null,
4005
+ // "product_specs": {
4006
+ // "vol_expiry_time": 172800
4007
+ // },
4008
+ // "launch_time": "2020-04-20T08:37:05Z",
4009
+ // "basis_factor_max_limit": "1000",
4010
+ // "initial_margin": "1",
4011
+ // "notional_type": "vanilla",
4012
+ // "contract_unit_currency": "BTC",
4013
+ // "disruption_reason": null,
4014
+ // "underlying_asset": {
4015
+ // "base_withdrawal_fee": "0.000000000000000000",
4016
+ // "id": 2,
4017
+ // "interest_credit": false,
4018
+ // "interest_slabs": null,
4019
+ // "kyc_deposit_limit": "0.000000000000000000",
4020
+ // "kyc_withdrawal_limit": "0.000000000000000000",
4021
+ // "min_withdrawal_amount": "0.000000000000000000",
4022
+ // "minimum_precision": 4,
4023
+ // "name": "Bitcoin",
4024
+ // "networks": [],
4025
+ // "precision": 8,
4026
+ // "sort_priority": 1,
4027
+ // "symbol": "BTC",
4028
+ // "variable_withdrawal_fee": "0.000000000000000000"
4029
+ // },
4030
+ // "initial_margin_scaling_factor": "0",
4031
+ // "position_size_limit": 10000000,
4032
+ // "max_leverage_notional": "10000",
4033
+ // "settlement_price": null,
4034
+ // "barrier_price": null,
4035
+ // "maintenance_margin": "0.5",
4036
+ // "default_leverage": "50.000000000000000000",
4037
+ // "settlement_time": null,
4038
+ // "description": "BTCUSDT-Bitcoin Perpetual futures, quoted,settled & margined in Tether(USDT)",
4039
+ // "contract_type": "perpetual_futures"
4040
+ // },
4041
+ // "product_id": 84,
4042
+ // "product_symbol": "BTCUSDT",
4043
+ // "realized_cashflow": "0.000000000000000000",
4044
+ // "realized_funding": "0",
4045
+ // "realized_holding_cost": "0",
4046
+ // "realized_pnl": "0",
4047
+ // "size": 1,
4048
+ // "unrealized_pnl": "-0.00519112",
4049
+ // "updated_at": "2026-01-14T11:24:35.801586Z",
4050
+ // "user_id": 30084879
4051
+ // }
4052
+ //
4053
+ const marketId = this.safeString(info, 'product_symbol');
4054
+ const datetime = this.safeString(info, 'created_at');
4055
+ return {
4056
+ 'info': info,
4057
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
4058
+ 'rank': this.safeInteger(info, 'adl_level'),
4059
+ 'rating': undefined,
4060
+ 'percentage': undefined,
4061
+ 'timestamp': this.parse8601(datetime),
4062
+ 'datetime': datetime,
4063
+ };
4064
+ }
3698
4065
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3699
4066
  const requestPath = '/' + this.version + '/' + this.implodeParams(path, params);
3700
4067
  let url = this.urls['api'][api] + requestPath;
@@ -4279,6 +4279,7 @@ class gate extends gate$1["default"] {
4279
4279
  * @param {int} [params.price_type] *contract only* 0 latest deal price, 1 mark price, 2 index price
4280
4280
  * @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
4281
4281
  * @param {bool} [params.unifiedAccount] set to true for creating an order in the unified account
4282
+ * @param {string} [params.clientOrderId] the clientOrderId of the order
4282
4283
  * @returns {object|undefined} [An order structure]{@link https://docs.ccxt.com/?id=order-structure}
4283
4284
  */
4284
4285
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -4472,7 +4473,8 @@ class gate extends gate$1["default"] {
4472
4473
  }
4473
4474
  // we only omit the unified params here
4474
4475
  // this is because the other params will get extended into the request
4475
- params = this.omit(params, ['stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'reduceOnly', 'timeInForce', 'postOnly']);
4476
+ let clientOrderId = this.safeString2(params, 'text', 'clientOrderId');
4477
+ params = this.omit(params, ['stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'reduceOnly', 'timeInForce', 'postOnly', 'clientOrderId']);
4476
4478
  const isLimitOrder = (type === 'limit');
4477
4479
  const isMarketOrder = (type === 'market');
4478
4480
  if (isLimitOrder && price === undefined) {
@@ -4585,7 +4587,6 @@ class gate extends gate$1["default"] {
4585
4587
  request['time_in_force'] = timeInForce;
4586
4588
  }
4587
4589
  }
4588
- let clientOrderId = this.safeString2(params, 'text', 'clientOrderId');
4589
4590
  const textIsRequired = this.safeBool(params, 'textIsRequired', false);
4590
4591
  if (clientOrderId !== undefined) {
4591
4592
  // user-defined, must follow the rules if not empty
@@ -4595,7 +4596,7 @@ class gate extends gate$1["default"] {
4595
4596
  if (clientOrderId.length > 28) {
4596
4597
  throw new errors.BadRequest(this.id + ' createOrder () clientOrderId or text param must be up to 28 characters');
4597
4598
  }
4598
- params = this.omit(params, ['text', 'clientOrderId', 'textIsRequired']);
4599
+ params = this.omit(params, 'textIsRequired');
4599
4600
  if (clientOrderId[0] !== 't') {
4600
4601
  clientOrderId = 't-' + clientOrderId;
4601
4602
  }
@@ -4609,6 +4610,9 @@ class gate extends gate$1["default"] {
4609
4610
  }
4610
4611
  }
4611
4612
  else {
4613
+ if (clientOrderId !== undefined) {
4614
+ request['text'] = clientOrderId;
4615
+ }
4612
4616
  if (market['option']) {
4613
4617
  throw new errors.NotSupported(this.id + ' createOrder() conditional option orders are not supported');
4614
4618
  }
@@ -5135,6 +5139,9 @@ class gate extends gate$1["default"] {
5135
5139
  if (lastTradeTimestampStr !== undefined) {
5136
5140
  lastTradeTimestamp = this.parseToInt(lastTradeTimestampStr);
5137
5141
  }
5142
+ const initial = this.safeDict(order, 'initial', {});
5143
+ const reduceOnlyInitial = this.safeBool(initial, 'is_reduce_only');
5144
+ const reduceOnly = this.safeBool(order, 'is_reduce_only', reduceOnlyInitial);
5138
5145
  return this.safeOrder({
5139
5146
  'id': this.safeString(order, 'id'),
5140
5147
  'clientOrderId': this.safeString(order, 'text'),
@@ -5146,7 +5153,7 @@ class gate extends gate$1["default"] {
5146
5153
  'type': type,
5147
5154
  'timeInForce': timeInForce,
5148
5155
  'postOnly': postOnly,
5149
- 'reduceOnly': this.safeValue(order, 'is_reduce_only'),
5156
+ 'reduceOnly': reduceOnly,
5150
5157
  'side': side,
5151
5158
  'price': price,
5152
5159
  'triggerPrice': triggerPrice,