ccxt 4.3.78 → 4.3.79

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.79';
198
198
  Exchange["default"].ccxtVersion = version;
199
199
  const exchanges = {
200
200
  'ace': ace,
@@ -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 = {}) {
@@ -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.78";
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.79';
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
  }
package/js/src/binance.js CHANGED
@@ -3556,7 +3556,7 @@ export default class binance extends Exchange {
3556
3556
  //
3557
3557
  // futures (fapi)
3558
3558
  //
3559
- // fapiPrivateV2GetAccount
3559
+ // fapiPrivateV3GetAccount
3560
3560
  //
3561
3561
  // {
3562
3562
  // "feeTier":0,
@@ -9000,6 +9000,7 @@ export default class binance extends Exchange {
9000
9000
  * @see https://developers.binance.com/docs/wallet/asset/trade-fee
9001
9001
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
9002
9002
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
9003
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Config
9003
9004
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9004
9005
  * @param {string} [params.subType] "linear" or "inverse"
9005
9006
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
@@ -9017,7 +9018,7 @@ export default class binance extends Exchange {
9017
9018
  response = await this.sapiGetAssetTradeFee(params);
9018
9019
  }
9019
9020
  else if (isLinear) {
9020
- response = await this.fapiPrivateV2GetAccount(params);
9021
+ response = await this.fapiPrivateGetAccountConfig(params);
9021
9022
  }
9022
9023
  else if (isInverse) {
9023
9024
  response = await this.dapiPrivateGetAccount(params);
@@ -10322,6 +10323,7 @@ export default class binance extends Exchange {
10322
10323
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
10323
10324
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V2
10324
10325
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Position-Information
10326
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V3
10325
10327
  * @param {string[]} [symbols] list of unified market symbols
10326
10328
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10327
10329
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
@@ -10453,6 +10455,7 @@ export default class binance extends Exchange {
10453
10455
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Position-Information
10454
10456
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Query-UM-Position-Information
10455
10457
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Query-CM-Position-Information
10458
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V3
10456
10459
  * @param {string[]|undefined} symbols list of unified market symbols
10457
10460
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10458
10461
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions for a portfolio margin account
@@ -10870,6 +10873,7 @@ export default class binance extends Exchange {
10870
10873
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
10871
10874
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Account-Detail
10872
10875
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Account-Detail
10876
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config
10873
10877
  * @param {string[]} [symbols] a list of unified market symbols
10874
10878
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10875
10879
  * @param {string} [params.subType] "linear" or "inverse"
@@ -10889,7 +10893,7 @@ export default class binance extends Exchange {
10889
10893
  response = await this.papiGetUmAccount(params);
10890
10894
  }
10891
10895
  else {
10892
- response = await this.fapiPrivateV2GetAccount(params);
10896
+ response = await this.fapiPrivateGetSymbolConfig(params);
10893
10897
  }
10894
10898
  }
10895
10899
  else if (this.isInverse(type, subType)) {
@@ -10903,7 +10907,10 @@ export default class binance extends Exchange {
10903
10907
  else {
10904
10908
  throw new NotSupported(this.id + ' fetchLeverages() supports linear and inverse contracts only');
10905
10909
  }
10906
- const leverages = this.safeList(response, 'positions', []);
10910
+ let leverages = this.safeList(response, 'positions', []);
10911
+ if (Array.isArray(response)) {
10912
+ leverages = response;
10913
+ }
10907
10914
  return this.parseLeverages(leverages, symbols, 'symbol');
10908
10915
  }
10909
10916
  parseLeverage(leverage, market = undefined) {
@@ -10913,6 +10920,10 @@ export default class binance extends Exchange {
10913
10920
  if (marginModeRaw !== undefined) {
10914
10921
  marginMode = marginModeRaw ? 'isolated' : 'cross';
10915
10922
  }
10923
+ const marginTypeRaw = this.safeStringLower(leverage, 'marginType');
10924
+ if (marginTypeRaw !== undefined) {
10925
+ marginMode = (marginTypeRaw === 'crossed') ? 'cross' : 'isolated';
10926
+ }
10916
10927
  const side = this.safeStringLower(leverage, 'positionSide');
10917
10928
  let longLeverage = undefined;
10918
10929
  let shortLeverage = undefined;
@@ -12792,6 +12803,7 @@ export default class binance extends Exchange {
12792
12803
  * @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
12793
12804
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
12794
12805
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
12806
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config
12795
12807
  * @param {string} symbol unified symbol of the market the order was made in
12796
12808
  * @param {object} [params] extra parameters specific to the exchange API endpoint
12797
12809
  * @param {string} [params.subType] "linear" or "inverse"
@@ -12807,70 +12819,17 @@ export default class binance extends Exchange {
12807
12819
  [subType, params] = this.handleSubTypeAndParams('fetchMarginMode', market, params);
12808
12820
  let response = undefined;
12809
12821
  if (subType === 'linear') {
12810
- response = await this.fapiPrivateV2GetAccount(params);
12822
+ response = await this.fapiPrivateGetSymbolConfig(params);
12811
12823
  //
12812
- // {
12813
- // feeTier: '0',
12814
- // canTrade: true,
12815
- // canDeposit: true,
12816
- // canWithdraw: true,
12817
- // tradeGroupId: '-1',
12818
- // updateTime: '0',
12819
- // multiAssetsMargin: true,
12820
- // totalInitialMargin: '438.31134352',
12821
- // totalMaintMargin: '5.90847101',
12822
- // totalWalletBalance: '4345.15626338',
12823
- // totalUnrealizedProfit: '376.45220224',
12824
- // totalMarginBalance: '4721.60846562',
12825
- // totalPositionInitialMargin: '425.45252687',
12826
- // totalOpenOrderInitialMargin: '12.85881664',
12827
- // totalCrossWalletBalance: '4345.15626338',
12828
- // totalCrossUnPnl: '376.45220224',
12829
- // availableBalance: '4281.84764041',
12830
- // maxWithdrawAmount: '4281.84764041',
12831
- // assets: [
12832
- // {
12833
- // asset: 'ETH',
12834
- // walletBalance: '0.00000000',
12835
- // unrealizedProfit: '0.00000000',
12836
- // marginBalance: '0.00000000',
12837
- // maintMargin: '0.00000000',
12838
- // initialMargin: '0.00000000',
12839
- // positionInitialMargin: '0.00000000',
12840
- // openOrderInitialMargin: '0.00000000',
12841
- // maxWithdrawAmount: '0.00000000',
12842
- // crossWalletBalance: '0.00000000',
12843
- // crossUnPnl: '0.00000000',
12844
- // availableBalance: '1.26075574',
12845
- // marginAvailable: true,
12846
- // updateTime: '0'
12847
- // },
12848
- // ...
12849
- // ],
12850
- // positions: [
12851
- // {
12852
- // symbol: 'SNTUSDT',
12853
- // initialMargin: '0',
12854
- // maintMargin: '0',
12855
- // unrealizedProfit: '0.00000000',
12856
- // positionInitialMargin: '0',
12857
- // openOrderInitialMargin: '0',
12858
- // leverage: '20',
12859
- // isolated: false,
12860
- // entryPrice: '0.0',
12861
- // breakEvenPrice: '0.0',
12862
- // maxNotional: '25000',
12863
- // positionSide: 'BOTH',
12864
- // positionAmt: '0',
12865
- // notional: '0',
12866
- // isolatedWallet: '0',
12867
- // updateTime: '0',
12868
- // bidNotional: '0',
12869
- // askNotional: '0'
12870
- // },
12871
- // ...
12872
- // ]
12873
- // }
12824
+ // [
12825
+ // {
12826
+ // "symbol": "BTCUSDT",
12827
+ // "marginType": "CROSSED",
12828
+ // "isAutoAddMargin": "false",
12829
+ // "leverage": 21,
12830
+ // "maxNotionalValue": "1000000",
12831
+ // }
12832
+ // ]
12874
12833
  //
12875
12834
  }
12876
12835
  else if (subType === 'inverse') {
@@ -12927,17 +12886,28 @@ export default class binance extends Exchange {
12927
12886
  else {
12928
12887
  throw new BadRequest(this.id + ' fetchMarginModes () supports linear and inverse subTypes only');
12929
12888
  }
12930
- const assets = this.safeList(response, 'positions', []);
12889
+ let assets = this.safeList(response, 'positions', []);
12890
+ if (Array.isArray(response)) {
12891
+ assets = response;
12892
+ }
12931
12893
  return this.parseMarginModes(assets, symbols, 'symbol', 'swap');
12932
12894
  }
12933
12895
  parseMarginMode(marginMode, market = undefined) {
12934
12896
  const marketId = this.safeString(marginMode, 'symbol');
12935
12897
  market = this.safeMarket(marketId, market);
12936
- const isIsolated = this.safeBool(marginMode, 'isolated');
12898
+ const marginModeRaw = this.safeBool(marginMode, 'isolated');
12899
+ let reMarginMode = undefined;
12900
+ if (marginModeRaw !== undefined) {
12901
+ reMarginMode = marginModeRaw ? 'isolated' : 'cross';
12902
+ }
12903
+ const marginTypeRaw = this.safeStringLower(marginMode, 'marginType');
12904
+ if (marginTypeRaw !== undefined) {
12905
+ reMarginMode = (marginTypeRaw === 'crossed') ? 'cross' : 'isolated';
12906
+ }
12937
12907
  return {
12938
12908
  'info': marginMode,
12939
12909
  'symbol': market['symbol'],
12940
- 'marginMode': isIsolated ? 'isolated' : 'cross',
12910
+ 'marginMode': reMarginMode,
12941
12911
  };
12942
12912
  }
12943
12913
  async fetchOption(symbol, params = {}) {