ccxt 4.2.63 → 4.2.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +3 -3
  2. package/build.sh +2 -2
  3. package/dist/ccxt.browser.js +565 -178
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/base/Exchange.js +12 -0
  7. package/dist/cjs/src/binance.js +33 -12
  8. package/dist/cjs/src/bingx.js +58 -49
  9. package/dist/cjs/src/bitget.js +69 -1
  10. package/dist/cjs/src/bitmex.js +3 -1
  11. package/dist/cjs/src/blofin.js +46 -11
  12. package/dist/cjs/src/btcmarkets.js +12 -0
  13. package/dist/cjs/src/bybit.js +100 -7
  14. package/dist/cjs/src/coinbase.js +12 -2
  15. package/dist/cjs/src/delta.js +95 -1
  16. package/dist/cjs/src/gemini.js +9 -4
  17. package/dist/cjs/src/hitbtc.js +1 -1
  18. package/dist/cjs/src/krakenfutures.js +1 -0
  19. package/dist/cjs/src/kucoin.js +87 -62
  20. package/dist/cjs/src/pro/bitget.js +5 -5
  21. package/dist/cjs/src/pro/coinex.js +4 -4
  22. package/dist/cjs/src/pro/currencycom.js +1 -1
  23. package/dist/cjs/src/pro/lbank.js +1 -1
  24. package/dist/cjs/src/yobit.js +15 -15
  25. package/js/ccxt.d.ts +1 -1
  26. package/js/ccxt.js +1 -1
  27. package/js/src/abstract/blofin.d.ts +1 -0
  28. package/js/src/abstract/krakenfutures.d.ts +1 -0
  29. package/js/src/abstract/kucoin.d.ts +10 -0
  30. package/js/src/abstract/kucoinfutures.d.ts +10 -0
  31. package/js/src/base/Exchange.js +12 -0
  32. package/js/src/binance.d.ts +1 -1
  33. package/js/src/binance.js +33 -12
  34. package/js/src/bingx.js +58 -49
  35. package/js/src/bitget.d.ts +3 -1
  36. package/js/src/bitget.js +69 -1
  37. package/js/src/bitmex.js +3 -1
  38. package/js/src/blofin.d.ts +3 -1
  39. package/js/src/blofin.js +46 -11
  40. package/js/src/btcmarkets.js +12 -0
  41. package/js/src/bybit.d.ts +1 -0
  42. package/js/src/bybit.js +100 -7
  43. package/js/src/coinbase.js +12 -2
  44. package/js/src/delta.d.ts +3 -1
  45. package/js/src/delta.js +95 -1
  46. package/js/src/gate.d.ts +1 -1
  47. package/js/src/gemini.js +9 -4
  48. package/js/src/hitbtc.js +1 -1
  49. package/js/src/krakenfutures.js +1 -0
  50. package/js/src/kucoin.js +87 -62
  51. package/js/src/okx.d.ts +1 -1
  52. package/js/src/pro/bitget.js +5 -5
  53. package/js/src/pro/coinex.js +4 -4
  54. package/js/src/pro/currencycom.d.ts +1 -1
  55. package/js/src/pro/currencycom.js +1 -1
  56. package/js/src/pro/lbank.js +1 -1
  57. package/js/src/woo.d.ts +1 -1
  58. package/js/src/yobit.js +15 -15
  59. package/package.json +2 -2
  60. package/skip-tests.json +47 -22
@@ -281,15 +281,15 @@ class yobit extends yobit$1 {
281
281
  });
282
282
  }
