ccxt 4.2.43 → 4.2.44

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
@@ -177,7 +177,7 @@ var woo$1 = require('./src/pro/woo.js');
177
177
 
178
178
  //-----------------------------------------------------------------------------
179
179
  // this is updated by vss.js when building
180
- const version = '4.2.43';
180
+ const version = '4.2.44';
181
181
  Exchange["default"].ccxtVersion = version;
182
182
  const exchanges = {
183
183
  'ace': ace,
@@ -3140,6 +3140,9 @@ class Exchange {
3140
3140
  * @param {string} currencyCode unified currency code, but this argument is not required by default, unless there is an exchange (like huobi) that needs an override of the method to be able to pass currencyCode argument additionally
3141
3141
  * @returns {string|undefined} exchange-specific network id
3142
3142
  */
3143
+ if (networkCode === undefined) {
3144
+ return undefined;
3145
+ }
3143
3146
  const networkIdsByCodes = this.safeValue(this.options, 'networks', {});
3144
3147
  let networkId = this.safeString(networkIdsByCodes, networkCode);
3145
3148
  // for example, if 'ETH' is passed for networkCode, but 'ETH' key not defined in `options->networks` object
@@ -3183,6 +3186,9 @@ class Exchange {
3183
3186
  * @param {string|undefined} currencyCode unified currency code, but this argument is not required by default, unless there is an exchange (like huobi) that needs an override of the method to be able to pass currencyCode argument additionally
3184
3187
  * @returns {string|undefined} unified network code
3185
3188
  */
3189
+ if (networkId === undefined) {
3190
+ return undefined;
3191
+ }
3186
3192
  const networkCodesByIds = this.safeDict(this.options, 'networksById', {});
3187
3193
  let networkCode = this.safeString(networkCodesByIds, networkId, networkId);
3188
3194
  // replace mainnet network-codes (i.e. ERC20->ETH)
@@ -2652,9 +2652,11 @@ class binance extends binance$1 {
2652
2652
  const networkList = this.safeList(entry, 'networkList', []);
2653
2653
  const fees = {};
2654
2654
  let fee = undefined;
2655
+ const networks = {};
2655
2656
  for (let j = 0; j < networkList.length; j++) {
2656
2657
  const networkItem = networkList[j];
2657
2658
  const network = this.safeString(networkItem, 'network');
2659
+ const networkCode = this.networkIdToCode(network);
2658
2660
  // const name = this.safeString (networkItem, 'name');
2659
2661
  const withdrawFee = this.safeNumber(networkItem, 'withdrawFee');
2660
2662
  const depositEnable = this.safeBool(networkItem, 'depositEnable');
@@ -2672,6 +2674,26 @@ class binance extends binance$1 {
2672
2674
  if (!Precise["default"].stringEq(precisionTick, '0')) {
2673
2675
  minPrecision = (minPrecision === undefined) ? precisionTick : Precise["default"].stringMin(minPrecision, precisionTick);
2674
2676
  }
2677
+ networks[networkCode] = {
2678
+ 'info': networkItem,
2679
+ 'id': network,
2680
+ 'network': networkCode,
2681
+ 'active': depositEnable && withdrawEnable,
2682
+ 'deposit': depositEnable,
2683
+ 'withdraw': withdrawEnable,
2684
+ 'fee': this.parseNumber(fee),
2685
+ 'precision': minPrecision,
2686
+ 'limits': {
2687
+ 'withdraw': {
2688
+ 'min': this.safeNumber(networkItem, 'withdrawMin'),
2689
+ 'max': this.safeNumber(networkItem, 'withdrawMax'),
2690
+ },
2691
+ 'deposit': {
2692
+ 'min': undefined,
2693
+ 'max': undefined,
2694
+ },
2695
+ },
2696
+ };
2675
2697
  }
2676
2698
  const trading = this.safeBool(entry, 'trading');
2677
2699
  const active = (isWithdrawEnabled && isDepositEnabled && trading);
@@ -2688,7 +2710,7 @@ class binance extends binance$1 {
2688
2710
  'active': active,
2689
2711
  'deposit': isDepositEnabled,
2690
2712
  'withdraw': isWithdrawEnabled,
2691
- 'networks': networkList,
2713
+ 'networks': networks,
2692
2714
  'fee': fee,
2693
2715
  'fees': fees,
2694
2716
  'limits': this.limits,
@@ -5101,7 +5123,7 @@ class binance extends binance$1 {
5101
5123
  // "msg": "Quantity greater than max quantity."
5102
5124
  // }
5103
5125
  //
5104
- // createOrder, fetchOpenOrders, fetchOrder, cancelOrder: portfolio margin linear swap and future
5126
+ // createOrder, fetchOpenOrders, fetchOrder, cancelOrder, fetchOrders: portfolio margin linear swap and future
5105
5127
  //
5106
5128
  // {
5107
5129
  // "symbol": "BTCUSDT",
@@ -5124,7 +5146,7 @@ class binance extends binance$1 {
5124
5146
  // "status": "NEW"
5125
5147
  // }
5126
5148
  //
5127
- // createOrder, fetchOpenOrders, fetchOrder, cancelOrder: portfolio margin inverse swap and future
5149
+ // createOrder, fetchOpenOrders, fetchOrder, cancelOrder, fetchOrders: portfolio margin inverse swap and future
5128
5150
  //
5129
5151
  // {
5130
5152
  // "symbol": "ETHUSD_PERP",
@@ -5209,7 +5231,7 @@ class binance extends binance$1 {
5209
5231
  // "type": "LIMIT"
5210
5232
  // }
5211
5233
  //
5212
- // fetchOpenOrders, fetchOrder: portfolio margin spot margin
5234
+ // fetchOpenOrders, fetchOrder, fetchOrders: portfolio margin spot margin
5213
5235
  //
5214
5236
  // {
5215
5237
  // "symbol": "BTCUSDT",
@@ -5259,6 +5281,32 @@ class binance extends binance$1 {
5259
5281
  // "selfTradePreventionMode": "NONE"
5260
5282
  // }
5261
5283
  //
5284
+ // fetchOrders: portfolio margin linear and inverse swap conditional
5285
+ //
5286
+ // {
5287
+ // "newClientStrategyId": "x-xcKtGhcuaf166172ed504cd1bc0396",
5288
+ // "strategyId": 3733211,
5289
+ // "strategyStatus": "CANCELLED",
5290
+ // "strategyType": "STOP",
5291
+ // "origQty": "0.010",
5292
+ // "price": "35000",
5293
+ // "orderId": 0,
5294
+ // "reduceOnly": false,
5295
+ // "side": "BUY",
5296
+ // "positionSide": "BOTH",
5297
+ // "stopPrice": "50000",
5298
+ // "symbol": "BTCUSDT",
5299
+ // "type": "LIMIT",
5300
+ // "bookTime": 1707270098774,
5301
+ // "updateTime": 1707270119261,
5302
+ // "timeInForce": "GTC",
5303
+ // "triggerTime": 0,
5304
+ // "workingType": "CONTRACT_PRICE",
5305
+ // "priceProtect": false,
5306
+ // "goodTillDate": 0,
5307
+ // "selfTradePreventionMode": "NONE"
5308
+ // }
5309
+ //
5262
5310
  const code = this.safeString(order, 'code');
5263
5311
  if (code !== undefined) {
5264
5312
  // cancelOrders/createOrders might have a partial success
@@ -5317,7 +5365,7 @@ class binance extends binance$1 {
5317
5365
  }
5318
5366
  return this.safeOrder({
5319
5367
  'info': order,
5320
- 'id': this.safeString2(order, 'orderId', 'strategyId'),
5368
+ 'id': this.safeString2(order, 'strategyId', 'orderId'),
5321
5369
  'clientOrderId': this.safeString2(order, 'clientOrderId', 'newClientStrategyId'),
5322
5370
  'timestamp': timestamp,
5323
5371
  'datetime': this.iso8601(timestamp),
@@ -5952,13 +6000,20 @@ class binance extends binance$1 {
5952
6000
  * @see https://binance-docs.github.io/apidocs/delivery/en/#all-orders-user_data
5953
6001
  * @see https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
5954
6002
  * @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
6003
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-orders-user_data
6004
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-orders-user_data
6005
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-conditional-orders-user_data
6006
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-conditional-orders-user_data
6007
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-margin-account-orders-user_data
5955
6008
  * @param {string} symbol unified market symbol of the market orders were made in
5956
6009
  * @param {int} [since] the earliest time in ms to fetch orders for
5957
6010
  * @param {int} [limit] the maximum number of order structures to retrieve
5958
6011
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5959
6012
  * @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
5960
6013
  * @param {int} [params.until] the latest time in ms to fetch orders for
5961
- * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
6014
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
6015
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
6016
+ * @param {boolean} [params.stop] set to true if you would like to fetch portfolio margin account stop or conditional orders
5962
6017
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
5963
6018
  */
5964
6019
  if (symbol === undefined) {
@@ -5971,17 +6026,18 @@ class binance extends binance$1 {
5971
6026
  return await this.fetchPaginatedCallDynamic('fetchOrders', symbol, since, limit, params);
5972
6027
  }
5973
6028
  const market = this.market(symbol);
5974
- const defaultType = this.safeString2(this.options, 'fetchOrders', 'defaultType', 'spot');
6029
+ const defaultType = this.safeString2(this.options, 'fetchOrders', 'defaultType', market['type']);
5975
6030
  const type = this.safeString(params, 'type', defaultType);
5976
- const [marginMode, query] = this.handleMarginModeAndParams('fetchOrders', params);
5977
- const request = {
6031
+ let marginMode = undefined;
6032
+ [marginMode, params] = this.handleMarginModeAndParams('fetchOrders', params);
6033
+ let isPortfolioMargin = undefined;
6034
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchOrders', 'papi', 'portfolioMargin', false);
6035
+ const isConditional = this.safeBool2(params, 'stop', 'conditional');
6036
+ params = this.omit(params, ['stop', 'conditional', 'type']);
6037
+ let request = {
5978
6038
  'symbol': market['id'],
5979
6039
  };
5980
- const until = this.safeInteger(params, 'until');
5981
- if (until !== undefined) {
5982
- params = this.omit(params, 'until');
5983
- request['endTime'] = until;
5984
- }
6040
+ [request, params] = this.handleUntilOption('endTime', request, params);
5985
6041
  if (since !== undefined) {
5986
6042
  request['startTime'] = since;
5987
6043
  }
@@ -5990,22 +6046,47 @@ class binance extends binance$1 {
5990
6046
  }
5991
6047
  let response = undefined;
5992
6048
  if (market['option']) {
5993
- response = await this.eapiPrivateGetHistoryOrders(this.extend(request, query));
6049
+ response = await this.eapiPrivateGetHistoryOrders(this.extend(request, params));
5994
6050
  }
5995
6051
  else if (market['linear']) {
5996
- response = await this.fapiPrivateGetAllOrders(this.extend(request, query));
6052
+ if (isPortfolioMargin) {
6053
+ if (isConditional) {
6054
+ response = await this.papiGetUmConditionalAllOrders(this.extend(request, params));
6055
+ }
6056
+ else {
6057
+ response = await this.papiGetUmAllOrders(this.extend(request, params));
6058
+ }
6059
+ }
6060
+ else {
6061
+ response = await this.fapiPrivateGetAllOrders(this.extend(request, params));
6062
+ }
5997
6063
  }
5998
6064
  else if (market['inverse']) {
5999
- response = await this.dapiPrivateGetAllOrders(this.extend(request, query));
6000
- }
6001
- else if (type === 'margin' || marginMode !== undefined) {
6002
- if (marginMode === 'isolated') {
6003
- request['isIsolated'] = true;
6065
+ if (isPortfolioMargin) {
6066
+ if (isConditional) {
6067
+ response = await this.papiGetCmConditionalAllOrders(this.extend(request, params));
6068
+ }
6069
+ else {
6070
+ response = await this.papiGetCmAllOrders(this.extend(request, params));
6071
+ }
6072
+ }
6073
+ else {
6074
+ response = await this.dapiPrivateGetAllOrders(this.extend(request, params));
6004
6075
  }
6005
- response = await this.sapiGetMarginAllOrders(this.extend(request, query));
6006
6076
  }
6007
6077
  else {
6008
- response = await this.privateGetAllOrders(this.extend(request, query));
6078
+ if (isPortfolioMargin) {
6079
+ response = await this.papiGetMarginAllOrders(this.extend(request, params));
6080
+ }
6081
+ else if (type === 'margin' || marginMode !== undefined) {
6082
+ if (marginMode === 'isolated') {
6083
+ request['isIsolated'] = true;
6084
+ }
6085
+ response = await this.sapiGetMarginAllOrders(this.extend(request, params));
6086
+ }
6087
+ else {
6088
+ response = await this.privateGetAllOrders(this.extend(request, params));
6089
+ }
6009
6090
  }
6010
6091
  //
6011
6092
  // spot
@@ -6081,6 +6162,112 @@ class binance extends binance$1 {
6081
6162
  // }
6082
6163
  // ]
6083
6164
  //
6165
+ // inverse portfolio margin
6166
+ //
6167
+ // [
6168
+ // {
6169
+ // "orderId": 71328442983,
6170
+ // "symbol": "ETHUSD_PERP",
6171
+ // "pair": "ETHUSD",
6172
+ // "status": "CANCELED",
6173
+ // "clientOrderId": "x-xcKtGhcu4b3e3d8515dd4dc5ba9ccc",
6174
+ // "price": "2000",
6175
+ // "avgPrice": "0.00",
6176
+ // "origQty": "1",
6177
+ // "executedQty": "0",
6178
+ // "cumBase": "0",
6179
+ // "timeInForce": "GTC",
6180
+ // "type": "LIMIT",
6181
+ // "reduceOnly": false,
6182
+ // "side": "BUY",
6183
+ // "origType": "LIMIT",
6184
+ // "time": 1707197843046,
6185
+ // "updateTime": 1707197941373,
6186
+ // "positionSide": "BOTH"
6187
+ // },
6188
+ // ]
6189
+ //
6190
+ // linear portfolio margin
6191
+ //
6192
+ // [
6193
+ // {
6194
+ // "orderId": 259235347005,
6195
+ // "symbol": "BTCUSDT",
6196
+ // "status": "CANCELED",
6197
+ // "clientOrderId": "x-xcKtGhcu402881c9103f42bdb4183b",
6198
+ // "price": "35000",
6199
+ // "avgPrice": "0.00000",
6200
+ // "origQty": "0.010",
6201
+ // "executedQty": "0",
6202
+ // "cumQuote": "0",
6203
+ // "timeInForce": "GTC",
6204
+ // "type": "LIMIT",
6205
+ // "reduceOnly": false,
6206
+ // "side": "BUY",
6207
+ // "origType": "LIMIT",
6208
+ // "time": 1707194702167,
6209
+ // "updateTime": 1707197804748,
6210
+ // "positionSide": "BOTH",
6211
+ // "selfTradePreventionMode": "NONE",
6212
+ // "goodTillDate": 0
6213
+ // },
6214
+ // ]
6215
+ //
6216
+ // conditional portfolio margin
6217
+ //
6218
+ // [
6219
+ // {
6220
+ // "newClientStrategyId": "x-xcKtGhcuaf166172ed504cd1bc0396",
6221
+ // "strategyId": 3733211,
6222
+ // "strategyStatus": "CANCELLED",
6223
+ // "strategyType": "STOP",
6224
+ // "origQty": "0.010",
6225
+ // "price": "35000",
6226
+ // "orderId": 0,
6227
+ // "reduceOnly": false,
6228
+ // "side": "BUY",
6229
+ // "positionSide": "BOTH",
6230
+ // "stopPrice": "50000",
6231
+ // "symbol": "BTCUSDT",
6232
+ // "type": "LIMIT",
6233
+ // "bookTime": 1707270098774,
6234
+ // "updateTime": 1707270119261,
6235
+ // "timeInForce": "GTC",
6236
+ // "triggerTime": 0,
6237
+ // "workingType": "CONTRACT_PRICE",
6238
+ // "priceProtect": false,
6239
+ // "goodTillDate": 0,
6240
+ // "selfTradePreventionMode": "NONE"
6241
+ // },
6242
+ // ]
6243
+ //
6244
+ // spot margin portfolio margin
6245
+ //
6246
+ // [
6247
+ // {
6248
+ // "symbol": "BTCUSDT",
6249
+ // "orderId": 24684460474,
6250
+ // "clientOrderId": "x-R4BD3S82e9ef29d8346440f0b28b86",
6251
+ // "price": "35000.00000000",
6252
+ // "origQty": "0.00100000",
6253
+ // "executedQty": "0.00000000",
6254
+ // "cummulativeQuoteQty": "0.00000000",
6255
+ // "status": "CANCELED",
6256
+ // "timeInForce": "GTC",
6257
+ // "type": "LIMIT",
6258
+ // "side": "BUY",
6259
+ // "stopPrice": "0.00000000",
6260
+ // "icebergQty": "0.00000000",
6261
+ // "time": 1707113538870,
6262
+ // "updateTime": 1707113797688,
6263
+ // "isWorking": true,
6264
+ // "accountId": 200180970,
6265
+ // "selfTradePreventionMode": "EXPIRE_MAKER",
6266
+ // "preventedMatchId": null,
6267
+ // "preventedQuantity": null
6268
+ // },
6269
+ // ]
6270
+ //
6084
6271
  return this.parseOrders(response, market, since, limit);
6085
6272
  }
6086
6273
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -6205,13 +6392,23 @@ class binance extends binance$1 {
6205
6392
  * @see https://binance-docs.github.io/apidocs/delivery/en/#all-orders-user_data
6206
6393
  * @see https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
6207
6394
  * @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
6395
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-orders-user_data
6396
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-orders-user_data
6397
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-conditional-orders-user_data
6398
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-conditional-orders-user_data
6399
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-margin-account-orders-user_data
6208
6400
  * @param {string} symbol unified market symbol of the market orders were made in
6209
6401
  * @param {int} [since] the earliest time in ms to fetch orders for
6210
6402
  * @param {int} [limit] the maximum number of order structures to retrieve
6211
6403
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6212
- * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
6404
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
6405
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
6406
+ * @param {boolean} [params.stop] set to true if you would like to fetch portfolio margin account stop or conditional orders
6213
6407
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
6214
6408
  */
6409
+ if (symbol === undefined) {
6410
+ throw new errors.ArgumentsRequired(this.id + ' fetchClosedOrders() requires a symbol argument');
6411
+ }
6215
6412
  const orders = await this.fetchOrders(symbol, since, undefined, params);
6216
6413
  const filteredOrders = this.filterBy(orders, 'status', 'closed');
6217
6414
  return this.filterBySinceLimit(filteredOrders, since, limit);
@@ -6224,22 +6421,23 @@ class binance extends binance$1 {
6224
6421
  * @see https://binance-docs.github.io/apidocs/spot/en/#all-orders-user_data
6225
6422
  * @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
6226
6423
  * @see https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
6424
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-orders-user_data
6425
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-orders-user_data
6426
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-conditional-orders-user_data
6427
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-conditional-orders-user_data
6428
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-margin-account-orders-user_data
6227
6429
  * @param {string} symbol unified market symbol of the market the orders were made in
6228
6430
  * @param {int} [since] the earliest time in ms to fetch orders for
6229
6431
  * @param {int} [limit] the maximum number of order structures to retrieve
6230
6432
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6231
- * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
6433
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
6434
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
6435
+ * @param {boolean} [params.stop] set to true if you would like to fetch portfolio margin account stop or conditional orders
6232
6436
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
6233
6437
  */
6234
6438
  if (symbol === undefined) {
6235
6439
  throw new errors.ArgumentsRequired(this.id + ' fetchCanceledOrders() requires a symbol argument');
6236
6440
  }
6237
- await this.loadMarkets();
6238
- const market = this.market(symbol);
6239
- if (market['swap'] || market['future']) {
6240
- throw new errors.NotSupported(this.id + ' fetchCanceledOrders() supports spot, margin and option markets only');
6241
- }
6242
- params = this.omit(params, 'type');
6243
6441
  const orders = await this.fetchOrders(symbol, since, undefined, params);
6244
6442
  const filteredOrders = this.filterBy(orders, 'status', 'canceled');
6245
6443
  return this.filterBySinceLimit(filteredOrders, since, limit);
@@ -7988,35 +8186,48 @@ class binance extends binance$1 {
7988
8186
  * @see https://binance-docs.github.io/apidocs/spot/en/#trade-fee-user_data
7989
8187
  * @see https://binance-docs.github.io/apidocs/futures/en/#user-commission-rate-user_data
7990
8188
  * @see https://binance-docs.github.io/apidocs/delivery/en/#user-commission-rate-user_data
8189
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-user-commission-rate-for-um-user_data
8190
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-user-commission-rate-for-cm-user_data
7991
8191
  * @param {string} symbol unified market symbol
7992
8192
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8193
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trading fees in a portfolio margin account
7993
8194
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
7994
8195
  */
7995
8196
  await this.loadMarkets();
7996
8197
  const market = this.market(symbol);
7997
- const defaultType = this.safeString2(this.options, 'fetchTradingFee', 'defaultType', 'linear');
7998
- const type = this.safeString(params, 'type', defaultType);
7999
- params = this.omit(params, 'type');
8198
+ const type = market['type'];
8000
8199
  let subType = undefined;
8001
8200
  [subType, params] = this.handleSubTypeAndParams('fetchTradingFee', market, params);
8002
- const isSpotOrMargin = (type === 'spot') || (type === 'margin');
8201
+ let isPortfolioMargin = undefined;
8202
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchTradingFee', 'papi', 'portfolioMargin', false);
8003
8203
  const isLinear = this.isLinear(type, subType);
8004
8204
  const isInverse = this.isInverse(type, subType);
8005
8205
  const request = {
8006
8206
  'symbol': market['id'],
8007
8207
  };
8008
8208
  let response = undefined;
8009
- if (isSpotOrMargin) {
8010
- response = await this.sapiGetAssetTradeFee(this.extend(request, params));
8011
- }
8012
- else if (isLinear) {
8013
- response = await this.fapiPrivateGetCommissionRate(this.extend(request, params));
8209
+ if (isLinear) {
8210
+ if (isPortfolioMargin) {
8211
+ response = await this.papiGetUmCommissionRate(this.extend(request, params));
8212
+ }
8213
+ else {
8214
+ response = await this.fapiPrivateGetCommissionRate(this.extend(request, params));
8215
+ }
8014
8216
  }
8015
8217
  else if (isInverse) {
8016
- response = await this.dapiPrivateGetCommissionRate(this.extend(request, params));
8218
+ if (isPortfolioMargin) {
8219
+ response = await this.papiGetCmCommissionRate(this.extend(request, params));
8220
+ }
8221
+ else {
8222
+ response = await this.dapiPrivateGetCommissionRate(this.extend(request, params));
8223
+ }
8224
+ }
8225
+ else {
8226
+ response = await this.sapiGetAssetTradeFee(this.extend(request, params));
8017
8227
  }
8018
8228
  //
8019
8229
  // spot
8230
+ //
8020
8231
  // [
8021
8232
  // {
8022
8233
  // "symbol": "BTCUSDT",
@@ -8026,6 +8237,7 @@ class binance extends binance$1 {
8026
8237
  // ]
8027
8238
  //
8028
8239
  // swap
8240
+ //
8029
8241
  // {
8030
8242
  // "symbol": "BTCUSD_PERP",
8031
8243
  // "makerCommissionRate": "0.00015", // 0.015%
@@ -8036,7 +8248,7 @@ class binance extends binance$1 {
8036
8248
  if (Array.isArray(data)) {
8037
8249
  data = this.safeDict(data, 0, {});
8038
8250
  }
8039
- return this.parseTradingFee(data);
8251
+ return this.parseTradingFee(data, market);
8040
8252
  }
8041
8253
  async fetchTradingFees(params = {}) {
8042
8254
  /**
@@ -385,7 +385,9 @@ class bingx extends bingx$1 {
385
385
  },
386
386
  'broad': {},
387
387
  },
388
- 'commonCurrencies': {},
388
+ 'commonCurrencies': {
389
+ 'SNOW': 'Snowman', // Snowman vs SnowSwap conflict
390
+ },
389
391
  'options': {
390
392
  'defaultType': 'spot',
391
393
  'accountsByType': {
@@ -955,7 +955,8 @@ class blofin extends blofin$1 {
955
955
  const request = {};
956
956
  let response = undefined;
957
957
  if (accountType !== undefined) {
958
- const parsedAccountType = this.safeString(this.options, 'accountsByType', accountType);
958
+ const options = this.safeDict(this.options, 'accountsByType', {});
959
+ const parsedAccountType = this.safeString(options, accountType, accountType);
959
960
  request['accountType'] = parsedAccountType;
960
961
  response = await this.privateGetAssetBalances(this.extend(request, params));
961
962
  }
@@ -3388,13 +3388,7 @@ class coinbase extends coinbase$1 {
3388
3388
  payload = body;
3389
3389
  }
3390
3390
  }
3391
- let auth = undefined;
3392
- if (version === 'v3') {
3393
- auth = nonce + method + savedPath + payload;
3394
- }
3395
- else {
3396
- auth = nonce + method + fullPath + payload;
3397
- }
3391
+ const auth = nonce + method + savedPath + payload;
3398
3392
  const signature = this.hmac(this.encode(auth), this.encode(this.secret), sha256.sha256);
3399
3393
  headers = {
3400
3394
  'CB-ACCESS-KEY': this.apiKey,
@@ -861,6 +861,7 @@ class krakenfutures extends krakenfutures$1 {
861
861
  }
862
862
  createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
863
863
  const market = this.market(symbol);
864
+ symbol = market['symbol'];
864
865
  type = this.safeString(params, 'orderType', type);
865
866
  const timeInForce = this.safeString(params, 'timeInForce');
866
867
  let postOnly = false;
@@ -880,7 +881,7 @@ class krakenfutures extends krakenfutures$1 {
880
881
  const request = {
881
882
  'symbol': market['id'],
882
883
  'side': side,
883
- 'size': amount,
884
+ 'size': this.amountToPrecision(symbol, amount),
884
885
  };
885
886
  const clientOrderId = this.safeString2(params, 'clientOrderId', 'cliOrdId');
886
887
  if (clientOrderId !== undefined) {
@@ -918,7 +919,7 @@ class krakenfutures extends krakenfutures$1 {
918
919
  }
919
920
  request['orderType'] = type;
920
921
  if (price !== undefined) {
921
- request['limitPrice'] = price;
922
+ request['limitPrice'] = this.priceToPrecision(symbol, price);
922
923
  }
923
924
  params = this.omit(params, ['clientOrderId', 'timeInForce', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']);
924
925
  return this.extend(request, params);
@@ -3857,11 +3857,11 @@ class kucoin extends kucoin$1 {
3857
3857
  }
3858
3858
  }
3859
3859
  let fee = undefined;
3860
- const feeCost = this.safeNumber(item, 'fee');
3860
+ const feeCost = this.safeString(item, 'fee');
3861
3861
  let feeCurrency = undefined;
3862
- if (feeCost !== 0) {
3862
+ if (feeCost !== '0') {
3863
3863
  feeCurrency = code;
3864
- fee = { 'cost': feeCost, 'currency': feeCurrency };
3864
+ fee = { 'cost': this.parseNumber(feeCost), 'currency': feeCurrency };
3865
3865
  }
3866
3866
  return {
3867
3867
  'id': id,
@@ -3975,8 +3975,12 @@ class kucoin extends kucoin$1 {
3975
3975
  // }
3976
3976
  // }
3977
3977
  //
3978
- const data = this.safeValue(response, 'data');
3979
- const items = this.safeValue(data, 'items', data);
3978
+ const dataList = this.safeList(response, 'data');
3979
+ if (dataList !== undefined) {
3980
+ return this.parseLedger(dataList, currency, since, limit);
3981
+ }
3982
+ const data = this.safeDict(response, 'data');
3983
+ const items = this.safeList(data, 'items', []);
3980
3984
  return this.parseLedger(items, currency, since, limit);
3981
3985
  }
3982
3986
  calculateRateLimiterCost(api, method, path, params, config = {}) {