ccxt 4.2.53 → 4.2.55

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/README.md CHANGED
@@ -209,13 +209,13 @@ console.log(version, Object.keys(exchanges));
209
209
 
210
210
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
211
211
 
212
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.53/dist/ccxt.browser.js
213
- * unpkg: https://unpkg.com/ccxt@4.2.53/dist/ccxt.browser.js
212
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.55/dist/ccxt.browser.js
213
+ * unpkg: https://unpkg.com/ccxt@4.2.55/dist/ccxt.browser.js
214
214
 
215
215
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
216
216
 
217
217
  ```HTML
218
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.53/dist/ccxt.browser.js"></script>
218
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.55/dist/ccxt.browser.js"></script>
219
219
  ```
220
220
 
221
221
  Creates a global `ccxt` object:
@@ -18179,7 +18179,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18179
18179
  'fetchL3OrderBook': false,
18180
18180
  'fetchLastPrices': true,
18181
18181
  'fetchLedger': true,
18182
- 'fetchLeverage': false,
18182
+ 'fetchLedgerEntry': true,
18183
+ 'fetchLeverage': true,
18183
18184
  'fetchLeverageTiers': true,
18184
18185
  'fetchLiquidations': false,
18185
18186
  'fetchMarketLeverageTiers': 'emulated',
@@ -18379,8 +18380,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18379
18380
  'loan/flexible/borrow/history': 40,
18380
18381
  'loan/flexible/repay/history': 40,
18381
18382
  'loan/flexible/ltv/adjustment/history': 40,
18382
- 'loan/flexible/loanable/data': 40,
18383
- 'loan/flexible/collateral/data': 40,
18384
18383
  'loan/vip/ongoing/orders': 40,
18385
18384
  'loan/vip/repay/history': 40,
18386
18385
  'loan/vip/collateral/account': 600,
@@ -18672,7 +18671,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18672
18671
  'loan/repay': 40.002,
18673
18672
  'loan/adjust/ltv': 40.002,
18674
18673
  'loan/customize/margin_call': 40.002,
18675
- 'loan/flexible/borrow': 40.002,
18676
18674
  'loan/flexible/repay': 40.002,
18677
18675
  'loan/flexible/adjust/ltv': 40.002,
18678
18676
  'loan/vip/repay': 40.002,
@@ -18727,10 +18725,19 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18727
18725
  'sub-account/futures/account': 0.1,
18728
18726
  'sub-account/futures/accountSummary': 1,
18729
18727
  'sub-account/futures/positionRisk': 0.1,
18728
+ 'loan/flexible/ongoing/orders': 30,
18729
+ 'loan/flexible/borrow/history': 40,
18730
+ 'loan/flexible/repay/history': 40,
18731
+ 'loan/flexible/ltv/adjustment/history': 40,
18732
+ 'loan/flexible/loanable/data': 40,
18733
+ 'loan/flexible/collateral/data': 40, // Weight(IP): 400 => cost = 0.1 * 400 = 40
18730
18734
  },
18731
18735
  'post': {
18732
18736
  'eth-staking/eth/stake': 15,
18733
- 'sub-account/subAccountApi/ipRestriction': 20.001, // Weight(UID): 3000 => cost = 0.006667 * 3000 = 20.001
18737
+ 'sub-account/subAccountApi/ipRestriction': 20.001,
18738
+ 'loan/flexible/borrow': 40.002,
18739
+ 'loan/flexible/repay': 40.002,
18740
+ 'loan/flexible/adjust/ltv': 40.002, // Weight(UID): 6000 => cost = 0.006667 * 6000 = 40.002
18734
18741
  },
18735
18742
  },
18736
18743
  'sapiV3': {
@@ -28465,6 +28472,67 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28465
28472
  //
28466
28473
  return response;
28467
28474
  }