283
283
  parseBalance(response) {
284
- const balances = this.safeValue(response, 'return', {});
284
+ const balances = this.safeDict(response, 'return', {});
285
285
  const timestamp = this.safeInteger(balances, 'server_time');
286
286
  const result = {
287
287
  'info': response,
288
288
  'timestamp': timestamp,
289
289
  'datetime': this.iso8601(timestamp),
290
290
  };
291
- const free = this.safeValue(balances, 'funds', {});
292
- const total = this.safeValue(balances, 'funds_incl_orders', {});
291
+ const free = this.safeDict(balances, 'funds', {});
292
+ const total = this.safeDict(balances, 'funds_incl_orders', {});
293
293
  const currencyIds = Object.keys(this.extend(free, total));
294
294
  for (let i = 0; i < currencyIds.length; i++) {
295
295
  const currencyId = currencyIds[i];
@@ -367,7 +367,7 @@ class yobit extends yobit$1 {
367
367
  // },
368
368
  // }
369
369
  //
370
- const markets = this.safeValue(response, 'pairs', {});
370
+ const markets = this.safeDict(response, 'pairs', {});
371
371
  const keys = Object.keys(markets);
372
372
  const result = [];
373
373
  for (let i = 0; i < keys.length; i++) {
@@ -655,7 +655,7 @@ class yobit extends yobit$1 {
655
655
  'currency': feeCurrencyCode,
656
656
  };
657
657
  }
658
- const isYourOrder = this.safeValue(trade, 'is_your_order');
658
+ const isYourOrder = this.safeString(trade, 'is_your_order');
659
659
  if (isYourOrder !== undefined) {
660
660
  if (fee === undefined) {
661
661
  const feeInNumbers = this.calculateFee(symbol, type, side, amount, price, 'taker');
@@ -722,7 +722,7 @@ class yobit extends yobit$1 {
722
722
  return [];
723
723
  }
724
724
  }
725
- const result = this.safeValue(response, market['id'], []);
725
+ const result = this.safeList(response, market['id'], []);
726
726
  return this.parseTrades(result, market, since, limit);
727
727
  }
728
728
  async fetchTradingFees(params = {}) {
@@ -755,12 +755,12 @@ class yobit extends yobit$1 {
755
755
  // },
756
756
  // }
757
757
  //
758
- const pairs = this.safeValue(response, 'pairs', {});
758
+ const pairs = this.safeDict(response, 'pairs', {});
759
759
  const marketIds = Object.keys(pairs);
760
760
  const result = {};
761
761
  for (let i = 0; i < marketIds.length; i++) {
762
762
  const marketId = marketIds[i];
763
- const pair = this.safeValue(pairs, marketId, {});
763
+ const pair = this.safeDict(pairs, marketId, {});
764
764
  const symbol = this.safeSymbol(marketId, undefined, '_');
765
765
  const takerString = this.safeString(pair, 'fee_buyer');
766
766
  const makerString = this.safeString(pair, 'fee_seller');
@@ -824,7 +824,7 @@ class yobit extends yobit$1 {
824
824
  // }
825
825
  // }
826
826
  //
827
- const result = this.safeValue(response, 'return');
827
+ const result = this.safeDict(response, 'return');
828
828
  return this.parseOrder(result, market);
829
829
  }
830
830
  async cancelOrder(id, symbol = undefined, params = {}) {
@@ -862,7 +862,7 @@ class yobit extends yobit$1 {
862
862
  // }
863
863
  // }
864
864
  //
865
- const result = this.safeValue(response, 'return', {});
865
+ const result = this.safeDict(response, 'return', {});
866
866
  return this.parseOrder(result);
867
867
  }
868
868
  parseOrderStatus(status) {
@@ -993,7 +993,7 @@ class yobit extends yobit$1 {
993
993
  };
994
994
  const response = await this.privatePostOrderInfo(this.extend(request, params));
995
995
  id = id.toString();
996
- const orders = this.safeValue(response, 'return', {});
996
+ const orders = this.safeDict(response, 'return', {});
997
997
  //
998
998
  // {
999
999
  // "success":1,
@@ -1058,7 +1058,7 @@ class yobit extends yobit$1 {
1058
1058
  // }
1059
1059
  // }
1060
1060
  //
1061
- const result = this.safeValue(response, 'return', {});
1061
+ const result = this.safeDict(response, 'return', {});
1062
1062
  return this.parseOrders(result, market, since, limit);
1063
1063
  }
1064
1064
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -1112,7 +1112,7 @@ class yobit extends yobit$1 {
1112
1112
  // }
1113
1113
  // }
1114
1114
  //
1115
- const trades = this.safeValue(response, 'return', {});
1115
+ const trades = this.safeDict(response, 'return', {});
1116
1116
  const ids = Object.keys(trades);
1117
1117
  const result = [];
1118
1118
  for (let i = 0; i < ids.length; i++) {
@@ -1160,7 +1160,7 @@ class yobit extends yobit$1 {
1160
1160
  await this.loadMarkets();
1161
1161
  const currency = this.currency(code);
1162
1162
  let currencyId = currency['id'];
1163
- const networks = this.safeValue(this.options, 'networks', {});
1163
+ const networks = this.safeDict(this.options, 'networks', {});
1164
1164
  let network = this.safeStringUpper(params, 'network'); // this line allows the user to specify either ERC20 or ETH
1165
1165
  network = this.safeString(networks, network, network); // handle ERC20>ETH alias
1166
1166
  if (network !== undefined) {
@@ -1327,7 +1327,7 @@ class yobit extends yobit$1 {
1327
1327
  //
1328
1328
  // To cover points 1, 2, 3 and 4 combined this handler should work like this:
1329
1329
  //
1330
- let success = this.safeBool(response, 'success', false);
1330
+ let success = this.safeValue(response, 'success'); // don't replace with safeBool here
1331
1331
  if (typeof success === 'string') {
1332
1332
  if ((success === 'true') || (success === '1')) {
1333
1333
  success = true;
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, Leverage, Leverages } 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.62";
7
+ declare const version = "4.2.64";
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.63';
41
+ const version = '4.2.65';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -18,6 +18,7 @@ interface Exchange {
18
18
  privateGetAccountBalance(params?: {}): Promise<implicitReturnType>;
19
19
  privateGetAccountPositions(params?: {}): Promise<implicitReturnType>;
20
20
  privateGetAccountLeverageInfo(params?: {}): Promise<implicitReturnType>;
21
+ privateGetAccountMarginMode(params?: {}): Promise<implicitReturnType>;
21
22
  privateGetAccountBatchLeverageInfo(params?: {}): Promise<implicitReturnType>;
22
23
  privateGetTradeOrdersTpslPending(params?: {}): Promise<implicitReturnType>;
23
24
  privateGetTradeOrdersHistory(params?: {}): Promise<implicitReturnType>;
@@ -32,6 +32,7 @@ interface Exchange {
32
32
  historyGetExecutions(params?: {}): Promise<implicitReturnType>;
33
33
  historyGetTriggers(params?: {}): Promise<implicitReturnType>;
34
34
  historyGetAccountlogcsv(params?: {}): Promise<implicitReturnType>;
35
+ historyGetAccountLog(params?: {}): Promise<implicitReturnType>;
35
36
  historyGetMarketSymbolOrders(params?: {}): Promise<implicitReturnType>;
36
37
  historyGetMarketSymbolExecutions(params?: {}): Promise<implicitReturnType>;
37
38
  }
@@ -82,6 +82,7 @@ interface Exchange {
82
82
  privateGetProjectMarketInterestRate(params?: {}): Promise<implicitReturnType>;
83
83
  privateGetRedeemOrders(params?: {}): Promise<implicitReturnType>;
84
84
  privateGetPurchaseOrders(params?: {}): Promise<implicitReturnType>;
85
+ privateGetBrokerApiRebaseDownload(params?: {}): Promise<implicitReturnType>;
85
86
  privatePostSubUserCreated(params?: {}): Promise<implicitReturnType>;
86
87
  privatePostSubApiKey(params?: {}): Promise<implicitReturnType>;
87
88
  privatePostSubApiKeyUpdate(params?: {}): Promise<implicitReturnType>;
@@ -186,6 +187,15 @@ interface Exchange {
186
187
  futuresPrivateDeleteOrders(params?: {}): Promise<implicitReturnType>;
187
188
  futuresPrivateDeleteStopOrders(params?: {}): Promise<implicitReturnType>;
188
189
  webExchangeGetCurrencyCurrencyChainInfo(params?: {}): Promise<implicitReturnType>;
190
+ brokerGetBrokerNdInfo(params?: {}): Promise<implicitReturnType>;
191
+ brokerGetBrokerNdAccount(params?: {}): Promise<implicitReturnType>;
192
+ brokerGetBrokerNdAccountApikey(params?: {}): Promise<implicitReturnType>;
193
+ brokerGetBrokerNdRebaseDownload(params?: {}): Promise<implicitReturnType>;
194
+ brokerPostBrokerNdTransfer(params?: {}): Promise<implicitReturnType>;
195
+ brokerPostBrokerNdAccount(params?: {}): Promise<implicitReturnType>;
196
+ brokerPostBrokerNdAccountApikey(params?: {}): Promise<implicitReturnType>;
197
+ brokerPostBrokerNdAccountUpdateApikey(params?: {}): Promise<implicitReturnType>;
198
+ brokerDeleteBrokerNdAccountApikey(params?: {}): Promise<implicitReturnType>;
189
199
  }
190
200
  declare abstract class Exchange extends _Exchange {
191
201
  }
@@ -82,6 +82,7 @@ interface kucoin {
82
82
  privateGetProjectMarketInterestRate(params?: {}): Promise<implicitReturnType>;
83
83
  privateGetRedeemOrders(params?: {}): Promise<implicitReturnType>;
84
84
  privateGetPurchaseOrders(params?: {}): Promise<implicitReturnType>;
85
+ privateGetBrokerApiRebaseDownload(params?: {}): Promise<implicitReturnType>;
85
86
  privatePostSubUserCreated(params?: {}): Promise<implicitReturnType>;
86
87
  privatePostSubApiKey(params?: {}): Promise<implicitReturnType>;
87
88
  privatePostSubApiKeyUpdate(params?: {}): Promise<implicitReturnType>;
@@ -203,6 +204,15 @@ interface kucoin {
203
204
  futuresPrivateDeleteSubApiKey(params?: {}): Promise<implicitReturnType>;
204
205
  webExchangeGetCurrencyCurrencyChainInfo(params?: {}): Promise<implicitReturnType>;
205
206
  webExchangeGetContractSymbolFundingRates(params?: {}): Promise<implicitReturnType>;
207
+ brokerGetBrokerNdInfo(params?: {}): Promise<implicitReturnType>;
208
+ brokerGetBrokerNdAccount(params?: {}): Promise<implicitReturnType>;
209
+ brokerGetBrokerNdAccountApikey(params?: {}): Promise<implicitReturnType>;
210
+ brokerGetBrokerNdRebaseDownload(params?: {}): Promise<implicitReturnType>;
211
+ brokerPostBrokerNdTransfer(params?: {}): Promise<implicitReturnType>;
212
+ brokerPostBrokerNdAccount(params?: {}): Promise<implicitReturnType>;
213
+ brokerPostBrokerNdAccountApikey(params?: {}): Promise<implicitReturnType>;
214
+ brokerPostBrokerNdAccountUpdateApikey(params?: {}): Promise<implicitReturnType>;
215
+ brokerDeleteBrokerNdAccountApikey(params?: {}): Promise<implicitReturnType>;
206
216
  }
207
217
  declare abstract class kucoin extends _kucoin {
208
218
  }
@@ -2692,6 +2692,18 @@ export default class Exchange {
2692
2692
  return this.filterBySymbolSinceLimit(results, symbol, since, limit);
2693
2693
  }
2694
2694
  calculateFee(symbol, type, side, amount, price, takerOrMaker = 'taker', params = {}) {
2695
+ /**
2696
+ * @method
2697
+ * @description calculates the presumptive fee that would be charged for an order
2698
+ * @param {string} symbol unified market symbol
2699
+ * @param {string} type 'market' or 'limit'
2700
+ * @param {string} side 'buy' or 'sell'
2701
+ * @param {float} amount how much you want to trade, in units of the base currency on most exchanges, or number of contracts
2702
+ * @param {float} price the price for the order to be filled at, in units of the quote currency
2703
+ * @param {string} takerOrMaker 'taker' or 'maker'
2704
+ * @param {object} params
2705
+ * @returns {object} contains the rate, the percentage multiplied to the order amount to obtain the fee amount, and cost, the total value of the fee in units of the quote currency, for the order
2706
+ */
2695
2707
  if (type === 'market' && takerOrMaker === 'maker') {
2696
2708
  throw new ArgumentsRequired(this.id + ' calculateFee() - you have provided incompatible arguments - "market" type order can not be "maker". Change either the "type" or the "takerOrMaker" argument to calculate the fee.');
2697
2709
  }
@@ -8,7 +8,7 @@ export default class binance extends Exchange {
8
8
  describe(): any;
9
9
  isInverse(type: any, subType?: any): boolean;
10
10
  isLinear(type: any, subType?: any): boolean;
11
- setSandboxMode(enable: any): void;
11
+ setSandboxMode(enable: boolean): void;
12
12
  convertExpireDate(date: any): string;
13
13
  createExpiredOptionMarket(symbol: string): MarketInterface;
14
14
  market(symbol: any): any;
package/js/src/binance.js CHANGED
@@ -2528,6 +2528,7 @@ export default class binance extends Exchange {
2528
2528
  * @see https://binance-docs.github.io/apidocs/futures/en/#check-server-time // swap
2529
2529
  * @see https://binance-docs.github.io/apidocs/delivery/en/#check-server-time // future
2530
2530
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2531
+ * @param {string} [params.subType] "linear" or "inverse"
2531
2532
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
2532
2533
  */
2533
2534
  const defaultType = this.safeString2(this.options, 'fetchTime', 'defaultType', 'spot');
@@ -2788,14 +2789,12 @@ export default class binance extends Exchange {
2788
2789
  }
2789
2790
  }
2790
2791
  const promises = await Promise.all(promisesRaw);
2791
- const spotMarkets = this.safeValue(this.safeValue(promises, 0), 'symbols', []);
2792
- const futureMarkets = this.safeValue(this.safeValue(promises, 1), 'symbols', []);
2793
- const deliveryMarkets = this.safeValue(this.safeValue(promises, 2), 'symbols', []);
2794
- const optionMarkets = this.safeValue(this.safeValue(promises, 3), 'optionSymbols', []);
2795
- let markets = spotMarkets;
2796
- markets = this.arrayConcat(markets, futureMarkets);
2797
- markets = this.arrayConcat(markets, deliveryMarkets);
2798
- markets = this.arrayConcat(markets, optionMarkets);
2792
+ let markets = [];
2793
+ for (let i = 0; i < fetchMarkets.length; i++) {
2794
+ const promise = this.safeDict(promises, i);
2795
+ const promiseMarkets = this.safeList2(promise, 'symbols', 'optionSymbols', []);
2796
+ markets = this.arrayConcat(markets, promiseMarkets);
2797
+ }
2799
2798
  //
2800
2799
  // spot / margin
2801
2800
  //
@@ -3325,6 +3324,7 @@ export default class binance extends Exchange {
3325
3324
  * @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
3326
3325
  * @param {string[]|undefined} [params.symbols] unified market symbols, only used in isolated margin mode
3327
3326
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the balance for a portfolio margin account
3327
+ * @param {string} [params.subType] "linear" or "inverse"
3328
3328
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
3329
3329
  */
3330
3330
  await this.loadMarkets();
@@ -3903,6 +3903,7 @@ export default class binance extends Exchange {
3903
3903
  * @see https://binance-docs.github.io/apidocs/delivery/en/#symbol-order-book-ticker // future
3904
3904
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
3905
3905
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3906
+ * @param {string} [params.subType] "linear" or "inverse"
3906
3907
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
3907
3908
  */
3908
3909
  await this.loadMarkets();
@@ -3943,6 +3944,7 @@ export default class binance extends Exchange {
3943
3944
  * @see https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-ticker // future
3944
3945
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the last prices
3945
3946
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3947
+ * @param {string} [params.subType] "linear" or "inverse"
3946
3948
  * @returns {object} a dictionary of lastprices structures
3947
3949
  */
3948
3950
  await this.loadMarkets();
@@ -4048,6 +4050,7 @@ export default class binance extends Exchange {
4048
4050
  * @see https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics // option
4049
4051
  * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
4050
4052
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4053
+ * @param {string} [params.subType] "linear" or "inverse"
4051
4054
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
4052
4055
  */
4053
4056
  await this.loadMarkets();
@@ -6474,6 +6477,7 @@ export default class binance extends Exchange {
6474
6477
  * @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
6475
6478
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch open orders in the portfolio margin account
6476
6479
  * @param {boolean} [params.stop] set to true if you would like to fetch portfolio margin account conditional orders
6480
+ * @param {string} [params.subType] "linear" or "inverse"
6477
6481
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
6478
6482
  */
6479
6483
  await this.loadMarkets();
@@ -8617,6 +8621,7 @@ export default class binance extends Exchange {
8617
8621
  * @param {string} symbol unified market symbol
8618
8622
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8619
8623
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch trading fees in a portfolio margin account
8624
+ * @param {string} [params.subType] "linear" or "inverse"
8620
8625
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
8621
8626
  */
8622
8627
  await this.loadMarkets();
@@ -8685,6 +8690,7 @@ export default class binance extends Exchange {
8685
8690
  * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
8686
8691
  * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
8687
8692
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8693
+ * @param {string} [params.subType] "linear" or "inverse"
8688
8694
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
8689
8695
  */
8690
8696
  await this.loadMarkets();
@@ -8942,6 +8948,7 @@ export default class binance extends Exchange {
8942
8948
  * @param {object} [params] extra parameters specific to the exchange API endpoint
8943
8949
  * @param {int} [params.until] timestamp in ms of the latest funding rate
8944
8950
  * @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)
8951
+ * @param {string} [params.subType] "linear" or "inverse"
8945
8952
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
8946
8953
  */
8947
8954
  await this.loadMarkets();
@@ -9015,6 +9022,7 @@ export default class binance extends Exchange {
9015
9022
  * @see https://binance-docs.github.io/apidocs/delivery/en/#index-price-and-mark-price
9016
9023
  * @param {string[]|undefined} symbols list of unified market symbols
9017
9024
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9025
+ * @param {string} [params.subType] "linear" or "inverse"
9018
9026
  * @returns {object} a dictionary of [funding rates structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexe by market symbols
9019
9027
  */
9020
9028
  await this.loadMarkets();
@@ -9638,6 +9646,7 @@ export default class binance extends Exchange {
9638
9646
  * @param {string[]|undefined} symbols list of unified market symbols
9639
9647
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9640
9648
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the leverage tiers for a portfolio margin account
9649
+ * @param {string} [params.subType] "linear" or "inverse"
9641
9650
  * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
9642
9651
  */
9643
9652
  await this.loadMarkets();
@@ -9952,6 +9961,7 @@ export default class binance extends Exchange {
9952
9961
  * @param {string[]|undefined} symbols list of unified market symbols
9953
9962
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9954
9963
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
9964
+ * @param {string} [params.subType] "linear" or "inverse"
9955
9965
  * @returns {object} data on account positions
9956
9966
  */
9957
9967
  if (symbols !== undefined) {
@@ -10005,6 +10015,7 @@ export default class binance extends Exchange {
10005
10015
  * @param {string[]|undefined} symbols list of unified market symbols
10006
10016
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10007
10017
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions for a portfolio margin account
10018
+ * @param {string} [params.subType] "linear" or "inverse"
10008
10019
  * @returns {object} data on the positions risk
10009
10020
  */
10010
10021
  if (symbols !== undefined) {
@@ -10164,6 +10175,7 @@ export default class binance extends Exchange {
10164
10175
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10165
10176
  * @param {int} [params.until] timestamp in ms of the latest funding history entry
10166
10177
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the funding history for a portfolio margin account
10178
+ * @param {string} [params.subType] "linear" or "inverse"
10167
10179
  * @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
10168
10180
  */
10169
10181
  await this.loadMarkets();
@@ -10348,6 +10360,7 @@ export default class binance extends Exchange {
10348
10360
  * @param {string} symbol not used by binance setPositionMode ()
10349
10361
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10350
10362
  * @param {boolean} [params.portfolioMargin] set to true if you would like to set the position mode for a portfolio margin account
10363
+ * @param {string} [params.subType] "linear" or "inverse"
10351
10364
  * @returns {object} response from the exchange
10352
10365
  */
10353
10366
  const defaultType = this.safeString(this.options, 'defaultType', 'future');
@@ -10376,7 +10389,7 @@ export default class binance extends Exchange {
10376
10389
  response = await this.dapiPrivatePostPositionSideDual(this.extend(request, params));
10377
10390
  }
10378
10391
  }
10379
- else {
10392
+ else if (this.isLinear(type, subType)) {
10380
10393
  if (isPortfolioMargin) {
10381
10394
  response = await this.papiPostUmPositionSideDual(this.extend(request, params));
10382
10395
  }
@@ -10384,6 +10397,9 @@ export default class binance extends Exchange {
10384
10397
  response = await this.fapiPrivatePostPositionSideDual(this.extend(request, params));
10385
10398
  }
10386
10399
  }
10400
+ else {
10401
+ throw new BadRequest(this.id + ' setPositionMode() supports linear and inverse contracts only');
10402
+ }
10387
10403
  //
10388
10404
  // {
10389
10405
  // "code": 200,
@@ -10403,6 +10419,7 @@ export default class binance extends Exchange {
10403
10419
  * @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
10404
10420
  * @param {string[]} [symbols] a list of unified market symbols
10405
10421
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10422
+ * @param {string} [params.subType] "linear" or "inverse"
10406
10423
  * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
10407
10424
  */
10408
10425
  await this.loadMarkets();
@@ -10677,6 +10694,7 @@ export default class binance extends Exchange {
10677
10694
  * @param {int} [params.until] timestamp in ms of the latest ledger entry
10678
10695
  * @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)
10679
10696
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch the ledger for a portfolio margin account
10697
+ * @param {string} [params.subType] "linear" or "inverse"
10680
10698
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
10681
10699
  */
10682
10700
  await this.loadMarkets();
@@ -11820,6 +11838,8 @@ export default class binance extends Exchange {
11820
11838
  * @param {int} [params.until] timestamp in ms of the latest liquidation
11821
11839
  * @param {boolean} [params.paginate] *spot only* 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)
11822
11840
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch liquidations in a portfolio margin account
11841
+ * @param {string} [params.type] "spot"
11842
+ * @param {string} [params.subType] "linear" or "inverse"
11823
11843
  * @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
11824
11844
  */
11825
11845
  await this.loadMarkets();
@@ -12145,8 +12165,8 @@ export default class binance extends Exchange {
12145
12165
  * @name binance#fetchPositionMode
12146
12166
  * @description fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
12147
12167
  * @param {string} symbol unified symbol of the market to fetch the order book for
12148
- * @param {object} params extra parameters specific to the exchange API endpoint
12149
- * @param {string} params.subType "linear" or "inverse"
12168
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
12169
+ * @param {string} [params.subType] "linear" or "inverse"
12150
12170
  * @returns {object} an object detailing whether the market is in hedged or one-way mode
12151
12171
  */
12152
12172
  let market = undefined;
@@ -12184,7 +12204,8 @@ export default class binance extends Exchange {
12184
12204
  * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
12185
12205
  * @param {string} symbol unified symbol of the market the order was made in
12186
12206
  * @param {object} [params] extra parameters specific to the exchange API endpoint
12187
- * @returns {object} struct of marginMode
12207
+ * @param {string} [params.subType] "linear" or "inverse"
12208
+ * @returns {object} a list of [margin mode structures]{@link https://docs.ccxt.com/#/?id=margin-mode-structure}
12188
12209
  */
12189
12210
  await this.loadMarkets();
12190
12211
  let market = undefined;