ccxt 4.3.78 → 4.3.80

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
@@ -194,7 +194,7 @@ var xt$1 = require('./src/pro/xt.js');
194
194
 
195
195
  //-----------------------------------------------------------------------------
196
196
  // this is updated by vss.js when building
197
- const version = '4.3.78';
197
+ const version = '4.3.80';
198
198
  Exchange["default"].ccxtVersion = version;
199
199
  const exchanges = {
200
200
  'ace': ace,
@@ -1775,55 +1775,43 @@ class Exchange {
1775
1775
  let httpsProxy = undefined;
1776
1776
  let socksProxy = undefined;
1777
1777
  // httpProxy
1778
- if (this.valueIsDefined(this.httpProxy)) {
1778
+ const isHttpProxyDefined = this.valueIsDefined(this.httpProxy);
1779
+ const isHttp_proxy_defined = this.valueIsDefined(this.http_proxy);
1780
+ if (isHttpProxyDefined || isHttp_proxy_defined) {
1779
1781
  usedProxies.push('httpProxy');
1780
- httpProxy = this.httpProxy;
1782
+ httpProxy = isHttpProxyDefined ? this.httpProxy : this.http_proxy;
1781
1783
  }
1782
- if (this.valueIsDefined(this.http_proxy)) {
1783
- usedProxies.push('http_proxy');
1784
- httpProxy = this.http_proxy;
1785
- }
1786
- if (this.httpProxyCallback !== undefined) {
1784
+ const ishttpProxyCallbackDefined = this.valueIsDefined(this.httpProxyCallback);
1785
+ const ishttp_proxy_callback_defined = this.valueIsDefined(this.http_proxy_callback);
1786
+ if (ishttpProxyCallbackDefined || ishttp_proxy_callback_defined) {
1787
1787
  usedProxies.push('httpProxyCallback');
1788
- httpProxy = this.httpProxyCallback(url, method, headers, body);
1789
- }
1790
- if (this.http_proxy_callback !== undefined) {
1791
- usedProxies.push('http_proxy_callback');
1792
- httpProxy = this.http_proxy_callback(url, method, headers, body);
1788
+ httpProxy = ishttpProxyCallbackDefined ? this.httpProxyCallback(url, method, headers, body) : this.http_proxy_callback(url, method, headers, body);
1793
1789
  }
1794
1790
  // httpsProxy
1795
- if (this.valueIsDefined(this.httpsProxy)) {
1791
+ const isHttpsProxyDefined = this.valueIsDefined(this.httpsProxy);
1792
+ const isHttps_proxy_defined = this.valueIsDefined(this.https_proxy);
1793
+ if (isHttpsProxyDefined || isHttps_proxy_defined) {
1796
1794
  usedProxies.push('httpsProxy');
1797
- httpsProxy = this.httpsProxy;
1798
- }
1799
- if (this.valueIsDefined(this.https_proxy)) {
1800
- usedProxies.push('https_proxy');
1801
- httpsProxy = this.https_proxy;
1795
+ httpsProxy = isHttpsProxyDefined ? this.httpsProxy : this.https_proxy;
1802
1796
  }
1803
- if (this.httpsProxyCallback !== undefined) {
1797
+ const ishttpsProxyCallbackDefined = this.valueIsDefined(this.httpsProxyCallback);
1798
+ const ishttps_proxy_callback_defined = this.valueIsDefined(this.https_proxy_callback);
1799
+ if (ishttpsProxyCallbackDefined || ishttps_proxy_callback_defined) {
1804
1800
  usedProxies.push('httpsProxyCallback');
1805
- httpsProxy = this.httpsProxyCallback(url, method, headers, body);
1806
- }
1807
- if (this.https_proxy_callback !== undefined) {
1808
- usedProxies.push('https_proxy_callback');
1809
- httpsProxy = this.https_proxy_callback(url, method, headers, body);
1801
+ httpsProxy = ishttpsProxyCallbackDefined ? this.httpsProxyCallback(url, method, headers, body) : this.https_proxy_callback(url, method, headers, body);
1810
1802
  }
1811
1803
  // socksProxy
1812
- if (this.valueIsDefined(this.socksProxy)) {
1804
+ const isSocksProxyDefined = this.valueIsDefined(this.socksProxy);
1805
+ const isSocks_proxy_defined = this.valueIsDefined(this.socks_proxy);
1806
+ if (isSocksProxyDefined || isSocks_proxy_defined) {
1813
1807
  usedProxies.push('socksProxy');
1814
- socksProxy = this.socksProxy;
1815
- }
1816
- if (this.valueIsDefined(this.socks_proxy)) {
1817
- usedProxies.push('socks_proxy');
1818
- socksProxy = this.socks_proxy;
1808
+ socksProxy = isSocksProxyDefined ? this.socksProxy : this.socks_proxy;
1819
1809
  }
1820
- if (this.socksProxyCallback !== undefined) {
1810
+ const issocksProxyCallbackDefined = this.valueIsDefined(this.socksProxyCallback);
1811
+ const issocks_proxy_callback_defined = this.valueIsDefined(this.socks_proxy_callback);
1812
+ if (issocksProxyCallbackDefined || issocks_proxy_callback_defined) {
1821
1813
  usedProxies.push('socksProxyCallback');
1822
- socksProxy = this.socksProxyCallback(url, method, headers, body);
1823
- }
1824
- if (this.socks_proxy_callback !== undefined) {
1825
- usedProxies.push('socks_proxy_callback');
1826
- socksProxy = this.socks_proxy_callback(url, method, headers, body);
1814
+ socksProxy = issocksProxyCallbackDefined ? this.socksProxyCallback(url, method, headers, body) : this.socks_proxy_callback(url, method, headers, body);
1827
1815
  }
1828
1816
  // check
1829
1817
  const length = usedProxies.length;
@@ -51,7 +51,7 @@ class binance extends binance$1 {
51
51
  'createMarketSellOrderWithCost': true,
52
52
  'createOrder': true,
53
53
  'createOrders': true,
54
- 'createOrderWithTakeProfitAndStopLoss': true,
54
+ 'createOrderWithTakeProfitAndStopLoss': false,
55
55
  'createPostOnlyOrder': true,
56
56
  'createReduceOnlyOrder': true,
57
57
  'createStopLimitOrder': true,
@@ -3553,7 +3553,7 @@ class binance extends binance$1 {
3553
3553
  //
3554
3554
  // futures (fapi)
3555
3555
  //
3556
- // fapiPrivateV2GetAccount
3556
+ // fapiPrivateV3GetAccount
3557
3557
  //
3558
3558
  // {
3559
3559
  // "feeTier":0,
@@ -8997,6 +8997,7 @@ class binance extends binance$1 {
8997
8997
  * @see https://developers.binance.com/docs/wallet/asset/trade-fee
8998
8998
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
8999
8999
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
9000
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Config
9000
9001
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9001
9002
  * @param {string} [params.subType] "linear" or "inverse"
9002
9003
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
@@ -9014,7 +9015,7 @@ class binance extends binance$1 {
9014
9015
  response = await this.sapiGetAssetTradeFee(params);
9015
9016
  }
9016
9017
  else if (isLinear) {
9017
- response = await this.fapiPrivateV2GetAccount(params);
9018
+ response = await this.fapiPrivateGetAccountConfig(params);
9018
9019
  }
9019
9020
  else if (isInverse) {
9020
9021
  response = await this.dapiPrivateGetAccount(params);
@@ -10319,6 +10320,7 @@ class binance extends binance$1 {
10319
10320
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
10320
10321
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V2
10321
10322
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Position-Information
10323
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V3
10322
10324
  * @param {string[]} [symbols] list of unified market symbols
10323
10325
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10324
10326
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
@@ -10450,6 +10452,7 @@ class binance extends binance$1 {
10450
10452
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Position-Information
10451
10453
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Query-UM-Position-Information
10452
10454
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Query-CM-Position-Information
10455
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V3
10453
10456
  * @param {string[]|undefined} symbols list of unified market symbols
10454
10457
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10455
10458
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions for a portfolio margin account
@@ -10867,6 +10870,7 @@ class binance extends binance$1 {
10867
10870
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
10868
10871
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Account-Detail
10869
10872
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Account-Detail
10873
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config
10870
10874
  * @param {string[]} [symbols] a list of unified market symbols
10871
10875
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10872
10876
  * @param {string} [params.subType] "linear" or "inverse"
@@ -10886,7 +10890,7 @@ class binance extends binance$1 {
10886
10890
  response = await this.papiGetUmAccount(params);
10887
10891
  }
10888
10892
  else {
10889
- response = await this.fapiPrivateV2GetAccount(params);
10893
+ response = await this.fapiPrivateGetSymbolConfig(params);
10890
10894
  }
10891
10895
  }
10892
10896
  else if (this.isInverse(type, subType)) {
@@ -10900,7 +10904,10 @@ class binance extends binance$1 {
10900
10904
  else {
10901
10905
  throw new errors.NotSupported(this.id + ' fetchLeverages() supports linear and inverse contracts only');
10902
10906
  }
10903
- const leverages = this.safeList(response, 'positions', []);
10907
+ let leverages = this.safeList(response, 'positions', []);
10908
+ if (Array.isArray(response)) {
10909
+ leverages = response;
10910
+ }
10904
10911
  return this.parseLeverages(leverages, symbols, 'symbol');
10905
10912
  }
10906
10913
  parseLeverage(leverage, market = undefined) {
@@ -10910,6 +10917,10 @@ class binance extends binance$1 {
10910
10917
  if (marginModeRaw !== undefined) {
10911
10918
  marginMode = marginModeRaw ? 'isolated' : 'cross';
10912
10919
  }
10920
+ const marginTypeRaw = this.safeStringLower(leverage, 'marginType');
10921
+ if (marginTypeRaw !== undefined) {
10922
+ marginMode = (marginTypeRaw === 'crossed') ? 'cross' : 'isolated';
10923
+ }
10913
10924
  const side = this.safeStringLower(leverage, 'positionSide');
10914
10925
  let longLeverage = undefined;
10915
10926
  let shortLeverage = undefined;
@@ -12789,6 +12800,7 @@ class binance extends binance$1 {
12789
12800
  * @description fetches margin modes ("isolated" or "cross") that the market for the symbol in in, with symbol=undefined all markets for a subType (linear/inverse) are returned
12790
12801
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
12791
12802
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
12803
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config
12792
12804
  * @param {string} symbol unified symbol of the market the order was made in
12793
12805
  * @param {object} [params] extra parameters specific to the exchange API endpoint
12794
12806
  * @param {string} [params.subType] "linear" or "inverse"
@@ -12804,70 +12816,17 @@ class binance extends binance$1 {
12804
12816
  [subType, params] = this.handleSubTypeAndParams('fetchMarginMode', market, params);
12805
12817
  let response = undefined;
12806
12818
  if (subType === 'linear') {
12807
- response = await this.fapiPrivateV2GetAccount(params);
12819
+ response = await this.fapiPrivateGetSymbolConfig(params);
12808
12820
  //
12809
- // {
12810
- // feeTier: '0',
12811
- // canTrade: true,
12812
- // canDeposit: true,
12813
- // canWithdraw: true,
12814
- // tradeGroupId: '-1',
12815
- // updateTime: '0',
12816
- // multiAssetsMargin: true,
12817
- // totalInitialMargin: '438.31134352',
12818
- // totalMaintMargin: '5.90847101',
12819
- // totalWalletBalance: '4345.15626338',
12820
- // totalUnrealizedProfit: '376.45220224',
12821
- // totalMarginBalance: '4721.60846562',
12822
- // totalPositionInitialMargin: '425.45252687',
12823
- // totalOpenOrderInitialMargin: '12.85881664',
12824
- // totalCrossWalletBalance: '4345.15626338',
12825
- // totalCrossUnPnl: '376.45220224',
12826
- // availableBalance: '4281.84764041',
12827
- // maxWithdrawAmount: '4281.84764041',
12828
- // assets: [
12829
- // {
12830
- // asset: 'ETH',
12831
- // walletBalance: '0.00000000',
12832
- // unrealizedProfit: '0.00000000',
12833
- // marginBalance: '0.00000000',
12834
- // maintMargin: '0.00000000',
12835
- // initialMargin: '0.00000000',
12836
- // positionInitialMargin: '0.00000000',
12837
- // openOrderInitialMargin: '0.00000000',
12838
- // maxWithdrawAmount: '0.00000000',
12839
- // crossWalletBalance: '0.00000000',
12840
- // crossUnPnl: '0.00000000',
12841
- // availableBalance: '1.26075574',
12842
- // marginAvailable: true,
12843
- // updateTime: '0'
12844
- // },
12845
- // ...
12846
- // ],
12847
- // positions: [
12848
- // {
12849
- // symbol: 'SNTUSDT',
12850
- // initialMargin: '0',
12851
- // maintMargin: '0',
12852
- // unrealizedProfit: '0.00000000',
12853
- // positionInitialMargin: '0',
12854
- // openOrderInitialMargin: '0',
12855
- // leverage: '20',
12856
- // isolated: false,
12857
- // entryPrice: '0.0',
12858
- // breakEvenPrice: '0.0',
12859
- // maxNotional: '25000',
12860
- // positionSide: 'BOTH',
12861
- // positionAmt: '0',
12862
- // notional: '0',
12863
- // isolatedWallet: '0',
12864
- // updateTime: '0',
12865
- // bidNotional: '0',
12866
- // askNotional: '0'
12867
- // },
12868
- // ...
12869
- // ]
12870
- // }
12821
+ // [
12822
+ // {
12823
+ // "symbol": "BTCUSDT",
12824
+ // "marginType": "CROSSED",
12825
+ // "isAutoAddMargin": "false",
12826
+ // "leverage": 21,
12827
+ // "maxNotionalValue": "1000000",
12828
+ // }
12829
+ // ]
12871
12830
  //
12872
12831
  }
12873
12832
  else if (subType === 'inverse') {
@@ -12924,17 +12883,28 @@ class binance extends binance$1 {
12924
12883
  else {
12925
12884
  throw new errors.BadRequest(this.id + ' fetchMarginModes () supports linear and inverse subTypes only');
12926
12885
  }
12927
- const assets = this.safeList(response, 'positions', []);
12886
+ let assets = this.safeList(response, 'positions', []);
12887
+ if (Array.isArray(response)) {
12888
+ assets = response;
12889
+ }
12928
12890
  return this.parseMarginModes(assets, symbols, 'symbol', 'swap');
12929
12891
  }
12930
12892
  parseMarginMode(marginMode, market = undefined) {
12931
12893
  const marketId = this.safeString(marginMode, 'symbol');
12932
12894
  market = this.safeMarket(marketId, market);
12933
- const isIsolated = this.safeBool(marginMode, 'isolated');
12895
+ const marginModeRaw = this.safeBool(marginMode, 'isolated');
12896
+ let reMarginMode = undefined;
12897
+ if (marginModeRaw !== undefined) {
12898
+ reMarginMode = marginModeRaw ? 'isolated' : 'cross';
12899
+ }
12900
+ const marginTypeRaw = this.safeStringLower(marginMode, 'marginType');
12901
+ if (marginTypeRaw !== undefined) {
12902
+ reMarginMode = (marginTypeRaw === 'crossed') ? 'cross' : 'isolated';
12903
+ }
12934
12904
  return {
12935
12905
  'info': marginMode,
12936
12906
  'symbol': market['symbol'],
12937
- 'marginMode': isIsolated ? 'isolated' : 'cross',
12907
+ 'marginMode': reMarginMode,
12938
12908
  };
12939
12909
  }
12940
12910
  async fetchOption(symbol, params = {}) {
@@ -2461,8 +2461,6 @@ class bitmart extends bitmart$1 {
2461
2461
  * @see https://developer-pro.bitmart.com/en/spot/#place-margin-order
2462
2462
  * @see https://developer-pro.bitmart.com/en/futures/#submit-order-signed
2463
2463
  * @see https://developer-pro.bitmart.com/en/futures/#submit-plan-order-signed
2464
- * @see https://developer-pro.bitmart.com/en/futures/#submit-order-signed
2465
- * @see https://developer-pro.bitmart.com/en/futures/#submit-plan-order-signed
2466
2464
  * @see https://developer-pro.bitmart.com/en/futuresv2/#submit-plan-order-signed
2467
2465
  * @param {string} symbol unified symbol of the market to create an order in
2468
2466
  * @param {string} type 'market', 'limit' or 'trailing' for swap markets only
@@ -2609,6 +2607,7 @@ class bitmart extends bitmart$1 {
2609
2607
  * @description create a trade order
2610
2608
  * @see https://developer-pro.bitmart.com/en/futures/#submit-order-signed
2611
2609
  * @see https://developer-pro.bitmart.com/en/futures/#submit-plan-order-signed
2610
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#submit-plan-order-signed
2612
2611
  * @param {string} symbol unified symbol of the market to create an order in
2613
2612
  * @param {string} type 'market', 'limit' or 'trailing'
2614
2613
  * @param {string} side 'buy' or 'sell'
@@ -2668,7 +2667,9 @@ class bitmart extends bitmart$1 {
2668
2667
  request['activation_price_type'] = this.safeInteger(params, 'activation_price_type', 1);
2669
2668
  }
2670
2669
  if (isTriggerOrder) {
2671
- request['executive_price'] = this.priceToPrecision(symbol, price);
2670
+ if (isLimitOrder || price !== undefined) {
2671
+ request['executive_price'] = this.priceToPrecision(symbol, price);
2672
+ }
2672
2673
  request['trigger_price'] = this.priceToPrecision(symbol, triggerPrice);
2673
2674
  request['price_type'] = this.safeInteger(params, 'price_type', 1);
2674
2675
  if (side === 'buy') {
@@ -5889,10 +5889,12 @@ class bybit extends bybit$1 {
5889
5889
  * @name bybit#fetchLedger
5890
5890
  * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
5891
5891
  * @see https://bybit-exchange.github.io/docs/v5/account/transaction-log
5892
+ * @see https://bybit-exchange.github.io/docs/v5/account/contract-transaction-log
5892
5893
  * @param {string} code unified currency code, default is undefined
5893
5894
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
5894
5895
  * @param {int} [limit] max number of ledger entrys to return, default is undefined
5895
5896
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5897
+ * @param {string} [params.subType] if inverse will use v5/account/contract-transaction-log
5896
5898
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
5897
5899
  */
5898
5900
  await this.loadMarkets();
@@ -5936,9 +5938,16 @@ class bybit extends bybit$1 {
5936
5938
  if (limit !== undefined) {
5937
5939
  request['limit'] = limit;
5938
5940
  }
5941
+ let subType = undefined;
5942
+ [subType, params] = this.handleSubTypeAndParams('fetchLedger', undefined, params);
5939
5943
  let response = undefined;
5940
5944
  if (enableUnified[1]) {
5941
- response = await this.privateGetV5AccountTransactionLog(this.extend(request, params));
5945
+ if (subType === 'inverse') {
5946
+ response = await this.privateGetV5AccountContractTransactionLog(this.extend(request, params));
5947
+ }
5948
+ else {
5949
+ response = await this.privateGetV5AccountTransactionLog(this.extend(request, params));
5950
+ }
5942
5951
  }
5943
5952
  else {
5944
5953
  response = await this.privateGetV2PrivateWalletFundRecords(this.extend(request, params));
@@ -1105,8 +1105,10 @@ class poloniex extends poloniex$1 {
1105
1105
  market = this.safeMarket(marketId, market, '_');
1106
1106
  const symbol = market['symbol'];
1107
1107
  let resultingTrades = this.safeValue(order, 'resultingTrades');
1108
- if (!Array.isArray(resultingTrades)) {
1109
- resultingTrades = this.safeValue(resultingTrades, this.safeString(market, 'id', marketId));
1108
+ if (resultingTrades !== undefined) {
1109
+ if (!Array.isArray(resultingTrades)) {
1110
+ resultingTrades = this.safeValue(resultingTrades, this.safeString(market, 'id', marketId));
1111
+ }
1110
1112
  }
1111
1113
  const price = this.safeString2(order, 'price', 'rate');
1112
1114
  const amount = this.safeString(order, 'quantity');
@@ -2064,7 +2064,7 @@ class binance extends binance$1 {
2064
2064
  * @param {string|undefined} [params.type] 'future', 'delivery', 'savings', 'funding', or 'spot'
2065
2065
  * @param {string|undefined} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
2066
2066
  * @param {string[]|undefined} [params.symbols] unified market symbols, only used in isolated margin mode
2067
- * @param {string|undefined} [params.method] method to use. Can be account.balance or account.status
2067
+ * @param {string|undefined} [params.method] method to use. Can be account.balance, account.status, v2/account.balance or v2/account.status
2068
2068
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
2069
2069
  */
2070
2070
  await this.loadMarkets();
@@ -2096,8 +2096,16 @@ class binance extends binance$1 {
2096
2096
  //
2097
2097
  //
2098
2098
  const messageHash = this.safeString(message, 'id');
2099
- const result = this.safeDict(message, 'result', {});
2100
- const rawBalance = this.safeList(result, 0, []);
2099
+ let rawBalance = undefined;
2100
+ if (Array.isArray(message['result'])) {
2101
+ // account.balance
2102
+ rawBalance = this.safeList(message, 'result', []);
2103
+ }
2104
+ else {
2105
+ // account.status
2106
+ const result = this.safeDict(message, 'result', {});
2107
+ rawBalance = this.safeList(result, 'assets', []);
2108
+ }
2101
2109
  const parsedBalances = this.parseBalanceCustom(rawBalance);
2102
2110
  client.resolve(parsedBalances, messageHash);
2103
2111
  }
@@ -2174,6 +2182,7 @@ class binance extends binance$1 {
2174
2182
  * @param {string[]} [symbols] list of unified market symbols
2175
2183
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2176
2184
  * @param {boolean} [params.returnRateLimits] set to true to return rate limit informations, defaults to false.
2185
+ * @param {string|undefined} [params.method] method to use. Can be account.position or v2/account.position
2177
2186
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
2178
2187
  */
2179
2188
  await this.loadMarkets();
@@ -2191,9 +2200,11 @@ class binance extends binance$1 {
2191
2200
  let returnRateLimits = false;
2192
2201
  [returnRateLimits, params] = this.handleOptionAndParams(params, 'fetchPositionsWs', 'returnRateLimits', false);
2193
2202
  payload['returnRateLimits'] = returnRateLimits;
2203
+ let method = undefined;
2204
+ [method, params] = this.handleOptionAndParams(params, 'fetchPositionsWs', 'method', 'account.position');
2194
2205
  const message = {
2195
2206
  'id': messageHash,
2196
- 'method': 'account.position',
2207
+ 'method': method,
2197
2208
  'params': this.signParams(this.extend(payload, params)),
2198
2209
  };
2199
2210
  const subscription = {
@@ -3291,7 +3302,7 @@ class binance extends binance$1 {
3291
3302
  this.setBalanceCache(client, type, isPortfolioMargin);
3292
3303
  this.setPositionsCache(client, type, symbols, isPortfolioMargin);
3293
3304
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
3294
- const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
3305
+ const awaitPositionsSnapshot = this.handleOption('watchPositions', 'awaitPositionsSnapshot', true);
3295
3306
  const cache = this.safeValue(this.positions, type);
3296
3307
  if (fetchPositionsSnapshot && awaitPositionsSnapshot && cache === undefined) {
3297
3308
  const snapshot = await client.future(type + ':fetchPositionsSnapshot');
@@ -1127,7 +1127,7 @@ class bybit extends bybit$1 {
1127
1127
  this.setPositionsCache(client, symbols);
1128
1128
  const cache = this.positions;
1129
1129
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
1130
- const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
1130
+ const awaitPositionsSnapshot = this.handleOption('watchPositions', 'awaitPositionsSnapshot', true);
1131
1131
  if (fetchPositionsSnapshot && awaitPositionsSnapshot && cache === undefined) {
1132
1132
  const snapshot = await client.future('fetchPositionsSnapshot');
1133
1133
  return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
@@ -561,7 +561,7 @@ class cryptocom extends cryptocom$1 {
561
561
  const client = this.client(url);
562
562
  this.setPositionsCache(client, symbols);
563
563
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
564
- const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
564
+ const awaitPositionsSnapshot = this.handleOption('watchPositions', 'awaitPositionsSnapshot', true);
565
565
  if (fetchPositionsSnapshot && awaitPositionsSnapshot && this.positions === undefined) {
566
566
  const snapshot = await client.future('fetchPositionsSnapshot');
567
567
  return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
@@ -1086,7 +1086,7 @@ class gate extends gate$1 {
1086
1086
  const client = this.client(url);
1087
1087
  this.setPositionsCache(client, type, symbols);
1088
1088
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
1089
- const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
1089
+ const awaitPositionsSnapshot = this.handleOption('watchPositions', 'awaitPositionsSnapshot', true);
1090
1090
  const cache = this.safeValue(this.positions, type);
1091
1091
  if (fetchPositionsSnapshot && awaitPositionsSnapshot && cache === undefined) {
1092
1092
  return await client.future(type + ':fetchPositionsSnapshot');
@@ -351,7 +351,7 @@ class kucoinfutures extends kucoinfutures$1 {
351
351
  const client = this.client(url);
352
352
  this.setPositionCache(client, symbol);
353
353
  const fetchPositionSnapshot = this.handleOption('watchPosition', 'fetchPositionSnapshot', true);
354
- const awaitPositionSnapshot = this.safeBool('watchPosition', 'awaitPositionSnapshot', true);
354
+ const awaitPositionSnapshot = this.handleOption('watchPosition', 'awaitPositionSnapshot', true);
355
355
  const currentPosition = this.getCurrentPosition(symbol);
356
356
  if (fetchPositionSnapshot && awaitPositionSnapshot && currentPosition === undefined) {
357
357
  const snapshot = await client.future('fetchPositionSnapshot:' + symbol);
@@ -572,7 +572,7 @@ class vertex extends vertex$1 {
572
572
  const client = this.client(url);
573
573
  this.setPositionsCache(client, symbols, params);
574
574
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
575
- const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
575
+ const awaitPositionsSnapshot = this.handleOption('watchPositions', 'awaitPositionsSnapshot', true);
576
576
  if (fetchPositionsSnapshot && awaitPositionsSnapshot && this.positions === undefined) {
577
577
  const snapshot = await client.future('fetchPositionsSnapshot');
578
578
  return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
@@ -968,7 +968,7 @@ class woo extends woo$1 {
968
968
  const client = this.client(url);
969
969
  this.setPositionsCache(client, symbols);
970
970
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
971
- const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
971
+ const awaitPositionsSnapshot = this.handleOption('watchPositions', 'awaitPositionsSnapshot', true);
972
972
  if (fetchPositionsSnapshot && awaitPositionsSnapshot && this.positions === undefined) {
973
973
  const snapshot = await client.future('fetchPositionsSnapshot');
974
974
  return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
@@ -912,7 +912,7 @@ class woofipro extends woofipro$1 {
912
912
  const client = this.client(url);
913
913
  this.setPositionsCache(client, symbols);
914
914
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
915
- const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
915
+ const awaitPositionsSnapshot = this.handleOption('watchPositions', 'awaitPositionsSnapshot', true);
916
916
  if (fetchPositionsSnapshot && awaitPositionsSnapshot && this.positions === undefined) {
917
917
  const snapshot = await client.future('fetchPositionsSnapshot');
918
918
  return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, 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 { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending } from './src/base/errors.js';
7
- declare const version = "4.3.77";
7
+ declare const version = "4.3.79";
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, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.3.78';
41
+ const version = '4.3.80';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -1146,7 +1146,7 @@ export default class Exchange {
1146
1146
  fetchPositionHistory(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Position>;
1147
1147
  fetchPositionsHistory(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
1148
1148
  parseMarginModification(data: Dict, market?: Market): MarginModification;
1149
- parseMarginModifications(response: object[], symbols?: string[], symbolKey?: Str, marketType?: MarketType): MarginModification[];
1149
+ parseMarginModifications(response: object[], symbols?: Strings, symbolKey?: Str, marketType?: MarketType): MarginModification[];
1150
1150
  fetchTransfer(id: string, code?: Str, params?: {}): Promise<TransferEntry>;
1151
1151
  fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<TransferEntry[]>;
1152
1152
  }
@@ -1758,55 +1758,43 @@ export default class Exchange {
1758
1758
  let httpsProxy = undefined;
1759
1759
  let socksProxy = undefined;
1760
1760
  // httpProxy
1761
- if (this.valueIsDefined(this.httpProxy)) {
1761
+ const isHttpProxyDefined = this.valueIsDefined(this.httpProxy);
1762
+ const isHttp_proxy_defined = this.valueIsDefined(this.http_proxy);
1763
+ if (isHttpProxyDefined || isHttp_proxy_defined) {
1762
1764
  usedProxies.push('httpProxy');
1763
- httpProxy = this.httpProxy;
1765
+ httpProxy = isHttpProxyDefined ? this.httpProxy : this.http_proxy;
1764
1766
  }
1765
- if (this.valueIsDefined(this.http_proxy)) {
1766
- usedProxies.push('http_proxy');
1767
- httpProxy = this.http_proxy;
1768
- }
1769
- if (this.httpProxyCallback !== undefined) {
1767
+ const ishttpProxyCallbackDefined = this.valueIsDefined(this.httpProxyCallback);
1768
+ const ishttp_proxy_callback_defined = this.valueIsDefined(this.http_proxy_callback);
1769
+ if (ishttpProxyCallbackDefined || ishttp_proxy_callback_defined) {
1770
1770
  usedProxies.push('httpProxyCallback');
1771
- httpProxy = this.httpProxyCallback(url, method, headers, body);
1772
- }
1773
- if (this.http_proxy_callback !== undefined) {
1774
- usedProxies.push('http_proxy_callback');
1775
- httpProxy = this.http_proxy_callback(url, method, headers, body);
1771
+ httpProxy = ishttpProxyCallbackDefined ? this.httpProxyCallback(url, method, headers, body) : this.http_proxy_callback(url, method, headers, body);
1776
1772
  }
1777
1773
  // httpsProxy
1778
- if (this.valueIsDefined(this.httpsProxy)) {
1774
+ const isHttpsProxyDefined = this.valueIsDefined(this.httpsProxy);
1775
+ const isHttps_proxy_defined = this.valueIsDefined(this.https_proxy);
1776
+ if (isHttpsProxyDefined || isHttps_proxy_defined) {
1779
1777
  usedProxies.push('httpsProxy');
1780
- httpsProxy = this.httpsProxy;
1781
- }
1782
- if (this.valueIsDefined(this.https_proxy)) {
1783
- usedProxies.push('https_proxy');
1784
- httpsProxy = this.https_proxy;
1778
+ httpsProxy = isHttpsProxyDefined ? this.httpsProxy : this.https_proxy;
1785
1779
  }
1786
- if (this.httpsProxyCallback !== undefined) {
1780
+ const ishttpsProxyCallbackDefined = this.valueIsDefined(this.httpsProxyCallback);
1781
+ const ishttps_proxy_callback_defined = this.valueIsDefined(this.https_proxy_callback);
1782
+ if (ishttpsProxyCallbackDefined || ishttps_proxy_callback_defined) {
1787
1783
  usedProxies.push('httpsProxyCallback');
1788
- httpsProxy = this.httpsProxyCallback(url, method, headers, body);
1789
- }
1790
- if (this.https_proxy_callback !== undefined) {
1791
- usedProxies.push('https_proxy_callback');
1792
- httpsProxy = this.https_proxy_callback(url, method, headers, body);
1784
+ httpsProxy = ishttpsProxyCallbackDefined ? this.httpsProxyCallback(url, method, headers, body) : this.https_proxy_callback(url, method, headers, body);
1793
1785
  }
1794
1786
  // socksProxy
1795
- if (this.valueIsDefined(this.socksProxy)) {
1787
+ const isSocksProxyDefined = this.valueIsDefined(this.socksProxy);
1788
+ const isSocks_proxy_defined = this.valueIsDefined(this.socks_proxy);
1789
+ if (isSocksProxyDefined || isSocks_proxy_defined) {
1796
1790
  usedProxies.push('socksProxy');
1797
- socksProxy = this.socksProxy;
1798
- }
1799
- if (this.valueIsDefined(this.socks_proxy)) {
1800
- usedProxies.push('socks_proxy');
1801
- socksProxy = this.socks_proxy;
1791
+ socksProxy = isSocksProxyDefined ? this.socksProxy : this.socks_proxy;
1802
1792
  }
1803
- if (this.socksProxyCallback !== undefined) {
1793
+ const issocksProxyCallbackDefined = this.valueIsDefined(this.socksProxyCallback);
1794
+ const issocks_proxy_callback_defined = this.valueIsDefined(this.socks_proxy_callback);
1795
+ if (issocksProxyCallbackDefined || issocks_proxy_callback_defined) {
1804
1796
  usedProxies.push('socksProxyCallback');
1805
- socksProxy = this.socksProxyCallback(url, method, headers, body);
1806
- }
1807
- if (this.socks_proxy_callback !== undefined) {
1808
- usedProxies.push('socks_proxy_callback');
1809
- socksProxy = this.socks_proxy_callback(url, method, headers, body);
1797
+ socksProxy = issocksProxyCallbackDefined ? this.socksProxyCallback(url, method, headers, body) : this.socks_proxy_callback(url, method, headers, body);
1810
1798
  }
1811
1799
  // check
1812
1800
  const length = usedProxies.length;