28475
+ async fetchLeverage(symbol, params = {}) {
28476
+ /**
28477
+ * @method
28478
+ * @name binance#fetchLeverage
28479
+ * @description fetch the set leverage for a market
28480
+ * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
28481
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
28482
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
28483
+ * @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
28484
+ * @param {string} symbol unified market symbol
28485
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
28486
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
28487
+ */
28488
+ await this.loadMarkets();
28489
+ await this.loadLeverageBrackets(false, params);
28490
+ const market = this.market(symbol);
28491
+ if (!market['contract']) {
28492
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLeverage() supports linear and inverse contracts only');
28493
+ }
28494
+ let type = undefined;
28495
+ [type, params] = this.handleMarketTypeAndParams('fetchLeverage', market, params);
28496
+ let subType = undefined;
28497
+ [subType, params] = this.handleSubTypeAndParams('fetchLeverage', market, params, 'linear');
28498
+ let isPortfolioMargin = undefined;
28499
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverage', 'papi', 'portfolioMargin', false);
28500
+ let response = undefined;
28501
+ if (this.isLinear(type, subType)) {
28502
+ if (isPortfolioMargin) {
28503
+ response = await this.papiGetUmAccount(params);
28504
+ }
28505
+ else {
28506
+ response = await this.fapiPrivateV2GetAccount(params);
28507
+ }
28508
+ }
28509
+ else if (this.isInverse(type, subType)) {
28510
+ if (isPortfolioMargin) {
28511
+ response = await this.papiGetCmAccount(params);
28512
+ }
28513
+ else {
28514
+ response = await this.dapiPrivateGetAccount(params);
28515
+ }
28516
+ }
28517
+ else {
28518
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchPositions() supports linear and inverse contracts only');
28519
+ }
28520
+ const positions = this.safeList(response, 'positions', []);
28521
+ for (let i = 0; i < positions.length; i++) {
28522
+ const position = positions[i];
28523
+ const innerSymbol = this.safeString(position, 'symbol');
28524
+ if (innerSymbol === market['id']) {
28525
+ const isolated = this.safeBool(position, 'isolated');
28526
+ const marginMode = isolated ? 'isolated' : 'cross';
28527
+ return {
28528
+ 'info': position,
28529
+ 'marginMode': marginMode,
28530
+ 'leverage': this.safeInteger(position, 'leverage'),
28531
+ };
28532
+ }
28533
+ }
28534
+ return response;
28535
+ }
28468
28536
  async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
