ccxt 4.2.42 → 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.
@@ -10,7 +10,7 @@ class binanceus extends binance {
10
10
  // eslint-disable-next-line new-cap
11
11
  const restInstance = new binanceus$1();
12
12
  const restDescribe = restInstance.describe();
13
- const extended = this.deepExtend(super.describe(), restDescribe);
13
+ const extended = this.deepExtend(restDescribe, super.describe());
14
14
  return this.deepExtend(extended, {
15
15
  'id': 'binanceus',
16
16
  'name': 'Binance US',
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.2.41";
7
+ declare const version = "4.2.43";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.2.42';
41
+ const version = '4.2.44';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -640,6 +640,9 @@ export default class Exchange {
640
640
  setLeverage(leverage: Int, symbol?: string, params?: {}): Promise<{}>;
641
641
  fetchLeverage(symbol: string, params?: {}): Promise<{}>;
642
642
  setPositionMode(hedged: boolean, symbol?: Str, params?: {}): Promise<{}>;
643
+ addMargin(symbol: string, amount: number, params?: {}): Promise<{}>;
644
+ reduceMargin(symbol: string, amount: number, params?: {}): Promise<{}>;
645
+ setMargin(symbol: string, amount: number, params?: {}): Promise<{}>;
643
646
  setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<{}>;
644
647
  fetchDepositAddressesByNetwork(code: string, params?: {}): Promise<{}>;
645
648
  fetchOpenInterestHistory(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OpenInterest[]>;
@@ -1938,6 +1938,15 @@ export default class Exchange {
1938
1938
  async setPositionMode(hedged, symbol = undefined, params = {}) {
1939
1939
  throw new NotSupported(this.id + ' setPositionMode() is not supported yet');
1940
1940
  }
1941
+ async addMargin(symbol, amount, params = {}) {
1942
+ throw new NotSupported(this.id + ' addMargin() is not supported yet');
1943
+ }
1944
+ async reduceMargin(symbol, amount, params = {}) {
1945
+ throw new NotSupported(this.id + ' reduceMargin() is not supported yet');
1946
+ }
1947
+ async setMargin(symbol, amount, params = {}) {
1948
+ throw new NotSupported(this.id + ' setMargin() is not supported yet');
1949
+ }
1941
1950
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
1942
1951
  throw new NotSupported(this.id + ' setMarginMode() is not supported yet');
1943
1952
  }
@@ -3127,6 +3136,9 @@ export default class Exchange {
3127
3136
  * @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
3128
3137
  * @returns {string|undefined} exchange-specific network id
3129
3138
  */
3139
+ if (networkCode === undefined) {
3140
+ return undefined;
3141
+ }
3130
3142
  const networkIdsByCodes = this.safeValue(this.options, 'networks', {});
3131
3143
  let networkId = this.safeString(networkIdsByCodes, networkCode);
3132
3144
  // for example, if 'ETH' is passed for networkCode, but 'ETH' key not defined in `options->networks` object
@@ -3170,6 +3182,9 @@ export default class Exchange {
3170
3182
  * @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
3171
3183
  * @returns {string|undefined} unified network code
3172
3184
  */
3185
+ if (networkId === undefined) {
3186
+ return undefined;
3187
+ }
3173
3188
  const networkCodesByIds = this.safeDict(this.options, 'networksById', {});
3174
3189
  let networkCode = this.safeString(networkCodesByIds, networkId, networkId);
3175
3190
  // replace mainnet network-codes (i.e. ERC20->ETH)
package/js/src/binance.js CHANGED
@@ -2655,9 +2655,11 @@ export default class binance extends Exchange {
2655
2655
  const networkList = this.safeList(entry, 'networkList', []);
2656
2656
  const fees = {};
2657
2657
  let fee = undefined;
2658
+ const networks = {};
2658
2659
  for (let j = 0; j < networkList.length; j++) {
2659
2660
  const networkItem = networkList[j];
2660
2661
  const network = this.safeString(networkItem, 'network');
2662
+ const networkCode = this.networkIdToCode(network);
2661
2663
  // const name = this.safeString (networkItem, 'name');
2662
2664
  const withdrawFee = this.safeNumber(networkItem, 'withdrawFee');
2663
2665
  const depositEnable = this.safeBool(networkItem, 'depositEnable');
@@ -2675,6 +2677,26 @@ export default class binance extends Exchange {
2675
2677
  if (!Precise.stringEq(precisionTick, '0')) {
2676
2678
  minPrecision = (minPrecision === undefined) ? precisionTick : Precise.stringMin(minPrecision, precisionTick);
2677
2679
  }
2680
+ networks[networkCode] = {
2681
+ 'info': networkItem,
2682
+ 'id': network,
2683
+ 'network': networkCode,
2684
+ 'active': depositEnable && withdrawEnable,
2685
+ 'deposit': depositEnable,
2686
+ 'withdraw': withdrawEnable,
2687
+ 'fee': this.parseNumber(fee),
2688
+ 'precision': minPrecision,
2689
+ 'limits': {
2690
+ 'withdraw': {
2691
+ 'min': this.safeNumber(networkItem, 'withdrawMin'),
2692
+ 'max': this.safeNumber(networkItem, 'withdrawMax'),
2693
+ },
2694
+ 'deposit': {
2695
+ 'min': undefined,
2696
+ 'max': undefined,
2697
+ },
2698
+ },
2699
+ };
2678
2700
  }
2679
2701
  const trading = this.safeBool(entry, 'trading');
2680
2702
  const active = (isWithdrawEnabled && isDepositEnabled && trading);
@@ -2691,7 +2713,7 @@ export default class binance extends Exchange {
2691
2713
  'active': active,
2692
2714
  'deposit': isDepositEnabled,
2693
2715
  'withdraw': isWithdrawEnabled,
2694
- 'networks': networkList,
2716
+ 'networks': networks,
2695
2717
  'fee': fee,
2696
2718
  'fees': fees,
2697
2719
  'limits': this.limits,
@@ -5104,7 +5126,7 @@ export default class binance extends Exchange {
5104
5126
  // "msg": "Quantity greater than max quantity."
5105
5127
  // }
5106
5128
  //
5107
- // createOrder, fetchOpenOrders, fetchOrder, cancelOrder: portfolio margin linear swap and future
5129
+ // createOrder, fetchOpenOrders, fetchOrder, cancelOrder, fetchOrders: portfolio margin linear swap and future
5108
5130
  //
5109
5131
  // {
5110
5132
  // "symbol": "BTCUSDT",
@@ -5127,7 +5149,7 @@ export default class binance extends Exchange {
5127
5149
  // "status": "NEW"
5128
5150
  // }
5129
5151
  //
5130
- // createOrder, fetchOpenOrders, fetchOrder, cancelOrder: portfolio margin inverse swap and future
5152
+ // createOrder, fetchOpenOrders, fetchOrder, cancelOrder, fetchOrders: portfolio margin inverse swap and future
5131
5153
  //
5132
5154
  // {
5133
5155
  // "symbol": "ETHUSD_PERP",
@@ -5212,7 +5234,7 @@ export default class binance extends Exchange {
5212
5234
  // "type": "LIMIT"
5213
5235
  // }
5214
5236
  //
5215
- // fetchOpenOrders, fetchOrder: portfolio margin spot margin
5237
+ // fetchOpenOrders, fetchOrder, fetchOrders: portfolio margin spot margin
5216
5238
  //
5217
5239
  // {
5218
5240
  // "symbol": "BTCUSDT",
@@ -5262,6 +5284,32 @@ export default class binance extends Exchange {
5262
5284
  // "selfTradePreventionMode": "NONE"
5263
5285
  // }
5264
5286
  //
5287
+ // fetchOrders: portfolio margin linear and inverse swap conditional
5288
+ //
5289
+ // {
5290
+ // "newClientStrategyId": "x-xcKtGhcuaf166172ed504cd1bc0396",
5291
+ // "strategyId": 3733211,
5292
+ // "strategyStatus": "CANCELLED",
5293
+ // "strategyType": "STOP",
5294
+ // "origQty": "0.010",
5295
+ // "price": "35000",
5296
+ // "orderId": 0,
5297
+ // "reduceOnly": false,
5298
+ // "side": "BUY",
5299
+ // "positionSide": "BOTH",
5300
+ // "stopPrice": "50000",
5301
+ // "symbol": "BTCUSDT",
5302
+ // "type": "LIMIT",
5303
+ // "bookTime": 1707270098774,
5304
+ // "updateTime": 1707270119261,
5305
+ // "timeInForce": "GTC",
5306
+ // "triggerTime": 0,
5307
+ // "workingType": "CONTRACT_PRICE",
5308
+ // "priceProtect": false,
5309
+ // "goodTillDate": 0,
5310
+ // "selfTradePreventionMode": "NONE"
5311
+ // }
5312
+ //
5265
5313
  const code = this.safeString(order, 'code');
5266
5314
  if (code !== undefined) {
5267
5315
  // cancelOrders/createOrders might have a partial success
@@ -5320,7 +5368,7 @@ export default class binance extends Exchange {
5320
5368
  }
5321
5369
  return this.safeOrder({
5322
5370
  'info': order,
5323
- 'id': this.safeString2(order, 'orderId', 'strategyId'),
5371
+ 'id': this.safeString2(order, 'strategyId', 'orderId'),
5324
5372
  'clientOrderId': this.safeString2(order, 'clientOrderId', 'newClientStrategyId'),
5325
5373
  'timestamp': timestamp,
5326
5374
  'datetime': this.iso8601(timestamp),
@@ -5955,13 +6003,20 @@ export default class binance extends Exchange {
5955
6003
  * @see https://binance-docs.github.io/apidocs/delivery/en/#all-orders-user_data
5956
6004
  * @see https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
5957
6005
  * @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
6006
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-orders-user_data
6007
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-orders-user_data
6008
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-conditional-orders-user_data
6009
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-conditional-orders-user_data
6010
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-margin-account-orders-user_data
5958
6011
  * @param {string} symbol unified market symbol of the market orders were made in
5959
6012
  * @param {int} [since] the earliest time in ms to fetch orders for
5960
6013
  * @param {int} [limit] the maximum number of order structures to retrieve
5961
6014
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5962
6015
  * @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
5963
6016
  * @param {int} [params.until] the latest time in ms to fetch orders for
5964
- * @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)
6017
+ * @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)
6018
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
6019
+ * @param {boolean} [params.stop] set to true if you would like to fetch portfolio margin account stop or conditional orders
5965
6020
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
5966
6021
  */
5967
6022
  if (symbol === undefined) {
@@ -5974,17 +6029,18 @@ export default class binance extends Exchange {
5974
6029
  return await this.fetchPaginatedCallDynamic('fetchOrders', symbol, since, limit, params);
5975
6030
  }
5976
6031
  const market = this.market(symbol);
5977
- const defaultType = this.safeString2(this.options, 'fetchOrders', 'defaultType', 'spot');
6032
+ const defaultType = this.safeString2(this.options, 'fetchOrders', 'defaultType', market['type']);
5978
6033
  const type = this.safeString(params, 'type', defaultType);
5979
- const [marginMode, query] = this.handleMarginModeAndParams('fetchOrders', params);
5980
- const request = {
6034
+ let marginMode = undefined;
6035
+ [marginMode, params] = this.handleMarginModeAndParams('fetchOrders', params);
6036
+ let isPortfolioMargin = undefined;
6037
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchOrders', 'papi', 'portfolioMargin', false);
6038
+ const isConditional = this.safeBool2(params, 'stop', 'conditional');
6039
+ params = this.omit(params, ['stop', 'conditional', 'type']);
6040
+ let request = {
5981
6041
  'symbol': market['id'],
5982
6042
  };
5983
- const until = this.safeInteger(params, 'until');
5984
- if (until !== undefined) {
5985
- params = this.omit(params, 'until');
5986
- request['endTime'] = until;
5987
- }
6043
+ [request, params] = this.handleUntilOption('endTime', request, params);
5988
6044
  if (since !== undefined) {
5989
6045
  request['startTime'] = since;
5990
6046
  }
@@ -5993,22 +6049,47 @@ export default class binance extends Exchange {
5993
6049
  }
5994
6050
  let response = undefined;
5995
6051
  if (market['option']) {
5996
- response = await this.eapiPrivateGetHistoryOrders(this.extend(request, query));
6052
+ response = await this.eapiPrivateGetHistoryOrders(this.extend(request, params));
5997
6053
  }
5998
6054
  else if (market['linear']) {
5999
- response = await this.fapiPrivateGetAllOrders(this.extend(request, query));
6055
+ if (isPortfolioMargin) {
6056
+ if (isConditional) {
6057
+ response = await this.papiGetUmConditionalAllOrders(this.extend(request, params));
6058
+ }
6059
+ else {
6060
+ response = await this.papiGetUmAllOrders(this.extend(request, params));
6061
+ }
6062
+ }
6063
+ else {
6064
+ response = await this.fapiPrivateGetAllOrders(this.extend(request, params));
6065
+ }
6000
6066
  }
6001
6067
  else if (market['inverse']) {
6002
- response = await this.dapiPrivateGetAllOrders(this.extend(request, query));
6003
- }
6004
- else if (type === 'margin' || marginMode !== undefined) {
6005
- if (marginMode === 'isolated') {
6006
- request['isIsolated'] = true;
6068
+ if (isPortfolioMargin) {
6069
+ if (isConditional) {
6070
+ response = await this.papiGetCmConditionalAllOrders(this.extend(request, params));
6071
+ }
6072
+ else {
6073
+ response = await this.papiGetCmAllOrders(this.extend(request, params));
6074
+ }
6075
+ }
6076
+ else {
6077
+ response = await this.dapiPrivateGetAllOrders(this.extend(request, params));
6007
6078
  }
6008
- response = await this.sapiGetMarginAllOrders(this.extend(request, query));
6009
6079
  }
6010
6080
  else {
6011
- response = await this.privateGetAllOrders(this.extend(request, query));
6081
+ if (isPortfolioMargin) {
6082
+ response = await this.papiGetMarginAllOrders(this.extend(request, params));
6083
+ }
6084
+ else if (type === 'margin' || marginMode !== undefined) {
6085
+ if (marginMode === 'isolated') {
6086
+ request['isIsolated'] = true;
6087
+ }
6088
+ response = await this.sapiGetMarginAllOrders(this.extend(request, params));
6089
+ }
6090
+ else {
6091
+ response = await this.privateGetAllOrders(this.extend(request, params));
6092
+ }
6012
6093
  }
6013
6094
  //
6014
6095
  // spot
@@ -6084,6 +6165,112 @@ export default class binance extends Exchange {
6084
6165
  // }
6085
6166
  // ]
6086
6167
  //
6168
+ // inverse portfolio margin
6169
+ //
6170
+ // [
6171
+ // {
6172
+ // "orderId": 71328442983,
6173
+ // "symbol": "ETHUSD_PERP",
6174
+ // "pair": "ETHUSD",
6175
+ // "status": "CANCELED",
6176
+ // "clientOrderId": "x-xcKtGhcu4b3e3d8515dd4dc5ba9ccc",
6177
+ // "price": "2000",
6178
+ // "avgPrice": "0.00",
6179
+ // "origQty": "1",
6180
+ // "executedQty": "0",
6181
+ // "cumBase": "0",
6182
+ // "timeInForce": "GTC",
6183
+ // "type": "LIMIT",
6184
+ // "reduceOnly": false,
6185
+ // "side": "BUY",
6186
+ // "origType": "LIMIT",
6187
+ // "time": 1707197843046,
6188
+ // "updateTime": 1707197941373,
6189
+ // "positionSide": "BOTH"
6190
+ // },
6191
+ // ]
6192
+ //
6193
+ // linear portfolio margin
6194
+ //
6195
+ // [
6196
+ // {
6197
+ // "orderId": 259235347005,
6198
+ // "symbol": "BTCUSDT",
6199
+ // "status": "CANCELED",
6200
+ // "clientOrderId": "x-xcKtGhcu402881c9103f42bdb4183b",
6201
+ // "price": "35000",
6202
+ // "avgPrice": "0.00000",
6203
+ // "origQty": "0.010",
6204
+ // "executedQty": "0",
6205
+ // "cumQuote": "0",
6206
+ // "timeInForce": "GTC",
6207
+ // "type": "LIMIT",
6208
+ // "reduceOnly": false,
6209
+ // "side": "BUY",
6210
+ // "origType": "LIMIT",
6211
+ // "time": 1707194702167,
6212
+ // "updateTime": 1707197804748,
6213
+ // "positionSide": "BOTH",
6214
+ // "selfTradePreventionMode": "NONE",
6215
+ // "goodTillDate": 0
6216
+ // },
6217
+ // ]
6218
+ //
6219
+ // conditional portfolio margin
6220
+ //
6221
+ // [
6222
+ // {
6223
+ // "newClientStrategyId": "x-xcKtGhcuaf166172ed504cd1bc0396",
6224
+ // "strategyId": 3733211,
6225
+ // "strategyStatus": "CANCELLED",
6226
+ // "strategyType": "STOP",
6227
+ // "origQty": "0.010",
6228
+ // "price": "35000",
6229
+ // "orderId": 0,
6230
+ // "reduceOnly": false,
6231
+ // "side": "BUY",
6232
+ // "positionSide": "BOTH",
6233
+ // "stopPrice": "50000",
6234
+ // "symbol": "BTCUSDT",
6235
+ // "type": "LIMIT",
6236
+ // "bookTime": 1707270098774,
6237
+ // "updateTime": 1707270119261,
6238
+ // "timeInForce": "GTC",
6239
+ // "triggerTime": 0,
6240
+ // "workingType": "CONTRACT_PRICE",
6241
+ // "priceProtect": false,
6242
+ // "goodTillDate": 0,
6243
+ // "selfTradePreventionMode": "NONE"
6244
+ // },
6245
+ // ]
6246
+ //
6247
+ // spot margin portfolio margin
6248
+ //
6249
+ // [
6250
+ // {
6251
+ // "symbol": "BTCUSDT",
6252
+ // "orderId": 24684460474,
6253
+ // "clientOrderId": "x-R4BD3S82e9ef29d8346440f0b28b86",
6254
+ // "price": "35000.00000000",
6255
+ // "origQty": "0.00100000",
6256
+ // "executedQty": "0.00000000",
6257
+ // "cummulativeQuoteQty": "0.00000000",
6258
+ // "status": "CANCELED",
6259
+ // "timeInForce": "GTC",
6260
+ // "type": "LIMIT",
6261
+ // "side": "BUY",
6262
+ // "stopPrice": "0.00000000",
6263
+ // "icebergQty": "0.00000000",
6264
+ // "time": 1707113538870,
6265
+ // "updateTime": 1707113797688,
6266
+ // "isWorking": true,
6267
+ // "accountId": 200180970,
6268
+ // "selfTradePreventionMode": "EXPIRE_MAKER",
6269
+ // "preventedMatchId": null,
6270
+ // "preventedQuantity": null
6271
+ // },
6272
+ // ]
6273
+ //
6087
6274
  return this.parseOrders(response, market, since, limit);
6088
6275
  }
6089
6276
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -6208,15 +6395,26 @@ export default class binance extends Exchange {
6208
6395
  * @see https://binance-docs.github.io/apidocs/delivery/en/#all-orders-user_data
6209
6396
  * @see https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
6210
6397
  * @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
6398
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-orders-user_data
6399
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-orders-user_data
6400
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-conditional-orders-user_data
6401
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-conditional-orders-user_data
6402
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-margin-account-orders-user_data
6211
6403
  * @param {string} symbol unified market symbol of the market orders were made in
6212
6404
  * @param {int} [since] the earliest time in ms to fetch orders for
6213
6405
  * @param {int} [limit] the maximum number of order structures to retrieve
6214
6406
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6215
- * @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)
6407
+ * @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)
6408
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
6409
+ * @param {boolean} [params.stop] set to true if you would like to fetch portfolio margin account stop or conditional orders
6216
6410
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
6217
6411
  */
6218
- const orders = await this.fetchOrders(symbol, since, limit, params);
6219
- return this.filterBy(orders, 'status', 'closed');
6412
+ if (symbol === undefined) {
6413
+ throw new ArgumentsRequired(this.id + ' fetchClosedOrders() requires a symbol argument');
6414
+ }
6415
+ const orders = await this.fetchOrders(symbol, since, undefined, params);
6416
+ const filteredOrders = this.filterBy(orders, 'status', 'closed');
6417
+ return this.filterBySinceLimit(filteredOrders, since, limit);
6220
6418
  }
6221
6419
  async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
6222
6420
  /**
@@ -6226,22 +6424,23 @@ export default class binance extends Exchange {
6226
6424
  * @see https://binance-docs.github.io/apidocs/spot/en/#all-orders-user_data
6227
6425
  * @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-all-orders-user_data
6228
6426
  * @see https://binance-docs.github.io/apidocs/voptions/en/#query-option-order-history-trade
6427
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-orders-user_data
6428
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-orders-user_data
6429
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-um-conditional-orders-user_data
6430
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-cm-conditional-orders-user_data
6431
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-all-margin-account-orders-user_data
6229
6432
  * @param {string} symbol unified market symbol of the market the orders were made in
6230
6433
  * @param {int} [since] the earliest time in ms to fetch orders for
6231
6434
  * @param {int} [limit] the maximum number of order structures to retrieve
6232
6435
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6233
- * @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)
6436
+ * @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)
6437
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch orders in a portfolio margin account
6438
+ * @param {boolean} [params.stop] set to true if you would like to fetch portfolio margin account stop or conditional orders
6234
6439
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
6235
6440
  */
6236
6441
  if (symbol === undefined) {
6237
6442
  throw new ArgumentsRequired(this.id + ' fetchCanceledOrders() requires a symbol argument');
6238
6443
  }
6239
- await this.loadMarkets();
6240
- const market = this.market(symbol);
6241
- if (market['swap'] || market['future']) {
6242
- throw new NotSupported(this.id + ' fetchCanceledOrders() supports spot, margin and option markets only');
6243
- }
6244
- params = this.omit(params, 'type');
6245
6444
  const orders = await this.fetchOrders(symbol, since, undefined, params);
6246
6445
  const filteredOrders = this.filterBy(orders, 'status', 'canceled');
6247
6446
  return this.filterBySinceLimit(filteredOrders, since, limit);
@@ -7990,35 +8189,48 @@ export default class binance extends Exchange {
7990
8189
  * @see https://binance-docs.github.io/apidocs/spot/en/#trade-fee-user_data
7991
8190
  * @see https://binance-docs.github.io/apidocs/futures/en/#user-commission-rate-user_data
7992
8191
  * @see https://binance-docs.github.io/apidocs/delivery/en/#user-commission-rate-user_data
8192
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-user-commission-rate-for-um-user_data
8193
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-user-commission-rate-for-cm-user_data
7993
8194
  * @param {string} symbol unified market symbol
7994
8195
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8196
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trading fees in a portfolio margin account
7995
8197
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
7996
8198
  */
7997
8199
  await this.loadMarkets();
7998
8200
  const market = this.market(symbol);
7999
- const defaultType = this.safeString2(this.options, 'fetchTradingFee', 'defaultType', 'linear');
8000
- const type = this.safeString(params, 'type', defaultType);
8001
- params = this.omit(params, 'type');
8201
+ const type = market['type'];
8002
8202
  let subType = undefined;
8003
8203
  [subType, params] = this.handleSubTypeAndParams('fetchTradingFee', market, params);
8004
- const isSpotOrMargin = (type === 'spot') || (type === 'margin');
8204
+ let isPortfolioMargin = undefined;
8205
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchTradingFee', 'papi', 'portfolioMargin', false);
8005
8206
  const isLinear = this.isLinear(type, subType);
8006
8207
  const isInverse = this.isInverse(type, subType);
8007
8208
  const request = {
8008
8209
  'symbol': market['id'],
8009
8210
  };
8010
8211
  let response = undefined;
8011
- if (isSpotOrMargin) {
8012
- response = await this.sapiGetAssetTradeFee(this.extend(request, params));
8013
- }
8014
- else if (isLinear) {
8015
- response = await this.fapiPrivateGetCommissionRate(this.extend(request, params));
8212
+ if (isLinear) {
8213
+ if (isPortfolioMargin) {
8214
+ response = await this.papiGetUmCommissionRate(this.extend(request, params));
8215
+ }
8216
+ else {
8217
+ response = await this.fapiPrivateGetCommissionRate(this.extend(request, params));
8218
+ }
8016
8219
  }
8017
8220
  else if (isInverse) {
8018
- response = await this.dapiPrivateGetCommissionRate(this.extend(request, params));
8221
+ if (isPortfolioMargin) {
8222
+ response = await this.papiGetCmCommissionRate(this.extend(request, params));
8223
+ }
8224
+ else {
8225
+ response = await this.dapiPrivateGetCommissionRate(this.extend(request, params));
8226
+ }
8227
+ }
8228
+ else {
8229
+ response = await this.sapiGetAssetTradeFee(this.extend(request, params));
8019
8230
  }
8020
8231
  //
8021
8232
  // spot
8233
+ //
8022
8234
  // [
8023
8235
  // {
8024
8236
  // "symbol": "BTCUSDT",
@@ -8028,6 +8240,7 @@ export default class binance extends Exchange {
8028
8240
  // ]
8029
8241
  //
8030
8242
  // swap
8243
+ //
8031
8244
  // {
8032
8245
  // "symbol": "BTCUSD_PERP",
8033
8246
  // "makerCommissionRate": "0.00015", // 0.015%
@@ -8038,7 +8251,7 @@ export default class binance extends Exchange {
8038
8251
  if (Array.isArray(data)) {
8039
8252
  data = this.safeDict(data, 0, {});
8040
8253
  }
8041
- return this.parseTradingFee(data);
8254
+ return this.parseTradingFee(data, market);
8042
8255
  }
8043
8256
  async fetchTradingFees(params = {}) {
8044
8257
  /**
package/js/src/bingx.d.ts CHANGED
@@ -108,7 +108,7 @@ export default class bingx extends Exchange {
108
108
  parseTransaction(transaction: any, currency?: Currency): Transaction;
109
109
  parseTransactionStatus(status: any): string;
110
110
  setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
111
- setMargin(symbol: string, amount: any, params?: {}): Promise<any>;
111
+ setMargin(symbol: string, amount: number, params?: {}): Promise<any>;
112
112
  fetchLeverage(symbol: string, params?: {}): Promise<any>;
113
113
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
114
114
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
package/js/src/bingx.js CHANGED
@@ -388,7 +388,9 @@ export default class bingx extends Exchange {
388
388
  },
389
389
  'broad': {},
390
390
  },
391
- 'commonCurrencies': {},
391
+ 'commonCurrencies': {
392
+ 'SNOW': 'Snowman', // Snowman vs SnowSwap conflict
393
+ },
392
394
  'options': {
393
395
  'defaultType': 'spot',
394
396
  'accountsByType': {
@@ -154,7 +154,7 @@ export default class bitfinex2 extends Exchange {
154
154
  parseOpenInterest(interest: any, market?: Market): OpenInterest;
155
155
  fetchLiquidations(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Liquidation[]>;
156
156
  parseLiquidation(liquidation: any, market?: Market): Liquidation;
157
- setMargin(symbol: string, amount: any, params?: {}): Promise<{
157
+ setMargin(symbol: string, amount: number, params?: {}): Promise<{
158
158
  info: any;
159
159
  type: any;
160
160
  amount: any;
@@ -81,7 +81,7 @@ export default class bitrue extends Exchange {
81
81
  symbol: any;
82
82
  status: any;
83
83
  };
84
- setMargin(symbol: string, amount: any, params?: {}): Promise<{
84
+ setMargin(symbol: string, amount: number, params?: {}): Promise<{
85
85
  info: any;
86
86
  type: any;
87
87
  amount: any;
package/js/src/blofin.js CHANGED
@@ -958,7 +958,8 @@ export default class blofin extends Exchange {
958
958
  const request = {};
959
959
  let response = undefined;
960
960
  if (accountType !== undefined) {
961
- const parsedAccountType = this.safeString(this.options, 'accountsByType', accountType);
961
+ const options = this.safeDict(this.options, 'accountsByType', {});
962
+ const parsedAccountType = this.safeString(options, accountType, accountType);
962
963
  request['accountType'] = parsedAccountType;
963
964
  response = await this.privateGetAssetBalances(this.extend(request, params));
964
965
  }
@@ -3391,13 +3391,7 @@ export default class coinbase extends Exchange {
3391
3391
  payload = body;
3392
3392
  }
3393
3393
  }
3394
- let auth = undefined;
3395
- if (version === 'v3') {
3396
- auth = nonce + method + savedPath + payload;
3397
- }
3398
- else {
3399
- auth = nonce + method + fullPath + payload;
3400
- }
3394
+ const auth = nonce + method + savedPath + payload;
3401
3395
  const signature = this.hmac(this.encode(auth), this.encode(this.secret), sha256);
3402
3396
  headers = {
3403
3397
  'CB-ACCESS-KEY': this.apiKey,