ccxt 4.3.59 → 4.3.60

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.
@@ -288,9 +288,11 @@ class bingx extends bingx$1 {
288
288
  'post': {
289
289
  'trade/order': 2,
290
290
  'trade/leverage': 2,
291
- 'trade/allOpenOrders': 2,
292
291
  'trade/closeAllPositions': 2,
293
292
  },
293
+ 'delete': {
294
+ 'trade/allOpenOrders': 2,
295
+ },
294
296
  },
295
297
  },
296
298
  },
@@ -1538,8 +1540,9 @@ class bingx extends bingx$1 {
1538
1540
  * @method
1539
1541
  * @name bingx#fetchTicker
1540
1542
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1541
- * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Ticker
1542
- * @see https://bingx-api.github.io/docs/#/spot/market-api.html#24%E5%B0%8F%E6%97%B6%E4%BB%B7%E6%A0%BC%E5%8F%98%E5%8A%A8%E6%83%85%E5%86%B5
1543
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Get%20Ticker
1544
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#24-hour%20price%20changes
1545
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Query%2024-Hour%20Price%20Change
1543
1546
  * @param {string} symbol unified symbol of the market to fetch the ticker for
1544
1547
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1545
1548
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -1554,8 +1557,41 @@ class bingx extends bingx$1 {
1554
1557
  response = await this.spotV1PublicGetTicker24hr(this.extend(request, params));
1555
1558
  }
1556
1559
  else {
1557
- response = await this.swapV2PublicGetQuoteTicker(this.extend(request, params));
1560
+ if (market['inverse']) {
1561
+ response = await this.cswapV1PublicGetMarketTicker(this.extend(request, params));
1562
+ }
1563
+ else {
1564
+ response = await this.swapV2PublicGetQuoteTicker(this.extend(request, params));
1565
+ }
1558
1566
  }
1567
+ //
1568
+ // spot and swap
1569
+ //
1570
+ // {
1571
+ // "code": 0,
1572
+ // "msg": "",
1573
+ // "timestamp": 1720647285296,
1574
+ // "data": [
1575
+ // {
1576
+ // "symbol": "SOL-USD",
1577
+ // "priceChange": "-2.418",
1578
+ // "priceChangePercent": "-1.6900%",
1579
+ // "lastPrice": "140.574",
1580
+ // "lastQty": "1",
1581
+ // "highPrice": "146.190",
1582
+ // "lowPrice": "138.586",
1583
+ // "volume": "1464648.00",
1584
+ // "quoteVolume": "102928.12",
1585
+ // "openPrice": "142.994",
1586
+ // "closeTime": "1720647284976",
1587
+ // "bidPrice": "140.573",
1588
+ // "bidQty": "372",
1589
+ // "askPrice": "140.577",
1590
+ // "askQty": "58"
1591
+ // }
1592
+ // ]
1593
+ // }
1594
+ //
1559
1595
  const data = this.safeList(response, 'data');
1560
1596
  if (data !== undefined) {
1561
1597
  const first = this.safeDict(data, 0, {});
@@ -1569,7 +1605,9 @@ class bingx extends bingx$1 {
1569
1605
  * @method
1570
1606
  * @name bingx#fetchTickers
1571
1607
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1572
- * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Ticker
1608
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Get%20Ticker
1609
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#24-hour%20price%20changes
1610
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Query%2024-Hour%20Price%20Change
1573
1611
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1574
1612
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1575
1613
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -1585,13 +1623,49 @@ class bingx extends bingx$1 {
1585
1623
  }
1586
1624
  let type = undefined;
1587
1625
  [type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
1626
+ let subType = undefined;
1627
+ [subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params);
1588
1628
  let response = undefined;
1589
1629
  if (type === 'spot') {
1590
1630
  response = await this.spotV1PublicGetTicker24hr(params);
1591
1631
  }
1592
1632
  else {
1593
- response = await this.swapV2PublicGetQuoteTicker(params);
1633
+ if (subType === 'inverse') {
1634
+ response = await this.cswapV1PublicGetMarketTicker(params);
1635
+ }
1636
+ else {
1637
+ response = await this.swapV2PublicGetQuoteTicker(params);
1638
+ }
1594
1639
  }
1640
+ //
1641
+ // spot and swap
1642
+ //
1643
+ // {
1644
+ // "code": 0,
1645
+ // "msg": "",
1646
+ // "timestamp": 1720647285296,
1647
+ // "data": [
1648
+ // {
1649
+ // "symbol": "SOL-USD",
1650
+ // "priceChange": "-2.418",
1651
+ // "priceChangePercent": "-1.6900%",
1652
+ // "lastPrice": "140.574",
1653
+ // "lastQty": "1",
1654
+ // "highPrice": "146.190",
1655
+ // "lowPrice": "138.586",
1656
+ // "volume": "1464648.00",
1657
+ // "quoteVolume": "102928.12",
1658
+ // "openPrice": "142.994",
1659
+ // "closeTime": "1720647284976",
1660
+ // "bidPrice": "140.573",
1661
+ // "bidQty": "372",
1662
+ // "askPrice": "140.577",
1663
+ // "askQty": "58"
1664
+ // },
1665
+ // ...
1666
+ // ]
1667
+ // }
1668
+ //
1595
1669
  const tickers = this.safeList(response, 'data');
1596
1670
  return this.parseTickers(tickers, symbols);
1597
1671
  }
@@ -2622,7 +2696,9 @@ class bingx extends bingx$1 {
2622
2696
  // side: 'SELL'
2623
2697
  // }
2624
2698
  // }
2699
+ //
2625
2700
  // stop loss order
2701
+ //
2626
2702
  // {
2627
2703
  // "symbol": "ETH-USDT",
2628
2704
  // "orderId": "1792461744476422144",
@@ -2642,6 +2718,52 @@ class bingx extends bingx$1 {
2642
2718
  // "clientOrderID": ""
2643
2719
  // }
2644
2720
  //
2721
+ // inverse swap cancelAllOrders
2722
+ //
2723
+ // {
2724
+ // "symbol": "SOL-USD",
2725
+ // "orderId": "1809845251327672320",
2726
+ // "side": "BUY",
2727
+ // "positionSide": "LONG",
2728
+ // "type": "LIMIT",
2729
+ // "quantity": 1,
2730
+ // "origQty": "0",
2731
+ // "price": "90",
2732
+ // "executedQty": "0",
2733
+ // "avgPrice": "0",
2734
+ // "cumQuote": "0",
2735
+ // "stopPrice": "",
2736
+ // "profit": "0.0000",
2737
+ // "commission": "0.000000",
2738
+ // "status": "CANCELLED",
2739
+ // "time": 1720335707872,
2740
+ // "updateTime": 1720335707912,
2741
+ // "clientOrderId": "",
2742
+ // "leverage": "",
2743
+ // "takeProfit": {
2744
+ // "type": "",
2745
+ // "quantity": 0,
2746
+ // "stopPrice": 0,
2747
+ // "price": 0,
2748
+ // "workingType": "",
2749
+ // "stopGuaranteed": ""
2750
+ // },
2751
+ // "stopLoss": {
2752
+ // "type": "",
2753
+ // "quantity": 0,
2754
+ // "stopPrice": 0,
2755
+ // "price": 0,
2756
+ // "workingType": "",
2757
+ // "stopGuaranteed": ""
2758
+ // },
2759
+ // "advanceAttr": 0,
2760
+ // "positionID": 0,
2761
+ // "takeProfitEntrustPrice": 0,
2762
+ // "stopLossEntrustPrice": 0,
2763
+ // "orderType": "",
2764
+ // "workingType": ""
2765
+ // }
2766
+ //
2645
2767
  const info = order;
2646
2768
  const newOrder = this.safeDict2(order, 'newOrderResponse', 'orderOpenResponse');
2647
2769
  if (newOrder !== undefined) {
@@ -2847,6 +2969,7 @@ class bingx extends bingx$1 {
2847
2969
  * @description cancel all open orders
2848
2970
  * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20orders%20by%20symbol
2849
2971
  * @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Cancel%20All%20Orders
2972
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Cancel%20all%20orders
2850
2973
  * @param {string} [symbol] unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
2851
2974
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2852
2975
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -2886,36 +3009,96 @@ class bingx extends bingx$1 {
2886
3009
  //
2887
3010
  }
2888
3011
  else if (market['swap']) {
2889
- response = await this.swapV2PrivateDeleteTradeAllOpenOrders(this.extend(request, params));
2890
- //
2891
- // {
2892
- // "code": 0,
2893
- // "msg": "",
2894
- // "data": {
2895
- // "success": [
2896
- // {
2897
- // "symbol": "LINK-USDT",
2898
- // "orderId": 1597783835095859200,
2899
- // "side": "BUY",
2900
- // "positionSide": "LONG",
2901
- // "type": "TRIGGER_LIMIT",
2902
- // "origQty": "5.0",
2903
- // "price": "9.0000",
2904
- // "executedQty": "0.0",
2905
- // "avgPrice": "0.0000",
2906
- // "cumQuote": "0",
2907
- // "stopPrice": "9.5000",
2908
- // "profit": "",
2909
- // "commission": "",
2910
- // "status": "NEW",
2911
- // "time": 1669776326000,
2912
- // "updateTime": 1669776326000
2913
- // }
2914
- // ],
2915
- // "failed": null
2916
- // }
2917
- // }
2918
- //
3012
+ if (market['inverse']) {
3013
+ response = await this.cswapV1PrivateDeleteTradeAllOpenOrders(this.extend(request, params));
3014
+ //
3015
+ // {
3016
+ // "code": 0,
3017
+ // "msg": "",
3018
+ // "timestamp": 1720501468364,
3019
+ // "data": {
3020
+ // "success": [
3021
+ // {
3022
+ // "symbol": "SOL-USD",
3023
+ // "orderId": "1809845251327672320",
3024
+ // "side": "BUY",
3025
+ // "positionSide": "LONG",
3026
+ // "type": "LIMIT",
3027
+ // "quantity": 1,
3028
+ // "origQty": "0",
3029
+ // "price": "90",
3030
+ // "executedQty": "0",
3031
+ // "avgPrice": "0",
3032
+ // "cumQuote": "0",
3033
+ // "stopPrice": "",
3034
+ // "profit": "0.0000",
3035
+ // "commission": "0.000000",
3036
+ // "status": "CANCELLED",
3037
+ // "time": 1720335707872,
3038
+ // "updateTime": 1720335707912,
3039
+ // "clientOrderId": "",
3040
+ // "leverage": "",
3041
+ // "takeProfit": {
3042
+ // "type": "",
3043
+ // "quantity": 0,
3044
+ // "stopPrice": 0,
3045
+ // "price": 0,
3046
+ // "workingType": "",
3047
+ // "stopGuaranteed": ""
3048
+ // },
3049
+ // "stopLoss": {
3050
+ // "type": "",
3051
+ // "quantity": 0,
3052
+ // "stopPrice": 0,
3053
+ // "price": 0,
3054
+ // "workingType": "",
3055
+ // "stopGuaranteed": ""
3056
+ // },
3057
+ // "advanceAttr": 0,
3058
+ // "positionID": 0,
3059
+ // "takeProfitEntrustPrice": 0,
3060
+ // "stopLossEntrustPrice": 0,
3061
+ // "orderType": "",
3062
+ // "workingType": ""
3063
+ // }
3064
+ // ],
3065
+ // "failed": null
3066
+ // }
3067
+ // }
3068
+ //
3069
+ }
3070
+ else {
3071
+ response = await this.swapV2PrivateDeleteTradeAllOpenOrders(this.extend(request, params));
3072
+ //
3073
+ // {
3074
+ // "code": 0,
3075
+ // "msg": "",
3076
+ // "data": {
3077
+ // "success": [
3078
+ // {
3079
+ // "symbol": "LINK-USDT",
3080
+ // "orderId": 1597783835095859200,
3081
+ // "side": "BUY",
3082
+ // "positionSide": "LONG",
3083
+ // "type": "TRIGGER_LIMIT",
3084
+ // "origQty": "5.0",
3085
+ // "price": "9.0000",
3086
+ // "executedQty": "0.0",
3087
+ // "avgPrice": "0.0000",
3088
+ // "cumQuote": "0",
3089
+ // "stopPrice": "9.5000",
3090
+ // "profit": "",
3091
+ // "commission": "",
3092
+ // "status": "NEW",
3093
+ // "time": 1669776326000,
3094
+ // "updateTime": 1669776326000
3095
+ // }
3096
+ // ],
3097
+ // "failed": null
3098
+ // }
3099
+ // }
3100
+ //
3101
+ }
2919
3102
  }
2920
3103
  else {
2921
3104
  throw new errors.BadRequest(this.id + ' cancelAllOrders is only supported for spot and swap markets.');
@@ -3968,6 +4151,7 @@ class bingx extends bingx$1 {
3968
4151
  * @name bingx#fetchLeverage
3969
4152
  * @description fetch the set leverage for a market
3970
4153
  * @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Query%20Leverage
4154
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Leverage
3971
4155
  * @param {string} symbol unified market symbol
3972
4156
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3973
4157
  * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
@@ -3977,21 +4161,79 @@ class bingx extends bingx$1 {
3977
4161
  const request = {
3978
4162
  'symbol': market['id'],
3979
4163
  };
3980
- const response = await this.swapV2PrivateGetTradeLeverage(this.extend(request, params));
3981
- //
3982
- // {
3983
- // "code": 0,
3984
- // "msg": "",
3985
- // "data": {
3986
- // "longLeverage": 6,
3987
- // "shortLeverage": 6
3988
- // }
3989
- // }
3990
- //
4164
+ let response = undefined;
4165
+ if (market['inverse']) {
4166
+ response = await this.cswapV1PrivateGetTradeLeverage(this.extend(request, params));
4167
+ //
4168
+ // {
4169
+ // "code": 0,
4170
+ // "msg": "",
4171
+ // "timestamp": 1720683803391,
4172
+ // "data": {
4173
+ // "symbol": "SOL-USD",
4174
+ // "longLeverage": 5,
4175
+ // "shortLeverage": 5,
4176
+ // "maxLongLeverage": 50,
4177
+ // "maxShortLeverage": 50,
4178
+ // "availableLongVol": "4000000",
4179
+ // "availableShortVol": "4000000"
4180
+ // }
4181
+ // }
4182
+ //
4183
+ }
4184
+ else {
4185
+ response = await this.swapV2PrivateGetTradeLeverage(this.extend(request, params));
4186
+ //
4187
+ // {
4188
+ // "code": 0,
4189
+ // "msg": "",
4190
+ // "data": {
4191
+ // "longLeverage": 5,
4192
+ // "shortLeverage": 5,
4193
+ // "maxLongLeverage": 125,
4194
+ // "maxShortLeverage": 125,
4195
+ // "availableLongVol": "0.0000",
4196
+ // "availableShortVol": "0.0000",
4197
+ // "availableLongVal": "0.0",
4198
+ // "availableShortVal": "0.0",
4199
+ // "maxPositionLongVal": "0.0",
4200
+ // "maxPositionShortVal": "0.0"
4201
+ // }
4202
+ // }
4203
+ //
4204
+ }
3991
4205
  const data = this.safeDict(response, 'data', {});
3992
4206
  return this.parseLeverage(data, market);
3993
4207
  }
3994
4208
  parseLeverage(leverage, market = undefined) {
4209
+ //
4210
+ // linear swap
4211
+ //
4212
+ // {
4213
+ // "longLeverage": 5,
4214
+ // "shortLeverage": 5,
4215
+ // "maxLongLeverage": 125,
4216
+ // "maxShortLeverage": 125,
4217
+ // "availableLongVol": "0.0000",
4218
+ // "availableShortVol": "0.0000",
4219
+ // "availableLongVal": "0.0",
4220
+ // "availableShortVal": "0.0",
4221
+ // "maxPositionLongVal": "0.0",
4222
+ // "maxPositionShortVal": "0.0"
4223
+ // }
4224
+ //
4225
+ // inverse swap
4226
+ //
4227
+ // {
4228
+ // "symbol": "SOL-USD",
4229
+ // "longLeverage": 5,
4230
+ // "shortLeverage": 5,
4231
+ // "maxLongLeverage": 50,
4232
+ // "maxShortLeverage": 50,
4233
+ // "availableLongVol": "4000000",
4234
+ // "availableShortVol": "4000000"
4235
+ // }
4236
+ //
3995
4237
  const marketId = this.safeString(leverage, 'symbol');
3996
4238
  return {
3997
4239
  'info': leverage,
@@ -4007,6 +4249,7 @@ class bingx extends bingx$1 {
4007
4249
  * @name bingx#setLeverage
4008
4250
  * @description set the level of leverage for a market
4009
4251
  * @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Switch%20Leverage
4252
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Modify%20Leverage
4010
4253
  * @param {float} leverage the rate of leverage
4011
4254
  * @param {string} symbol unified market symbol
4012
4255
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -4025,17 +4268,44 @@ class bingx extends bingx$1 {
4025
4268
  'side': side,
4026
4269
  'leverage': leverage,
4027
4270
  };
4028
- //
4029
- // {
4030
- // "code": 0,
4031
- // "msg": "",
4032
- // "data": {
4033
- // "leverage": 6,
4034
- // "symbol": "BTC-USDT"
4035
- // }
4036
- // }
4037
- //
4038
- return await this.swapV2PrivatePostTradeLeverage(this.extend(request, params));
4271
+ if (market['inverse']) {
4272
+ return await this.cswapV1PrivatePostTradeLeverage(this.extend(request, params));
4273
+ //
4274
+ // {
4275
+ // "code": 0,
4276
+ // "msg": "",
4277
+ // "timestamp": 1720725058059,
4278
+ // "data": {
4279
+ // "symbol": "SOL-USD",
4280
+ // "longLeverage": 10,
4281
+ // "shortLeverage": 5,
4282
+ // "maxLongLeverage": 50,
4283
+ // "maxShortLeverage": 50,
4284
+ // "availableLongVol": "4000000",
4285
+ // "availableShortVol": "4000000"
4286
+ // }
4287
+ // }
4288
+ //
4289
+ }
4290
+ else {
4291
+ return await this.swapV2PrivatePostTradeLeverage(this.extend(request, params));
4292
+ //
4293
+ // {
4294
+ // "code": 0,
4295
+ // "msg": "",
4296
+ // "data": {
4297
+ // "leverage": 10,
4298
+ // "symbol": "BTC-USDT",
4299
+ // "availableLongVol": "0.0000",
4300
+ // "availableShortVol": "0.0000",
4301
+ // "availableLongVal": "0.0",
4302
+ // "availableShortVal": "0.0",
4303
+ // "maxPositionLongVal": "0.0",
4304
+ // "maxPositionShortVal": "0.0"
4305
+ // }
4306
+ // }
4307
+ //
4308
+ }
4039
4309
  }
4040
4310
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4041
4311
  /**
@@ -4391,62 +4661,71 @@ class bingx extends bingx$1 {
4391
4661
  * @name bingx#closePosition
4392
4662
  * @description closes open positions for a market
4393
4663
  * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#One-Click%20Close%20All%20Positions
4664
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Close%20all%20positions%20in%20bulk
4394
4665
  * @param {string} symbol Unified CCXT market symbol
4395
4666
  * @param {string} [side] not used by bingx
4396
4667
  * @param {object} [params] extra parameters specific to the bingx api endpoint
4397
- * @param {string|undefined} [params.positionId] it is recommended to fill in this parameter when closing a position
4668
+ * @param {string|undefined} [params.positionId] the id of the position you would like to close
4398
4669
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4399
4670
  */
4400
4671
  await this.loadMarkets();
4672
+ const market = this.market(symbol);
4401
4673
  const positionId = this.safeString(params, 'positionId');
4402
- params = this.omit(params, 'positionId');
4674
+ const request = {};
4403
4675
  let response = undefined;
4404
4676
  if (positionId !== undefined) {
4405
- const request = {
4406
- 'positionId': positionId,
4407
- };
4408
4677
  response = await this.swapV1PrivatePostTradeClosePosition(this.extend(request, params));
4678
+ //
4679
+ // {
4680
+ // "code": 0,
4681
+ // "msg": "",
4682
+ // "timestamp": 1710992264190,
4683
+ // "data": {
4684
+ // "orderId": 1770656007907930112,
4685
+ // "positionId": "1751667128353910784",
4686
+ // "symbol": "LTC-USDT",
4687
+ // "side": "Ask",
4688
+ // "type": "MARKET",
4689
+ // "positionSide": "Long",
4690
+ // "origQty": "0.2"
4691
+ // }
4692
+ // }
4693
+ //
4409
4694
  }
4410
4695
  else {
4411
- const market = this.market(symbol);
4412
- const request = {
4413
- 'symbol': market['id'],
4414
- };
4415
- response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
4696
+ request['symbol'] = market['id'];
4697
+ if (market['inverse']) {
4698
+ response = await this.cswapV1PrivatePostTradeCloseAllPositions(this.extend(request, params));
4699
+ //
4700
+ // {
4701
+ // "code": 0,
4702
+ // "msg": "",
4703
+ // "timestamp": 1720771601428,
4704
+ // "data": {
4705
+ // "success": ["1811673520637231104"],
4706
+ // "failed": null
4707
+ // }
4708
+ // }
4709
+ //
4710
+ }
4711
+ else {
4712
+ response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
4713
+ //
4714
+ // {
4715
+ // "code": 0,
4716
+ // "msg": "",
4717
+ // "data": {
4718
+ // "success": [
4719
+ // 1727686766700486656,
4720
+ // ],
4721
+ // "failed": null
4722
+ // }
4723
+ // }
4724
+ //
4725
+ }
4416
4726
  }
4417
- //
4418
- // swapV1PrivatePostTradeClosePosition
4419
- //
4420
- // {
4421
- // "code": 0,
4422
- // "msg": "",
4423
- // "timestamp": 1710992264190,
4424
- // "data": {
4425
- // "orderId": 1770656007907930112,
4426
- // "positionId": "1751667128353910784",
4427
- // "symbol": "LTC-USDT",
4428
- // "side": "Ask",
4429
- // "type": "MARKET",
4430
- // "positionSide": "Long",
4431
- // "origQty": "0.2"
4432
- // }
4433
- // }
4434
- //
4435
- // swapV2PrivatePostTradeCloseAllPositions
4436
- //
4437
- // {
4438
- // "code": 0,
4439
- // "msg": "",
4440
- // "data": {
4441
- // "success": [
4442
- // 1727686766700486656,
4443
- // ],
4444
- // "failed": null
4445
- // }
4446
- // }
4447
- //
4448
4727
  const data = this.safeDict(response, 'data');
4449
- return this.parseOrder(data);
4728
+ return this.parseOrder(data, market);
4450
4729
  }
4451
4730
  async closeAllPositions(params = {}) {
4452
4731
  /**
@@ -4454,35 +4733,55 @@ class bingx extends bingx$1 {
4454
4733
  * @name bitget#closePositions
4455
4734
  * @description closes open positions for a market
4456
4735
  * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#One-Click%20Close%20All%20Positions
4457
- * @param {object} [params] extra parameters specific to the okx api endpoint
4736
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Close%20all%20positions%20in%20bulk
4737
+ * @param {object} [params] extra parameters specific to the bingx api endpoint
4458
4738
  * @param {string} [params.recvWindow] request valid time window value
4459
- * @returns {object[]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
4739
+ * @returns {object[]} [a list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
4460
4740
  */
4461
4741
  await this.loadMarkets();
4462
4742
  const defaultRecvWindow = this.safeInteger(this.options, 'recvWindow');
4463
4743
  const recvWindow = this.safeInteger(this.parseParams, 'recvWindow', defaultRecvWindow);
4464
4744
  let marketType = undefined;
4465
4745
  [marketType, params] = this.handleMarketTypeAndParams('closeAllPositions', undefined, params);
4746
+ let subType = undefined;
4747
+ [subType, params] = this.handleSubTypeAndParams('closeAllPositions', undefined, params);
4466
4748
  if (marketType === 'margin') {
4467
4749
  throw new errors.BadRequest(this.id + ' closePositions () cannot be used for ' + marketType + ' markets');
4468
4750
  }
4469
4751
  const request = {
4470
4752
  'recvWindow': recvWindow,
4471
4753
  };
4472
- const response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
4473
- //
4474
- // {
4475
- // "code": 0,
4476
- // "msg": "",
4477
- // "data": {
4478
- // "success": [
4479
- // 1727686766700486656,
4480
- // 1727686767048613888
4481
- // ],
4482
- // "failed": null
4483
- // }
4484
- // }
4485
- //
4754
+ let response = undefined;
4755
+ if (subType === 'inverse') {
4756
+ response = await this.cswapV1PrivatePostTradeCloseAllPositions(this.extend(request, params));
4757
+ //
4758
+ // {
4759
+ // "code": 0,
4760
+ // "msg": "",
4761
+ // "timestamp": 1720771601428,
4762
+ // "data": {
4763
+ // "success": ["1811673520637231104"],
4764
+ // "failed": null
4765
+ // }
4766
+ // }
4767
+ //
4768
+ }
4769
+ else {
4770
+ response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
4771
+ //
4772
+ // {
4773
+ // "code": 0,
4774
+ // "msg": "",
4775
+ // "data": {
4776
+ // "success": [
4777
+ // 1727686766700486656,
4778
+ // 1727686767048613888
4779
+ // ],
4780
+ // "failed": null
4781
+ // }
4782
+ // }
4783
+ //
4784
+ }
4486
4785
  const data = this.safeDict(response, 'data', {});
4487
4786
  const success = this.safeList(data, 'success', []);
4488
4787
  const positions = [];