ccxt 4.3.67 → 4.3.68

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.
package/dist/cjs/ccxt.js CHANGED
@@ -191,7 +191,7 @@ var xt$1 = require('./src/pro/xt.js');
191
191
 
192
192
  //-----------------------------------------------------------------------------
193
193
  // this is updated by vss.js when building
194
- const version = '4.3.67';
194
+ const version = '4.3.68';
195
195
  Exchange["default"].ccxtVersion = version;
196
196
  const exchanges = {
197
197
  'ace': ace,
@@ -1588,8 +1588,10 @@ class Exchange {
1588
1588
  if (value === undefined) {
1589
1589
  return defaultValue;
1590
1590
  }
1591
- if (typeof value === 'object') {
1592
- return value;
1591
+ if ((typeof value === 'object')) {
1592
+ if (!Array.isArray(value)) {
1593
+ return value;
1594
+ }
1593
1595
  }
1594
1596
  return defaultValue;
1595
1597
  }
@@ -3478,7 +3480,7 @@ class Exchange {
3478
3480
  }
3479
3481
  else {
3480
3482
  // otherwise, try to use the global-scope 'defaultNetwork' value (even if that network is not supported by currency, it doesn't make any problem, this will be just used "at first" if currency supports this network at all)
3481
- const defaultNetwork = this.safeDict(this.options, 'defaultNetwork');
3483
+ const defaultNetwork = this.safeString(this.options, 'defaultNetwork');
3482
3484
  if (defaultNetwork !== undefined) {
3483
3485
  defaultNetworkCode = defaultNetwork;
3484
3486
  }
@@ -80,7 +80,7 @@ const safeInteger2 = (o, k1, k2, $default) => {
80
80
  return isNumber(n) ? n : $default;
81
81
  };
82
82
  const safeIntegerProduct2 = (o, k1, k2, $factor, $default) => {
83
- const n = asInteger(prop2(o, k1, k2));
83
+ const n = asFloat(prop2(o, k1, k2));
84
84
  return isNumber(n) ? parseInt(n * $factor) : $default;
85
85
  };
86
86
  const safeTimestamp2 = (o, k1, k2, $default) => {
@@ -127,7 +127,7 @@ const safeIntegerN = (o, k, $default) => {
127
127
  return isNumber(n) ? n : $default;
128
128
  };
129
129
  const safeIntegerProductN = (o, k, $factor, $default) => {
130
- const n = asInteger(getValueFromKeysInArray(o, k));
130
+ const n = asFloat(getValueFromKeysInArray(o, k));
131
131
  return isNumber(n) ? parseInt(n * $factor) : $default;
132
132
  };
133
133
  const safeTimestampN = (o, k, $default) => {
@@ -48,6 +48,7 @@ class bingx extends bingx$1 {
48
48
  'createTrailingPercentOrder': true,
49
49
  'createTriggerOrder': true,
50
50
  'fetchBalance': true,
51
+ 'fetchCanceledOrders': true,
51
52
  'fetchClosedOrders': true,
52
53
  'fetchCurrencies': true,
53
54
  'fetchDepositAddress': true,
@@ -3011,8 +3012,7 @@ class bingx extends bingx$1 {
3011
3012
  // "clientOrderID": ""
3012
3013
  // }
3013
3014
  //
3014
- // inverse swap cancelAllOrders, cancelOrder
3015
- // inverse swap cancelAllOrders, cancelOrder, fetchOpenOrders
3015
+ // inverse swap cancelAllOrders, cancelOrder, fetchOrder, fetchOpenOrders, fetchClosedOrders, fetchCanceledOrders
3016
3016
  //
3017
3017
  // {
3018
3018
  // "symbol": "SOL-USD",
@@ -3072,7 +3072,7 @@ class bingx extends bingx$1 {
3072
3072
  const side = this.safeStringLower2(order, 'side', 'S');
3073
3073
  const timestamp = this.safeIntegerN(order, ['time', 'transactTime', 'E']);
3074
3074
  const lastTradeTimestamp = this.safeInteger2(order, 'updateTime', 'T');
3075
- const statusId = this.safeString2(order, 'status', 'X');
3075
+ const statusId = this.safeStringUpper2(order, 'status', 'X');
3076
3076
  let feeCurrencyCode = this.safeString2(order, 'feeAsset', 'N');
3077
3077
  const feeCost = this.safeStringN(order, ['fee', 'commission', 'n']);
3078
3078
  if ((feeCurrencyCode === undefined)) {
@@ -3618,11 +3618,12 @@ class bingx extends bingx$1 {
3618
3618
  * @method
3619
3619
  * @name bingx#fetchOrder
3620
3620
  * @description fetches information on an order made by the user
3621
- * @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Query%20Orders
3622
- * @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Query%20Order
3621
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20details
3622
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20details
3623
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Order
3623
3624
  * @param {string} symbol unified symbol of the market the order was made in
3624
3625
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3625
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3626
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3626
3627
  */
3627
3628
  if (symbol === undefined) {
3628
3629
  throw new errors.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
@@ -3633,68 +3634,124 @@ class bingx extends bingx$1 {
3633
3634
  'symbol': market['id'],
3634
3635
  'orderId': id,
3635
3636
  };
3637
+ let type = undefined;
3638
+ let subType = undefined;
3636
3639
  let response = undefined;
3637
- const [marketType, query] = this.handleMarketTypeAndParams('fetchOrder', market, params);
3638
- if (marketType === 'spot') {
3639
- response = await this.spotV1PrivateGetTradeQuery(this.extend(request, query));
3640
+ [type, params] = this.handleMarketTypeAndParams('fetchOrder', market, params);
3641
+ [subType, params] = this.handleSubTypeAndParams('fetchOrder', market, params);
3642
+ if (type === 'spot') {
3643
+ response = await this.spotV1PrivateGetTradeQuery(this.extend(request, params));
3644
+ //
3645
+ // {
3646
+ // "code": 0,
3647
+ // "msg": "",
3648
+ // "data": {
3649
+ // "symbol": "XRP-USDT",
3650
+ // "orderId": 1514087361158316032,
3651
+ // "price": "0.5",
3652
+ // "origQty": "10",
3653
+ // "executedQty": "0",
3654
+ // "cummulativeQuoteQty": "0",
3655
+ // "status": "CANCELED",
3656
+ // "type": "LIMIT",
3657
+ // "side": "BUY",
3658
+ // "time": 1649821532000,
3659
+ // "updateTime": 1649821543000,
3660
+ // "origQuoteOrderQty": "0",
3661
+ // "fee": "0",
3662
+ // "feeAsset": "XRP"
3663
+ // }
3664
+ // }
3665
+ //
3640
3666
  }
3641
3667
  else {
3642
- response = await this.swapV2PrivateGetTradeOrder(this.extend(request, query));
3668
+ if (subType === 'inverse') {
3669
+ response = await this.cswapV1PrivateGetTradeOrderDetail(this.extend(request, params));
3670
+ //
3671
+ // {
3672
+ // "code": 0,
3673
+ // "msg": "",
3674
+ // "data": {
3675
+ // "order": {
3676
+ // "symbol": "SOL-USD",
3677
+ // "orderId": "1816342420721254400",
3678
+ // "side": "BUY",
3679
+ // "positionSide": "Long",
3680
+ // "type": "LIMIT",
3681
+ // "quantity": 1,
3682
+ // "origQty": "",
3683
+ // "price": "150",
3684
+ // "executedQty": "0",
3685
+ // "avgPrice": "0.000",
3686
+ // "cumQuote": "",
3687
+ // "stopPrice": "",
3688
+ // "profit": "0.0000",
3689
+ // "commission": "0.0000",
3690
+ // "status": "Pending",
3691
+ // "time": 1721884753767,
3692
+ // "updateTime": 1721884753786,
3693
+ // "clientOrderId": "",
3694
+ // "leverage": "",
3695
+ // "takeProfit": {
3696
+ // "type": "TAKE_PROFIT",
3697
+ // "quantity": 0,
3698
+ // "stopPrice": 0,
3699
+ // "price": 0,
3700
+ // "workingType": "MARK_PRICE",
3701
+ // "stopGuaranteed": ""
3702
+ // },
3703
+ // "stopLoss": {
3704
+ // "type": "STOP",
3705
+ // "quantity": 0,
3706
+ // "stopPrice": 0,
3707
+ // "price": 0,
3708
+ // "workingType": "MARK_PRICE",
3709
+ // "stopGuaranteed": ""
3710
+ // },
3711
+ // "advanceAttr": 0,
3712
+ // "positionID": 0,
3713
+ // "takeProfitEntrustPrice": 0,
3714
+ // "stopLossEntrustPrice": 0,
3715
+ // "orderType": "",
3716
+ // "workingType": "MARK_PRICE"
3717
+ // }
3718
+ // }
3719
+ // }
3720
+ //
3721
+ }
3722
+ else {
3723
+ response = await this.swapV2PrivateGetTradeOrder(this.extend(request, params));
3724
+ //
3725
+ // {
3726
+ // "code": 0,
3727
+ // "msg": "",
3728
+ // "data": {
3729
+ // "order": {
3730
+ // "symbol": "BTC-USDT",
3731
+ // "orderId": 1597597642269917184,
3732
+ // "side": "SELL",
3733
+ // "positionSide": "LONG",
3734
+ // "type": "TAKE_PROFIT_MARKET",
3735
+ // "origQty": "1.0000",
3736
+ // "price": "0.0",
3737
+ // "executedQty": "0.0000",
3738
+ // "avgPrice": "0.0",
3739
+ // "cumQuote": "",
3740
+ // "stopPrice": "16494.0",
3741
+ // "profit": "",
3742
+ // "commission": "",
3743
+ // "status": "FILLED",
3744
+ // "time": 1669731935000,
3745
+ // "updateTime": 1669752524000
3746
+ // }
3747
+ // }
3748
+ // }
3749
+ //
3750
+ }
3643
3751
  }
3644
- //
3645
- // spot
3646
- //
3647
- // {
3648
- // "code": 0,
3649
- // "msg": "",
3650
- // "data": {
3651
- // "symbol": "XRP-USDT",
3652
- // "orderId": 1514087361158316032,
3653
- // "price": "0.5",
3654
- // "origQty": "10",
3655
- // "executedQty": "0",
3656
- // "cummulativeQuoteQty": "0",
3657
- // "status": "CANCELED",
3658
- // "type": "LIMIT",
3659
- // "side": "BUY",
3660
- // "time": 1649821532000,
3661
- // "updateTime": 1649821543000,
3662
- // "origQuoteOrderQty": "0",
3663
- // "fee": "0",
3664
- // "feeAsset": "XRP"
3665
- // }
3666
- // }
3667
- //
3668
- // swap
3669
- //
3670
- // {
3671
- // "code": 0,
3672
- // "msg": "",
3673
- // "data": {
3674
- // "order": {
3675
- // "symbol": "BTC-USDT",
3676
- // "orderId": 1597597642269917184,
3677
- // "side": "SELL",
3678
- // "positionSide": "LONG",
3679
- // "type": "TAKE_PROFIT_MARKET",
3680
- // "origQty": "1.0000",
3681
- // "price": "0.0",
3682
- // "executedQty": "0.0000",
3683
- // "avgPrice": "0.0",
3684
- // "cumQuote": "",
3685
- // "stopPrice": "16494.0",
3686
- // "profit": "",
3687
- // "commission": "",
3688
- // "status": "FILLED",
3689
- // "time": 1669731935000,
3690
- // "updateTime": 1669752524000
3691
- // }
3692
- // }
3693
- // }
3694
- //
3695
- const data = this.safeValue(response, 'data');
3696
- const first = this.safeDict(data, 'order', data);
3697
- return this.parseOrder(first, market);
3752
+ const data = this.safeDict(response, 'data', {});
3753
+ const order = this.safeDict(data, 'order', data);
3754
+ return this.parseOrder(order, market);
3698
3755
  }
3699
3756
  async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3700
3757
  /**
@@ -3946,8 +4003,51 @@ class bingx extends bingx$1 {
3946
4003
  * @method
3947
4004
  * @name bingx#fetchClosedOrders
3948
4005
  * @description fetches information on multiple closed orders made by the user
3949
- * @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Query%20Order%20History
3950
- * @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#User's%20Force%20Orders
4006
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20history
4007
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history
4008
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#User's%20History%20Orders
4009
+ * @see https://bingx-api.github.io/docs/#/standard/contract-interface.html#Historical%20order
4010
+ * @param {string} symbol unified market symbol of the closed orders
4011
+ * @param {int} [since] timestamp in ms of the earliest order
4012
+ * @param {int} [limit] the max number of closed orders to return
4013
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4014
+ * @param {int} [params.until] the latest time in ms to fetch orders for
4015
+ * @param {boolean} [params.standard] whether to fetch standard contract orders
4016
+ * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
4017
+ */
4018
+ await this.loadMarkets();
4019
+ const orders = await this.fetchCanceledAndClosedOrders(symbol, since, limit, params);
4020
+ return this.filterBy(orders, 'status', 'closed');
4021
+ }
4022
+ async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4023
+ /**
4024
+ * @method
4025
+ * @name bingx#fetchCanceledOrders
4026
+ * @description fetches information on multiple canceled orders made by the user
4027
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20history
4028
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history
4029
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#User's%20History%20Orders
4030
+ * @see https://bingx-api.github.io/docs/#/standard/contract-interface.html#Historical%20order
4031
+ * @param {string} symbol unified market symbol of the canceled orders
4032
+ * @param {int} [since] timestamp in ms of the earliest order
4033
+ * @param {int} [limit] the max number of canceled orders to return
4034
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4035
+ * @param {int} [params.until] the latest time in ms to fetch orders for
4036
+ * @param {boolean} [params.standard] whether to fetch standard contract orders
4037
+ * @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
4038
+ */
4039
+ await this.loadMarkets();
4040
+ const orders = await this.fetchCanceledAndClosedOrders(symbol, since, limit, params);
4041
+ return this.filterBy(orders, 'status', 'canceled');
4042
+ }
4043
+ async fetchCanceledAndClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4044
+ /**
4045
+ * @method
4046
+ * @name bingx#fetchCanceledAndClosedOrders
4047
+ * @description fetches information on multiple closed orders made by the user
4048
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20history
4049
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history
4050
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#User's%20History%20Orders
3951
4051
  * @see https://bingx-api.github.io/docs/#/standard/contract-interface.html#Historical%20order
3952
4052
  * @param {string} [symbol] unified market symbol of the market orders were made in
3953
4053
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -3965,75 +4065,133 @@ class bingx extends bingx$1 {
3965
4065
  const request = {
3966
4066
  'symbol': market['id'],
3967
4067
  };
3968
- let response = undefined;
4068
+ let type = undefined;
4069
+ let subType = undefined;
3969
4070
  let standard = undefined;
4071
+ let response = undefined;
4072
+ [type, params] = this.handleMarketTypeAndParams('fetchClosedOrders', market, params);
4073
+ [subType, params] = this.handleSubTypeAndParams('fetchClosedOrders', market, params);
3970
4074
  [standard, params] = this.handleOptionAndParams(params, 'fetchClosedOrders', 'standard', false);
3971
- const [marketType, query] = this.handleMarketTypeAndParams('fetchClosedOrders', market, params);
3972
4075
  if (standard) {
3973
- response = await this.contractV1PrivateGetAllOrders(this.extend(request, query));
4076
+ response = await this.contractV1PrivateGetAllOrders(this.extend(request, params));
3974
4077
  }
3975
- else if (marketType === 'spot') {
3976
- response = await this.spotV1PrivateGetTradeHistoryOrders(this.extend(request, query));
4078
+ else if (type === 'spot') {
4079
+ response = await this.spotV1PrivateGetTradeHistoryOrders(this.extend(request, params));
4080
+ //
4081
+ // {
4082
+ // "code": 0,
4083
+ // "msg": "",
4084
+ // "data": {
4085
+ // "orders": [
4086
+ // {
4087
+ // "symbol": "XRP-USDT",
4088
+ // "orderId": 1514073325788200960,
4089
+ // "price": "0.5",
4090
+ // "origQty": "20",
4091
+ // "executedQty": "0",
4092
+ // "cummulativeQuoteQty": "0",
4093
+ // "status": "PENDING",
4094
+ // "type": "LIMIT",
4095
+ // "side": "BUY",
4096
+ // "time": 1649818185647,
4097
+ // "updateTime": 1649818185647,
4098
+ // "origQuoteOrderQty": "0"
4099
+ // }
4100
+ // ]
4101
+ // }
4102
+ // }
4103
+ //
3977
4104
  }
3978
4105
  else {
3979
- response = await this.swapV2PrivateGetTradeAllOrders(this.extend(request, query));
4106
+ if (subType === 'inverse') {
4107
+ response = await this.cswapV1PrivateGetTradeOrderHistory(this.extend(request, params));
4108
+ //
4109
+ // {
4110
+ // "code": 0,
4111
+ // "msg": "",
4112
+ // "data": {
4113
+ // "orders": [
4114
+ // {
4115
+ // "symbol": "SOL-USD",
4116
+ // "orderId": "1816002957423951872",
4117
+ // "side": "BUY",
4118
+ // "positionSide": "LONG",
4119
+ // "type": "LIMIT",
4120
+ // "quantity": 1,
4121
+ // "origQty": "10.00000000",
4122
+ // "price": "150.000",
4123
+ // "executedQty": "0.00000000",
4124
+ // "avgPrice": "0.000",
4125
+ // "cumQuote": "",
4126
+ // "stopPrice": "0.000",
4127
+ // "profit": "0.0000",
4128
+ // "commission": "0.000000",
4129
+ // "status": "Filled",
4130
+ // "time": 1721803819000,
4131
+ // "updateTime": 1721803856000,
4132
+ // "clientOrderId": "",
4133
+ // "leverage": "",
4134
+ // "takeProfit": {
4135
+ // "type": "",
4136
+ // "quantity": 0,
4137
+ // "stopPrice": 0,
4138
+ // "price": 0,
4139
+ // "workingType": "",
4140
+ // "stopGuaranteed": ""
4141
+ // },
4142
+ // "stopLoss": {
4143
+ // "type": "",
4144
+ // "quantity": 0,
4145
+ // "stopPrice": 0,
4146
+ // "price": 0,
4147
+ // "workingType": "",
4148
+ // "stopGuaranteed": ""
4149
+ // },
4150
+ // "advanceAttr": 0,
4151
+ // "positionID": 0,
4152
+ // "takeProfitEntrustPrice": 0,
4153
+ // "stopLossEntrustPrice": 0,
4154
+ // "orderType": "",
4155
+ // "workingType": "MARK_PRICE"
4156
+ // },
4157
+ // ]
4158
+ // }
4159
+ // }
4160
+ //
4161
+ }
4162
+ else {
4163
+ response = await this.swapV2PrivateGetTradeAllOrders(this.extend(request, params));
4164
+ //
4165
+ // {
4166
+ // "code": 0,
4167
+ // "msg": "",
4168
+ // "data": {
4169
+ // "orders": [
4170
+ // {
4171
+ // "symbol": "LINK-USDT",
4172
+ // "orderId": 1585839271162413056,
4173
+ // "side": "BUY",
4174
+ // "positionSide": "LONG",
4175
+ // "type": "TRIGGER_MARKET",
4176
+ // "origQty": "5.0",
4177
+ // "price": "9",
4178
+ // "executedQty": "0.0",
4179
+ // "avgPrice": "0",
4180
+ // "cumQuote": "0",
4181
+ // "stopPrice": "5",
4182
+ // "profit": "0.0000",
4183
+ // "commission": "0.000000",
4184
+ // "status": "CANCELLED",
4185
+ // "time": 1667631605000,
4186
+ // "updateTime": 1667631605000
4187
+ // },
4188
+ // ]
4189
+ // }
4190
+ // }
4191
+ //
4192
+ }
3980
4193
  }
3981
- //
3982
- // spot
3983
- //
3984
- // {
3985
- // "code": 0,
3986
- // "msg": "",
3987
- // "data": {
3988
- // "orders": [
3989
- // {
3990
- // "symbol": "XRP-USDT",
3991
- // "orderId": 1514073325788200960,
3992
- // "price": "0.5",
3993
- // "origQty": "20",
3994
- // "executedQty": "0",
3995
- // "cummulativeQuoteQty": "0",
3996
- // "status": "PENDING",
3997
- // "type": "LIMIT",
3998
- // "side": "BUY",
3999
- // "time": 1649818185647,
4000
- // "updateTime": 1649818185647,
4001
- // "origQuoteOrderQty": "0"
4002
- // }
4003
- // ]
4004
- // }
4005
- // }
4006
- //
4007
- // swap
4008
- //
4009
- // {
4010
- // "code": 0,
4011
- // "msg": "",
4012
- // "data": {
4013
- // "orders": [
4014
- // {
4015
- // "symbol": "LINK-USDT",
4016
- // "orderId": 1585839271162413056,
4017
- // "side": "BUY",
4018
- // "positionSide": "LONG",
4019
- // "type": "TRIGGER_MARKET",
4020
- // "origQty": "5.0",
4021
- // "price": "9",
4022
- // "executedQty": "0.0",
4023
- // "avgPrice": "0",
4024
- // "cumQuote": "0",
4025
- // "stopPrice": "5",
4026
- // "profit": "0.0000",
4027
- // "commission": "0.000000",
4028
- // "status": "CANCELLED",
4029
- // "time": 1667631605000,
4030
- // "updateTime": 1667631605000
4031
- // },
4032
- // ]
4033
- // }
4034
- // }
4035
- //
4036
- const data = this.safeValue(response, 'data', []);
4194
+ const data = this.safeDict(response, 'data', {});
4037
4195
  const orders = this.safeList(data, 'orders', []);
4038
4196
  return this.parseOrders(orders, market, since, limit);
4039
4197
  }
@@ -4465,7 +4623,8 @@ class bingx extends bingx$1 {
4465
4623
  * @method
4466
4624
  * @name bingx#setMarginMode
4467
4625
  * @description set margin mode to 'cross' or 'isolated'
4468
- * @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Switch%20Margin%20Mode
4626
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Change%20Margin%20Type
4627
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Set%20Margin%20Type
4469
4628
  * @param {string} marginMode 'cross' or 'isolated'
4470
4629
  * @param {string} symbol unified market symbol
4471
4630
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -4490,7 +4649,14 @@ class bingx extends bingx$1 {
4490
4649
  'symbol': market['id'],
4491
4650
  'marginType': marginMode,
4492
4651
  };
4493
- return await this.swapV2PrivatePostTradeMarginType(this.extend(request, params));
4652
+ let subType = undefined;
4653
+ [subType, params] = this.handleSubTypeAndParams('setMarginMode', market, params);
4654
+ if (subType === 'inverse') {
4655
+ return await this.cswapV1PrivatePostTradeMarginType(this.extend(request, params));
4656
+ }
4657
+ else {
4658
+ return await this.swapV2PrivatePostTradeMarginType(this.extend(request, params));
4659
+ }
4494
4660
  }
4495
4661
  async addMargin(symbol, amount, params = {}) {
4496
4662
  const request = {
@@ -5449,7 +5615,8 @@ class bingx extends bingx$1 {
5449
5615
  * @method
5450
5616
  * @name bingx#fetchMarginMode
5451
5617
  * @description fetches the margin mode of the trading pair
5452
- * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Margin%20Mode
5618
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Margin%20Type
5619
+ * @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Margin%20Type
5453
5620
  * @param {string} symbol unified symbol of the market to fetch the margin mode for
5454
5621
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5455
5622
  * @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
@@ -5459,25 +5626,45 @@ class bingx extends bingx$1 {
5459
5626
  const request = {
5460
5627
  'symbol': market['id'],
5461
5628
  };
5462
- const response = await this.swapV2PrivateGetTradeMarginType(this.extend(request, params));
5463
- //
5464
- // {
5465
- // "code": 0,
5466
- // "msg": "",
5467
- // "data": {
5468
- // "marginType": "CROSSED"
5469
- // }
5470
- // }
5471
- //
5629
+ let subType = undefined;
5630
+ let response = undefined;
5631
+ [subType, params] = this.handleSubTypeAndParams('fetchMarginMode', market, params);
5632
+ if (subType === 'inverse') {
5633
+ response = await this.cswapV1PrivateGetTradeMarginType(this.extend(request, params));
5634
+ //
5635
+ // {
5636
+ // "code": 0,
5637
+ // "msg": "",
5638
+ // "timestamp": 1721966069132,
5639
+ // "data": {
5640
+ // "symbol": "SOL-USD",
5641
+ // "marginType": "CROSSED"
5642
+ // }
5643
+ // }
5644
+ //
5645
+ }
5646
+ else {
5647
+ response = await this.swapV2PrivateGetTradeMarginType(this.extend(request, params));
5648
+ //
5649
+ // {
5650
+ // "code": 0,
5651
+ // "msg": "",
5652
+ // "data": {
5653
+ // "marginType": "CROSSED"
5654
+ // }
5655
+ // }
5656
+ //
5657
+ }
5472
5658
  const data = this.safeDict(response, 'data', {});
5473
5659
  return this.parseMarginMode(data, market);
5474
5660
  }
5475
5661
  parseMarginMode(marginMode, market = undefined) {
5662
+ const marketId = this.safeString(marginMode, 'symbol');
5476
5663
  let marginType = this.safeStringLower(marginMode, 'marginType');
5477
5664
  marginType = (marginType === 'crossed') ? 'cross' : marginType;
5478
5665
  return {
5479
5666
  'info': marginMode,
5480
- 'symbol': market['symbol'],
5667
+ 'symbol': this.safeSymbol(marketId, market, '-', 'swap'),
5481
5668
  'marginMode': marginType,
5482
5669
  };
5483
5670
  }
@@ -5205,8 +5205,10 @@ class bitget extends bitget$1 {
5205
5205
  response = JSON.parse(response);
5206
5206
  }
5207
5207
  const data = this.safeDict(response, 'data');
5208
- if ((data !== undefined) && !Array.isArray(data)) {
5209
- return this.parseOrder(data, market);
5208
+ if ((data !== undefined)) {
5209
+ if (!Array.isArray(data)) {
5210
+ return this.parseOrder(data, market);
5211
+ }
5210
5212
  }
5211
5213
  const dataList = this.safeList(response, 'data', []);
5212
5214
  const first = this.safeDict(dataList, 0, {});