28469
28537
  /**
28470
28538
  * @method
@@ -28647,6 +28715,19 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28647
28715
  }
28648
28716
  return result;
28649
28717
  }
28718
+ async fetchLedgerEntry(id, code = undefined, params = {}) {
28719
+ await this.loadMarkets();
28720
+ let type = undefined;
28721
+ [type, params] = this.handleMarketTypeAndParams('fetchLedgerEntry', undefined, params);
28722
+ const query = {
28723
+ 'recordId': id,
28724
+ 'type': type,
28725
+ };
28726
+ if (type !== 'option') {
28727
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchLedgerEntry () can only be used for type option');
28728
+ }
28729
+ return await this.fetchLedger(code, undefined, undefined, this.extend(query, params));
28730
+ }
28650
28731
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
28651
28732
  /**
28652
28733
  * @method
@@ -82378,6 +82459,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
82378
82459
  'fetchIsolatedBorrowRate': false,
82379
82460
  'fetchIsolatedBorrowRates': false,
82380
82461
  'fetchLedger': true,
82462
+ 'fetchLeverage': true,
82381
82463
  'fetchMarketLeverageTiers': true,
82382
82464
  'fetchMarkets': true,
82383
82465
  'fetchMarkOHLCV': true,
@@ -88644,6 +88726,24 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
88644
88726
  'takeProfitPrice': this.safeNumber2(position, 'take_profit', 'takeProfit'),
88645
88727
  });
88646
88728
  }
88729
+ async fetchLeverage(symbol, params = {}) {
88730
+ /**
88731
+ * @method
88732
+ * @name bybit#fetchLeverage
88733
+ * @description fetch the set leverage for a market
88734
+ * @see https://bybit-exchange.github.io/docs/v5/position
88735
+ * @param {string} symbol unified market symbol
88736
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
88737
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
88738
+ */
88739
+ await this.loadMarkets();
88740
+ const position = await this.fetchPosition(symbol, params);
88741
+ return {
88742
+ 'info': position,
88743
+ 'leverage': this.safeInteger(position, 'leverage'),
88744
+ 'marginMode': this.safeNumber(position, 'marginMode'),
88745
+ };
88746
+ }
88647
88747
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
88648
88748
  /**
88649
88749
  * @method
@@ -132175,7 +132275,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
132175
132275
  'spot': 'https://api.gateio.ws/api/v4',
132176
132276
  'options': 'https://api.gateio.ws/api/v4',
132177
132277
  'subAccounts': 'https://api.gateio.ws/api/v4',
132178
- 'portfolio': 'https://api.gateio.ws/api/v4',
132278
+ 'unified': 'https://api.gateio.ws/api/v4',
132179
132279
  'rebate': 'https://api.gateio.ws/api/v4',
132180
132280
  'earn': 'https://api.gateio.ws/api/v4',
132181
132281
  'account': 'https://api.gateio.ws/api/v4',
@@ -132398,11 +132498,14 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
132398
132498
  'saved_address': 1,
132399
132499
  'fee': 1,
132400
132500
  'total_balance': 2.5,
132501
+ 'small_balance': 1,
132502
+ 'small_balance_history': 1,
132401
132503
  },
132402
132504
  'post': {
132403
132505
  'transfers': 2.5,
132404
132506
  'sub_account_transfers': 2.5,
132405
132507
  'sub_account_to_sub_account': 2.5,
132508
+ 'small_balance': 1,
132406
132509
  },
132407
132510
  },
132408
132511
  'subAccounts': {
@@ -132425,7 +132528,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
132425
132528
  'sub_accounts/{user_id}/keys/{key}': 2.5,
132426
132529
  },
132427
132530
  },
132428
- 'portfolio': {
132531
+ 'unified': {
132429
132532
  'get': {
132430
132533
  'accounts': 20 / 15,
132431
132534
  'account_mode': 20 / 15,
@@ -132434,6 +132537,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
132434
132537
  'loans': 20 / 15,
132435
132538
  'loan_records': 20 / 15,
132436
132539
  'interest_records': 20 / 15,
132540
+ 'estimate_rate': 20 / 15,
132437
132541
  },
132438
132542
  'post': {
132439
132543
  'account_mode': 20 / 15,
@@ -198531,6 +198635,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
198531
198635
  '50027': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.PermissionDenied,
198532
198636
  '50028': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError,
198533
198637
  '50044': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
198638
+ '50062': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError,
198534
198639
  // API Class
198535
198640
  '50100': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError,
198536
198641
  '50101': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.AuthenticationError,
@@ -198585,6 +198690,15 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
198585
198690
  '51072': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
198586
198691
  '51073': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
198587
198692
  '51074': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
198693
+ '51090': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
198694
+ '51091': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
198695
+ '51092': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
198696
+ '51093': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
198697
+ '51094': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
198698
+ '51095': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
198699
+ '51096': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
198700
+ '51098': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
198701
+ '51099': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
198588
198702
  '51100': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
198589
198703
  '51101': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
198590
198704
  '51102': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
@@ -200712,7 +200826,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
200712
200826
  }
200713
200827
  request['tpTriggerPx'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
200714
200828
  const takeProfitLimitPrice = this.safeValueN(takeProfit, ['price', 'takeProfitPrice', 'tpOrdPx']);
200715
- const takeProfitOrderType = this.safeString(takeProfit, 'type');
200829
+ const takeProfitOrderType = this.safeString2(takeProfit, 'type', 'tpOrdKind');
200716
200830
  if (takeProfitOrderType !== undefined) {
200717
200831
  const takeProfitLimitOrderType = (takeProfitOrderType === 'limit');
200718
200832
  const takeProfitMarketOrderType = (takeProfitOrderType === 'market');
@@ -200724,6 +200838,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
200724
200838
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder(this.id + ' createOrder() requires a limit price in params["takeProfit"]["price"] or params["takeProfit"]["tpOrdPx"] for a take profit limit order');
200725
200839
  }
200726
200840
  else {
200841
+ request['tpOrdKind'] = takeProfitOrderType;
200727
200842
  request['tpOrdPx'] = this.priceToPrecision(symbol, takeProfitLimitPrice);
200728
200843
  }
200729
200844
  }
@@ -200732,6 +200847,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
200732
200847
  }
200733
200848
  }
200734
200849
  else if (takeProfitLimitPrice !== undefined) {
200850
+ request['tpOrdKind'] = 'limit';
200735
200851
  request['tpOrdPx'] = this.priceToPrecision(symbol, takeProfitLimitPrice); // limit tp order
200736
200852
  }
200737
200853
  else {
@@ -200756,6 +200872,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
200756
200872
  const twoWayCondition = ((takeProfitPrice !== undefined) && (stopLossPrice !== undefined));
200757
200873
  // if TP and SL are sent together
200758
200874
  // as ordType 'conditional' only stop-loss order will be applied
200875
+ // tpOrdKind is 'condition' which is the default
200759
200876
  if (twoWayCondition) {
200760
200877
  request['ordType'] = 'oco';
200761
200878
  }
@@ -200809,6 +200926,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
200809
200926
  * @param {string} [params.stopLoss.type] 'market' or 'limit' used to specify the stop loss price type
200810
200927
  * @param {string} [params.positionSide] if position mode is one-way: set to 'net', if position mode is hedge-mode: set to 'long' or 'short'
200811
200928
  * @param {string} [params.trailingPercent] the percent to trail away from the current market price
200929
+ * @param {string} [params.tpOrdKind] 'condition' or 'limit', the default is 'condition'
200812
200930
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
200813
200931
  */
200814
200932
  await this.loadMarkets();
@@ -200974,6 +201092,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
200974
201092
  takeProfitTriggerPrice = this.safeValue(takeProfit, 'triggerPrice');
200975
201093
  takeProfitPrice = this.safeValue(takeProfit, 'price');
200976
201094
  const takeProfitType = this.safeString(takeProfit, 'type');
201095
+ request['newTpOrdKind'] = (takeProfitType === 'limit') ? takeProfitType : 'condition';
200977
201096
  request['newTpTriggerPx'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
200978
201097
  request['newTpOrdPx'] = (takeProfitType === 'market') ? '-1' : this.priceToPrecision(symbol, takeProfitPrice);
200979
201098
  request['newTpTriggerPxType'] = takeProfitTriggerPriceType;
@@ -201019,6 +201138,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
201019
201138
  * @param {float} [params.takeProfit.triggerPrice] take profit trigger price
201020
201139
  * @param {float} [params.takeProfit.price] used for take profit limit orders, not used for take profit market price orders
201021
201140
  * @param {string} [params.takeProfit.type] 'market' or 'limit' used to specify the take profit price type
201141
+ * @param {string} [params.newTpOrdKind] 'condition' or 'limit', the default is 'condition'
201022
201142
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
201023
201143
  */
201024
201144
  await this.loadMarkets();
@@ -220006,6 +220126,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
220006
220126
  'future': 'wss://fstream.binance.com/ws',
220007
220127
  'delivery': 'wss://dstream.binance.com/ws',
220008
220128
  'ws': 'wss://ws-api.binance.com:443/ws-api/v3',
220129
+ 'papi': 'wss://fstream.binance.com/pm/ws',
220009
220130
  },
220010
220131
  },
220011
220132
  },
@@ -221181,11 +221302,12 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
221181
221302
  }
221182
221303
  async authenticate(params = {}) {
221183
221304
  const time = this.milliseconds();
221184
- let query = undefined;
221185
221305
  let type = undefined;
221186
- [type, query] = this.handleMarketTypeAndParams('authenticate', undefined, params);
221306
+ [type, params] = this.handleMarketTypeAndParams('authenticate', undefined, params);
221187
221307
  let subType = undefined;
221188
- [subType, query] = this.handleSubTypeAndParams('authenticate', undefined, query);
221308
+ [subType, params] = this.handleSubTypeAndParams('authenticate', undefined, params);
221309
+ let isPortfolioMargin = undefined;
221310
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'authenticate', 'papi', 'portfolioMargin', false);
221189
221311
  if (this.isLinear(type, subType)) {
221190
221312
  type = 'future';
221191
221313
  }
@@ -221193,36 +221315,39 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
221193
221315
  type = 'delivery';
221194
221316
  }
221195
221317
  let marginMode = undefined;
221196
- [marginMode, query] = this.handleMarginModeAndParams('authenticate', query);
221318
+ [marginMode, params] = this.handleMarginModeAndParams('authenticate', params);
221197
221319
  const isIsolatedMargin = (marginMode === 'isolated');
221198
221320
  const isCrossMargin = (marginMode === 'cross') || (marginMode === undefined);
221199
- const symbol = this.safeString(query, 'symbol');
221200
- query = this.omit(query, 'symbol');
221321
+ const symbol = this.safeString(params, 'symbol');
221322
+ params = this.omit(params, 'symbol');
221201
221323
  const options = this.safeValue(this.options, type, {});
221202
221324
  const lastAuthenticatedTime = this.safeInteger(options, 'lastAuthenticatedTime', 0);
221203
221325
  const listenKeyRefreshRate = this.safeInteger(this.options, 'listenKeyRefreshRate', 1200000);
221204
221326
  const delay = this.sum(listenKeyRefreshRate, 10000);
221205
221327
  if (time - lastAuthenticatedTime > delay) {
221206
221328
  let response = undefined;
221207
- if (type === 'future') {
221208
- response = await this.fapiPrivatePostListenKey(query);
221329
+ if (isPortfolioMargin) {
221330
+ response = await this.papiPostListenKey(params);
221331
+ }
221332
+ else if (type === 'future') {
221333
+ response = await this.fapiPrivatePostListenKey(params);
221209
221334
  }
221210
221335
  else if (type === 'delivery') {
221211
- response = await this.dapiPrivatePostListenKey(query);
221336
+ response = await this.dapiPrivatePostListenKey(params);
221212
221337
  }
221213
221338
  else if (type === 'margin' && isCrossMargin) {
221214
- response = await this.sapiPostUserDataStream(query);
221339
+ response = await this.sapiPostUserDataStream(params);
221215
221340
  }
221216
221341
  else if (isIsolatedMargin) {
221217
221342
  if (symbol === undefined) {
221218
221343
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' authenticate() requires a symbol argument for isolated margin mode');
221219
221344
  }
221220
221345
  const marketId = this.marketId(symbol);
221221
- query = this.extend(query, { 'symbol': marketId });
221222
- response = await this.sapiPostUserDataStreamIsolated(query);
221346
+ params = this.extend(params, { 'symbol': marketId });
221347
+ response = await this.sapiPostUserDataStreamIsolated(params);
221223
221348
  }
221224
221349
  else {
221225
- response = await this.publicPostUserDataStream(query);
221350
+ response = await this.publicPostUserDataStream(params);
221226
221351
  }
221227
221352
  this.options[type] = this.extend(options, {
221228
221353
  'listenKey': this.safeString(response, 'listenKey'),
@@ -221235,6 +221360,8 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
221235
221360
  // https://binance-docs.github.io/apidocs/spot/en/#listen-key-spot
221236
221361
  let type = this.safeString2(this.options, 'defaultType', 'authenticate', 'spot');
221237
221362
  type = this.safeString(params, 'type', type);
221363
+ let isPortfolioMargin = undefined;
221364
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'keepAliveListenKey', 'papi', 'portfolioMargin', false);
221238
221365
  const subTypeInfo = this.handleSubTypeAndParams('keepAliveListenKey', undefined, params);
221239
221366
  const subType = subTypeInfo[0];
221240
221367
  if (this.isLinear(type, subType)) {
@@ -221251,28 +221378,35 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
221251
221378
  }
221252
221379
  const request = {};
221253
221380
  const symbol = this.safeString(params, 'symbol');
221254
- const sendParams = this.omit(params, ['type', 'symbol']);
221381
+ params = this.omit(params, ['type', 'symbol']);
221255
221382
  const time = this.milliseconds();
221256
221383
  try {
221257
- if (type === 'future') {
221258
- await this.fapiPrivatePutListenKey(this.extend(request, sendParams));
221384
+ if (isPortfolioMargin) {
221385
+ await this.papiPutListenKey(this.extend(request, params));
221386
+ }
221387
+ else if (type === 'future') {
221388
+ await this.fapiPrivatePutListenKey(this.extend(request, params));
221259
221389
  }
221260
221390
  else if (type === 'delivery') {
221261
- await this.dapiPrivatePutListenKey(this.extend(request, sendParams));
221391
+ await this.dapiPrivatePutListenKey(this.extend(request, params));
221262
221392
  }
221263
221393
  else {
221264
221394
  request['listenKey'] = listenKey;
221265
221395
  if (type === 'margin') {
221266
221396
  request['symbol'] = symbol;
221267
- await this.sapiPutUserDataStream(this.extend(request, sendParams));
221397
+ await this.sapiPutUserDataStream(this.extend(request, params));
221268
221398
  }
221269
221399
  else {
221270
- await this.publicPutUserDataStream(this.extend(request, sendParams));
221400
+ await this.publicPutUserDataStream(this.extend(request, params));
221271
221401
  }
221272
221402
  }
221273
221403
  }
221274
221404
  catch (error) {
221275
- const url = this.urls['api']['ws'][type] + '/' + this.options[type]['listenKey'];
221405
+ let urlType = type;
221406
+ if (isPortfolioMargin) {
221407
+ urlType = 'papi';
221408
+ }
221409
+ const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
221276
221410
  const client = this.client(url);
221277
221411
  const messageHashes = Object.keys(client.futures);
221278
221412
  for (let i = 0; i < messageHashes.length; i++) {
@@ -221304,7 +221438,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
221304
221438
  }
221305
221439
  }
221306
221440
  }
221307
- setBalanceCache(client, type) {
221441
+ setBalanceCache(client, type, isPortfolioMargin = false) {
221308
221442
  if (type in client.subscriptions) {
221309
221443
  return;
221310
221444
  }
@@ -221314,15 +221448,21 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
221314
221448
  const messageHash = type + ':fetchBalanceSnapshot';
221315
221449
  if (!(messageHash in client.futures)) {
221316
221450
  client.future(messageHash);
221317
- this.spawn(this.loadBalanceSnapshot, client, messageHash, type);
221451
+ this.spawn(this.loadBalanceSnapshot, client, messageHash, type, isPortfolioMargin);
221318
221452
  }
221319
221453
  }
221320
221454
  else {
221321
221455
  this.balance[type] = {};
221322
221456
  }
221323
221457
  }
221324
- async loadBalanceSnapshot(client, messageHash, type) {
221325
- const response = await this.fetchBalance({ 'type': type });
221458
+ async loadBalanceSnapshot(client, messageHash, type, isPortfolioMargin) {
221459
+ const params = {
221460
+ 'type': type,
221461
+ };
221462
+ if (isPortfolioMargin) {
221463
+ params['portfolioMargin'] = true;
221464
+ }
221465
+ const response = await this.fetchBalance(params);
221326
221466
  this.balance[type] = this.extend(response, this.safeValue(this.balance, type, {}));
221327
221467
  // don't remove the future from the .futures cache
221328
221468
  const future = client.futures[messageHash];
@@ -221416,6 +221556,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
221416
221556
  * @name binance#watchBalance
221417
221557
  * @description watch balance and get the amount of funds available for trading or funds locked in orders
221418
221558
  * @param {object} [params] extra parameters specific to the exchange API endpoint
221559
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to watch the balance of a portfolio margin account
221419
221560
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
221420
221561
  */
221421
221562
  await this.loadMarkets();
@@ -221424,16 +221565,22 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
221424
221565
  let type = this.safeString(params, 'type', defaultType);
221425
221566
  let subType = undefined;
221426
221567
  [subType, params] = this.handleSubTypeAndParams('watchBalance', undefined, params);
221568
+ let isPortfolioMargin = undefined;
221569
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchBalance', 'papi', 'portfolioMargin', false);
221570
+ let urlType = type;
221571
+ if (isPortfolioMargin) {
221572
+ urlType = 'papi';
221573
+ }
221427
221574
  if (this.isLinear(type, subType)) {
221428
221575
  type = 'future';
221429
221576
  }
221430
221577
  else if (this.isInverse(type, subType)) {
221431
221578
  type = 'delivery';
221432
221579
  }
221433
- const url = this.urls['api']['ws'][type] + '/' + this.options[type]['listenKey'];
221580
+ const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
221434
221581
  const client = this.client(url);
221435
- this.setBalanceCache(client, type);
221436
- this.setPositionsCache(client, type);
221582
+ this.setBalanceCache(client, type, isPortfolioMargin);
221583
+ this.setPositionsCache(client, type, undefined, isPortfolioMargin);
221437
221584
  const options = this.safeValue(this.options, 'watchBalance');
221438
221585
  const fetchBalanceSnapshot = this.safeBool(options, 'fetchBalanceSnapshot', false);
221439
221586
  const awaitBalanceSnapshot = this.safeBool(options, 'awaitBalanceSnapshot', true);
@@ -222040,11 +222187,14 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
222040
222187
  * @name binance#watchOrders
222041
222188
  * @description watches information on multiple orders made by the user
222042
222189
  * @see https://binance-docs.github.io/apidocs/spot/en/#payload-order-update
222190
+ * @see https://binance-docs.github.io/apidocs/pm/en/#event-futures-order-update
222191
+ * @see https://binance-docs.github.io/apidocs/pm/en/#event-margin-order-update
222043
222192
  * @param {string} symbol unified market symbol of the market the orders were made in
222044
222193
  * @param {int} [since] the earliest time in ms to fetch orders for
222045
222194
  * @param {int} [limit] the maximum number of order structures to retrieve
222046
222195
  * @param {object} [params] extra parameters specific to the exchange API endpoint
222047
222196
  * @param {string|undefined} [params.marginMode] 'cross' or 'isolated', for spot margin
222197
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to watch portfolio margin account orders
222048
222198
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
222049
222199
  */
222050
222200
  await this.loadMarkets();
@@ -222073,10 +222223,15 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
222073
222223
  if ((type === 'margin') || ((type === 'spot') && (marginMode !== undefined))) {
222074
222224
  urlType = 'spot'; // spot-margin shares the same stream as regular spot
222075
222225
  }
222226
+ let isPortfolioMargin = undefined;
222227
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchOrders', 'papi', 'portfolioMargin', false);
222228
+ if (isPortfolioMargin) {
222229
+ urlType = 'papi';
222230
+ }
222076
222231
  const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
222077
222232
  const client = this.client(url);
222078
- this.setBalanceCache(client, type);
222079
- this.setPositionsCache(client, type);
222233
+ this.setBalanceCache(client, type, isPortfolioMargin);
222234
+ this.setPositionsCache(client, type, undefined, isPortfolioMargin);
222080
222235
  const message = undefined;
222081
222236
  const orders = await this.watch(url, messageHash, message, type);
222082
222237
  if (this.newUpdates) {
@@ -222331,6 +222486,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
222331
222486
  * @description watch all open positions
222332
222487
  * @param {string[]|undefined} symbols list of unified market symbols
222333
222488
  * @param {object} params extra parameters specific to the exchange API endpoint
222489
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to watch positions in a portfolio margin account
222334
222490
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
222335
222491
  */
222336
222492
  await this.loadMarkets();
@@ -222361,10 +222517,16 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
222361
222517
  type = 'delivery';
222362
222518
  }
222363
222519
  messageHash = type + ':positions' + messageHash;
222364
- const url = this.urls['api']['ws'][type] + '/' + this.options[type]['listenKey'];
222520
+ let isPortfolioMargin = undefined;
222521
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchPositions', 'papi', 'portfolioMargin', false);
222522
+ let urlType = type;
222523
+ if (isPortfolioMargin) {
222524
+ urlType = 'papi';
222525
+ }
222526
+ const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
222365
222527
  const client = this.client(url);
222366
- this.setBalanceCache(client, type);
222367
- this.setPositionsCache(client, type, symbols);
222528
+ this.setBalanceCache(client, type, isPortfolioMargin);
222529
+ this.setPositionsCache(client, type, symbols, isPortfolioMargin);
222368
222530
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
222369
222531
  const awaitPositionsSnapshot = this.safeValue('watchPositions', 'awaitPositionsSnapshot', true);
222370
222532
  const cache = this.safeValue(this.positions, type);
@@ -222378,7 +222540,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
222378
222540
  }
222379
222541
  return this.filterBySymbolsSinceLimit(cache, symbols, since, limit, true);
222380
222542
  }
222381
- setPositionsCache(client, type, symbols = undefined) {
222543
+ setPositionsCache(client, type, symbols = undefined, isPortfolioMargin = false) {
222382
222544
  if (type === 'spot') {
222383
222545
  return;
222384
222546
  }
@@ -222393,15 +222555,21 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
222393
222555
  const messageHash = type + ':fetchPositionsSnapshot';
222394
222556
  if (!(messageHash in client.futures)) {
222395
222557
  client.future(messageHash);
222396
- this.spawn(this.loadPositionsSnapshot, client, messageHash, type);
222558
+ this.spawn(this.loadPositionsSnapshot, client, messageHash, type, isPortfolioMargin);
222397
222559
  }
222398
222560
  }
222399
222561
  else {
222400
222562
  this.positions[type] = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCacheBySymbolBySide */ .tU();
222401
222563
  }
222402
222564
  }
222403
- async loadPositionsSnapshot(client, messageHash, type) {
222404
- const positions = await this.fetchPositions(undefined, { 'type': type });
222565
+ async loadPositionsSnapshot(client, messageHash, type, isPortfolioMargin) {
222566
+ const params = {
222567
+ 'type': type,
222568
+ };
222569
+ if (isPortfolioMargin) {
222570
+ params['portfolioMargin'] = true;
222571
+ }
222572
+ const positions = await this.fetchPositions(undefined, params);
222405
222573
  this.positions[type] = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCacheBySymbolBySide */ .tU();
222406
222574
  const cache = this.positions[type];
222407
222575
  for (let i = 0; i < positions.length; i++) {
@@ -222674,6 +222842,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
222674
222842
  * @param {int} [since] the earliest time in ms to fetch orders for
222675
222843
  * @param {int} [limit] the maximum number of order structures to retrieve
222676
222844
  * @param {object} [params] extra parameters specific to the exchange API endpoint
222845
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to watch trades in a portfolio margin account
222677
222846
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
222678
222847
  */
222679
222848
  await this.loadMarkets();
@@ -222703,10 +222872,15 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
222703
222872
  if (type === 'margin') {
222704
222873
  urlType = 'spot'; // spot-margin shares the same stream as regular spot
222705
222874
  }
222875
+ let isPortfolioMargin = undefined;
222876
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchMyTrades', 'papi', 'portfolioMargin', false);
222877
+ if (isPortfolioMargin) {
222878
+ urlType = 'papi';
222879
+ }
222706
222880
  const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
222707
222881
  const client = this.client(url);
222708
- this.setBalanceCache(client, type);
222709
- this.setPositionsCache(client, type);
222882
+ this.setBalanceCache(client, type, isPortfolioMargin);
222883
+ this.setPositionsCache(client, type, undefined, isPortfolioMargin);
222710
222884
  const message = undefined;
222711
222885
  const trades = await this.watch(url, messageHash, message, type);
222712
222886
  if (this.newUpdates) {
@@ -293003,6 +293177,7 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
293003
293177
  'account': 'spot',
293004
293178
  },
293005
293179
  'accountsByType': {
293180
+ 'funding': 'main',
293006
293181
  'main': 'main',
293007
293182
  'spot': 'spot',
293008
293183
  'margin': 'collateral',
@@ -294096,9 +294271,9 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
294096
294271
  else {
294097
294272
  const options = this.safeValue(this.options, 'fetchBalance', {});
294098
294273
  const defaultAccount = this.safeString(options, 'account');
294099
- const account = this.safeString(params, 'account', defaultAccount);
294100
- params = this.omit(params, 'account');
294101
- if (account === 'main') {
294274
+ const account = this.safeString2(params, 'account', 'type', defaultAccount);
294275
+ params = this.omit(params, ['account', 'type']);
294276
+ if (account === 'main' || account === 'funding') {
294102
294277
  response = await this.v4PrivatePostMainAccountBalance(params);
294103
294278
  }
294104
294279
  else {
@@ -307460,7 +307635,7 @@ SOFTWARE.
307460
307635
 
307461
307636
  //-----------------------------------------------------------------------------
307462
307637
  // this is updated by vss.js when building
307463
- const version = '4.2.53';
307638
+ const version = '4.2.55';
307464
307639
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
307465
307640
  //-----------------------------------------------------------------------------
307466
307641