ccxt 4.1.91 → 4.1.95

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
@@ -168,7 +168,7 @@ var woo$1 = require('./src/pro/woo.js');
168
168
 
169
169
  //-----------------------------------------------------------------------------
170
170
  // this is updated by vss.js when building
171
- const version = '4.1.91';
171
+ const version = '4.1.95';
172
172
  Exchange["default"].ccxtVersion = version;
173
173
  const exchanges = {
174
174
  'ace': ace,
@@ -3137,7 +3137,7 @@ class binance extends binance$1 {
3137
3137
  * @see https://binance-docs.github.io/apidocs/futures/en/#24hr-ticker-price-change-statistics // swap
3138
3138
  * @see https://binance-docs.github.io/apidocs/delivery/en/#24hr-ticker-price-change-statistics // future
3139
3139
  * @see https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics // option
3140
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
3140
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
3141
3141
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3142
3142
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
3143
3143
  */
@@ -3152,22 +3152,24 @@ class binance extends binance$1 {
3152
3152
  [type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
3153
3153
  let subType = undefined;
3154
3154
  [subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params);
3155
- const query = this.omit(params, 'type');
3156
- let defaultMethod = undefined;
3155
+ let response = undefined;
3157
3156
  if (type === 'option') {
3158
- defaultMethod = 'eapiPublicGetTicker';
3157
+ response = await this.eapiPublicGetTicker(params);
3159
3158
  }
3160
3159
  else if (this.isLinear(type, subType)) {
3161
- defaultMethod = 'fapiPublicGetTicker24hr';
3160
+ response = await this.fapiPublicGetTicker24hr(params);
3162
3161
  }
3163
3162
  else if (this.isInverse(type, subType)) {
3164
- defaultMethod = 'dapiPublicGetTicker24hr';
3163
+ response = await this.dapiPublicGetTicker24hr(params);
3165
3164
  }
3166
3165
  else {
3167
- defaultMethod = 'publicGetTicker24hr';
3166
+ const request = {};
3167
+ if (symbols !== undefined) {
3168
+ const marketIds = this.marketIds(symbols);
3169
+ request['symbols'] = this.json(marketIds);
3170
+ }
3171
+ response = await this.publicGetTicker24hr(this.extend(request, params));
3168
3172
  }
3169
- const method = this.safeString(this.options, 'fetchTickersMethod', defaultMethod);
3170
- const response = await this[method](query);
3171
3173
  return this.parseTickers(response, symbols);
3172
3174
  }
3173
3175
  parseOHLCV(ohlcv, market = undefined) {
@@ -890,14 +890,19 @@ class bingx extends bingx$1 {
890
890
  const type = (cost === undefined) ? 'spot' : 'swap';
891
891
  const currencyId = this.safeString2(trade, 'currency', 'N');
892
892
  const currencyCode = this.safeCurrencyCode(currencyId);
893
- const m = this.safeValue(trade, 'm', false);
893
+ const m = this.safeValue(trade, 'm');
894
894
  const marketId = this.safeString(trade, 's');
895
895
  const isBuyerMaker = this.safeValue2(trade, 'buyerMaker', 'isBuyerMaker');
896
- let takeOrMaker = (isBuyerMaker || m) ? 'maker' : 'taker';
896
+ let takeOrMaker = undefined;
897
+ if ((isBuyerMaker !== undefined) || (m !== undefined)) {
898
+ takeOrMaker = (isBuyerMaker || m) ? 'maker' : 'taker';
899
+ }
897
900
  let side = this.safeStringLower2(trade, 'side', 'S');
898
901
  if (side === undefined) {
899
- side = (isBuyerMaker || m) ? 'sell' : 'buy';
900
- takeOrMaker = 'taker';
902
+ if ((isBuyerMaker !== undefined) || (m !== undefined)) {
903
+ side = (isBuyerMaker || m) ? 'sell' : 'buy';
904
+ takeOrMaker = 'taker';
905
+ }
901
906
  }
902
907
  return this.safeTrade({
903
908
  'id': this.safeStringN(trade, ['id', 't']),
@@ -910,7 +915,7 @@ class bingx extends bingx$1 {
910
915
  'side': this.parseOrderSide(side),
911
916
  'takerOrMaker': takeOrMaker,
912
917
  'price': this.safeString2(trade, 'price', 'p'),
913
- 'amount': this.safeStringN(trade, ['qty', 'amount', 'q']),
918
+ 'amount': this.safeStringN(trade, ['qty', 'volume', 'amount', 'q']),
914
919
  'cost': cost,
915
920
  'fee': {
916
921
  'cost': this.parseNumber(Precise["default"].stringAbs(this.safeString2(trade, 'commission', 'n'))),
@@ -1346,7 +1351,7 @@ class bingx extends bingx$1 {
1346
1351
  async fetchBalance(params = {}) {
1347
1352
  /**
1348
1353
  * @method
1349
- * @name cryptocom#fetchBalance
1354
+ * @name bingx#fetchBalance
1350
1355
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
1351
1356
  * @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Query%20Assets
1352
1357
  * @see https://bingx-api.github.io/docs/#/swapV2/account-api.html#Get%20Perpetual%20Swap%20Account%20Asset%20Information
@@ -36,7 +36,7 @@ class bitget extends bitget$1 {
36
36
  'cancelOrder': true,
37
37
  'cancelOrders': true,
38
38
  'closeAllPositions': true,
39
- 'closePosition': false,
39
+ 'closePosition': true,
40
40
  'createMarketBuyOrderWithCost': true,
41
41
  'createMarketOrderWithCost': false,
42
42
  'createMarketSellOrderWithCost': false,
@@ -3567,7 +3567,7 @@ class bitget extends bitget$1 {
3567
3567
  }
3568
3568
  parseOrder(order, market = undefined) {
3569
3569
  //
3570
- // createOrder, editOrder
3570
+ // createOrder, editOrder, closePosition
3571
3571
  //
3572
3572
  // {
3573
3573
  // "clientOid": "abe95dbe-6081-4a6f-a2d3-ae49601cd479",
@@ -3845,8 +3845,13 @@ class bitget extends bitget$1 {
3845
3845
  'status': 'rejected',
3846
3846
  }, market);
3847
3847
  }
3848
+ const isContractOrder = ('posSide' in order);
3849
+ let marketType = isContractOrder ? 'contract' : 'spot';
3850
+ if (market !== undefined) {
3851
+ marketType = market['type'];
3852
+ }
3848
3853
  const marketId = this.safeString(order, 'symbol');
3849
- market = this.safeMarket(marketId, market);
3854
+ market = this.safeMarket(marketId, market, undefined, marketType);
3850
3855
  const timestamp = this.safeInteger2(order, 'cTime', 'ctime');
3851
3856
  const updateTimestamp = this.safeInteger(order, 'uTime');
3852
3857
  const rawStatus = this.safeString2(order, 'status', 'state');
@@ -4996,26 +5001,35 @@ class bitget extends bitget$1 {
4996
5001
  * @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
4997
5002
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
4998
5003
  */
4999
- if (symbol === undefined) {
5000
- throw new errors.ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
5001
- }
5002
5004
  await this.loadMarkets();
5003
5005
  const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
5004
5006
  let market = undefined;
5005
- if (sandboxMode) {
5006
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5007
- market = this.market(sandboxSymbol);
5007
+ let type = undefined;
5008
+ let request = {};
5009
+ let marginMode = undefined;
5010
+ [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
5011
+ if (symbol !== undefined) {
5012
+ if (sandboxMode) {
5013
+ const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5014
+ market = this.market(sandboxSymbol);
5015
+ }
5016
+ else {
5017
+ market = this.market(symbol);
5018
+ }
5019
+ request['symbol'] = market['id'];
5020
+ const defaultType = this.safeString2(this.options, 'fetchOpenOrders', 'defaultType', 'spot');
5021
+ const marketType = ('type' in market) ? market['type'] : defaultType;
5022
+ type = this.safeString(params, 'type', marketType);
5008
5023
  }
5009
5024
  else {
5010
- market = this.market(symbol);
5025
+ const defaultType = this.safeString2(this.options, 'fetchOpenOrders', 'defaultType', 'spot');
5026
+ type = this.safeString(params, 'type', defaultType);
5011
5027
  }
5012
- let marginMode = undefined;
5013
- [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
5014
5028
  let paginate = false;
5015
5029
  [paginate, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'paginate');
5016
5030
  if (paginate) {
5017
5031
  let cursorReceived = undefined;
5018
- if (market['spot']) {
5032
+ if (type === 'spot') {
5019
5033
  if (marginMode !== undefined) {
5020
5034
  cursorReceived = 'minId';
5021
5035
  }
@@ -5025,9 +5039,6 @@ class bitget extends bitget$1 {
5025
5039
  }
5026
5040
  return await this.fetchPaginatedCallCursor('fetchOpenOrders', symbol, since, limit, params, cursorReceived, 'idLessThan');
5027
5041
  }
5028
- let request = {
5029
- 'symbol': market['id'],
5030
- };
5031
5042
  let response = undefined;
5032
5043
  const stop = this.safeValue2(params, 'stop', 'trigger');
5033
5044
  params = this.omit(params, ['stop', 'trigger']);
@@ -5038,46 +5049,48 @@ class bitget extends bitget$1 {
5038
5049
  if (limit !== undefined) {
5039
5050
  request['limit'] = limit;
5040
5051
  }
5041
- if ((market['swap']) || (market['future']) || (marginMode !== undefined)) {
5052
+ if ((type === 'swap') || (type === 'future') || (marginMode !== undefined)) {
5042
5053
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
5043
5054
  params = this.omit(params, 'clientOrderId');
5044
5055
  if (clientOrderId !== undefined) {
5045
5056
  request['clientOid'] = clientOrderId;
5046
5057
  }
5047
5058
  }
5048
- if (market['spot']) {
5059
+ let query = undefined;
5060
+ query = this.omit(params, ['type']);
5061
+ if (type === 'spot') {
5049
5062
  if (marginMode !== undefined) {
5050
5063
  if (since === undefined) {
5051
5064
  since = this.milliseconds() - 7776000000;
5052
5065
  request['startTime'] = since;
5053
5066
  }
5054
5067
  if (marginMode === 'isolated') {
5055
- response = await this.privateMarginGetV2MarginIsolatedOpenOrders(this.extend(request, params));
5068
+ response = await this.privateMarginGetV2MarginIsolatedOpenOrders(this.extend(request, query));
5056
5069
  }
5057
5070
  else if (marginMode === 'cross') {
5058
- response = await this.privateMarginGetV2MarginCrossedOpenOrders(this.extend(request, params));
5071
+ response = await this.privateMarginGetV2MarginCrossedOpenOrders(this.extend(request, query));
5059
5072
  }
5060
5073
  }
5061
5074
  else {
5062
5075
  if (stop) {
5063
- response = await this.privateSpotGetV2SpotTradeCurrentPlanOrder(this.extend(request, params));
5076
+ response = await this.privateSpotGetV2SpotTradeCurrentPlanOrder(this.extend(request, query));
5064
5077
  }
5065
5078
  else {
5066
- response = await this.privateSpotGetV2SpotTradeUnfilledOrders(this.extend(request, params));
5079
+ response = await this.privateSpotGetV2SpotTradeUnfilledOrders(this.extend(request, query));
5067
5080
  }
5068
5081
  }
5069
5082
  }
5070
5083
  else {
5071
5084
  let productType = undefined;
5072
- [productType, params] = this.handleProductTypeAndParams(market, params);
5085
+ [productType, query] = this.handleProductTypeAndParams(market, query);
5073
5086
  request['productType'] = productType;
5074
5087
  if (stop) {
5075
- const planType = this.safeString(params, 'planType', 'normal_plan');
5088
+ const planType = this.safeString(query, 'planType', 'normal_plan');
5076
5089
  request['planType'] = planType;
5077
- response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, params));
5090
+ response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, query));
5078
5091
  }
5079
5092
  else {
5080
- response = await this.privateMixGetV2MixOrderOrdersPending(this.extend(request, params));
5093
+ response = await this.privateMixGetV2MixOrderOrdersPending(this.extend(request, query));
5081
5094
  }
5082
5095
  }
5083
5096
  //
@@ -5256,7 +5269,7 @@ class bitget extends bitget$1 {
5256
5269
  // }
5257
5270
  //
5258
5271
  const data = this.safeValue(response, 'data');
5259
- if (market['spot']) {
5272
+ if (type === 'spot') {
5260
5273
  if ((marginMode !== undefined) || stop) {
5261
5274
  const resultList = this.safeValue(data, 'orderList', []);
5262
5275
  return this.parseOrders(resultList, market, since, limit);
@@ -5286,13 +5299,14 @@ class bitget extends bitget$1 {
5286
5299
  * @param {int} [params.until] the latest time in ms to fetch entries for
5287
5300
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
5288
5301
  * @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
5302
+ * @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
5289
5303
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
5290
5304
  */
5291
- if (symbol === undefined) {
5292
- throw new errors.ArgumentsRequired(this.id + ' fetchClosedOrders() requires a symbol argument');
5293
- }
5294
5305
  await this.loadMarkets();
5295
- const market = this.market(symbol);
5306
+ let market = undefined;
5307
+ if (symbol !== undefined) {
5308
+ market = this.market(symbol);
5309
+ }
5296
5310
  const response = await this.fetchCanceledAndClosedOrders(symbol, since, limit, params);
5297
5311
  const result = [];
5298
5312
  for (let i = 0; i < response.length; i++) {
@@ -5322,13 +5336,14 @@ class bitget extends bitget$1 {
5322
5336
  * @param {int} [params.until] the latest time in ms to fetch entries for
5323
5337
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
5324
5338
  * @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
5339
+ * @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
5325
5340
  * @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
5326
5341
  */
5327
- if (symbol === undefined) {
5328
- throw new errors.ArgumentsRequired(this.id + ' fetchCanceledOrders() requires a symbol argument');
5329
- }
5330
5342
  await this.loadMarkets();
5331
- const market = this.market(symbol);
5343
+ let market = undefined;
5344
+ if (symbol !== undefined) {
5345
+ market = this.market(symbol);
5346
+ }
5332
5347
  const response = await this.fetchCanceledAndClosedOrders(symbol, since, limit, params);
5333
5348
  const result = [];
5334
5349
  for (let i = 0; i < response.length; i++) {
@@ -5345,19 +5360,25 @@ class bitget extends bitget$1 {
5345
5360
  const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
5346
5361
  let market = undefined;
5347
5362
  if (sandboxMode) {
5348
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5349
- market = this.market(sandboxSymbol);
5363
+ if (symbol !== undefined) {
5364
+ const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5365
+ symbol = sandboxSymbol;
5366
+ }
5350
5367
  }
5351
- else {
5368
+ let request = {};
5369
+ if (symbol !== undefined) {
5352
5370
  market = this.market(symbol);
5371
+ request['symbol'] = market['id'];
5353
5372
  }
5373
+ let marketType = undefined;
5374
+ [marketType, params] = this.handleMarketTypeAndParams('fetchCanceledAndClosedOrders', market, params);
5354
5375
  let marginMode = undefined;
5355
5376
  [marginMode, params] = this.handleMarginModeAndParams('fetchCanceledAndClosedOrders', params);
5356
5377
  let paginate = false;
5357
5378
  [paginate, params] = this.handleOptionAndParams(params, 'fetchCanceledAndClosedOrders', 'paginate');
5358
5379
  if (paginate) {
5359
5380
  let cursorReceived = undefined;
5360
- if (market['spot']) {
5381
+ if (marketType === 'spot') {
5361
5382
  if (marginMode !== undefined) {
5362
5383
  cursorReceived = 'minId';
5363
5384
  }
@@ -5367,9 +5388,6 @@ class bitget extends bitget$1 {
5367
5388
  }
5368
5389
  return await this.fetchPaginatedCallCursor('fetchCanceledAndClosedOrders', symbol, since, limit, params, cursorReceived, 'idLessThan');
5369
5390
  }
5370
- let request = {
5371
- 'symbol': market['id'],
5372
- };
5373
5391
  let response = undefined;
5374
5392
  const stop = this.safeValue2(params, 'stop', 'trigger');
5375
5393
  params = this.omit(params, ['stop', 'trigger']);
@@ -5380,7 +5398,7 @@ class bitget extends bitget$1 {
5380
5398
  if (limit !== undefined) {
5381
5399
  request['limit'] = limit;
5382
5400
  }
5383
- if ((market['swap']) || (market['future']) || (marginMode !== undefined)) {
5401
+ if ((marketType === 'swap') || (marketType === 'future') || (marginMode !== undefined)) {
5384
5402
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
5385
5403
  params = this.omit(params, 'clientOrderId');
5386
5404
  if (clientOrderId !== undefined) {
@@ -5388,7 +5406,7 @@ class bitget extends bitget$1 {
5388
5406
  }
5389
5407
  }
5390
5408
  const now = this.milliseconds();
5391
- if (market['spot']) {
5409
+ if (marketType === 'spot') {
5392
5410
  if (marginMode !== undefined) {
5393
5411
  if (since === undefined) {
5394
5412
  since = now - 7776000000;
@@ -5403,6 +5421,9 @@ class bitget extends bitget$1 {
5403
5421
  }
5404
5422
  else {
5405
5423
  if (stop) {
5424
+ if (symbol === undefined) {
5425
+ throw new errors.ArgumentsRequired(this.id + ' fetchCanceledAndClosedOrders() requires a symbol argument');
5426
+ }
5406
5427
  const endTime = this.safeIntegerN(params, ['endTime', 'until', 'till']);
5407
5428
  params = this.omit(params, ['until', 'till']);
5408
5429
  if (since === undefined) {
@@ -5611,7 +5632,7 @@ class bitget extends bitget$1 {
5611
5632
  // }
5612
5633
  //
5613
5634
  const data = this.safeValue(response, 'data', {});
5614
- if (market['spot']) {
5635
+ if (marketType === 'spot') {
5615
5636
  if ((marginMode !== undefined) || stop) {
5616
5637
  return this.safeValue(data, 'orderList', []);
5617
5638
  }
@@ -6299,11 +6320,10 @@ class bitget extends bitget$1 {
6299
6320
  //
6300
6321
  // closeAllPositions
6301
6322
  //
6302
- // {
6303
- // "symbol": "XRPUSDT_UMCBL",
6304
- // "orderId": "1111861847410757635",
6305
- // "clientOid": "1111861847410757637"
6306
- // }
6323
+ // {
6324
+ // "orderId": "1120923953904893955",
6325
+ // "clientOid": "1120923953904893956"
6326
+ // }
6307
6327
  //
6308
6328
  const marketId = this.safeString(position, 'symbol');
6309
6329
  market = this.safeMarket(marketId, market, undefined, 'contract');
@@ -6372,7 +6392,7 @@ class bitget extends bitget$1 {
6372
6392
  const percentage = Precise["default"].stringMul(Precise["default"].stringDiv(unrealizedPnl, initialMargin, 4), '100');
6373
6393
  return this.safePosition({
6374
6394
  'info': position,
6375
- 'id': undefined,
6395
+ 'id': this.safeString(position, 'orderId'),
6376
6396
  'symbol': symbol,
6377
6397
  'notional': this.parseNumber(notional),
6378
6398
  'marginMode': marginMode,
@@ -7992,65 +8012,94 @@ class bitget extends bitget$1 {
7992
8012
  'info': info,
7993
8013
  };
7994
8014
  }
8015
+ async closePosition(symbol, side = undefined, params = {}) {
8016
+ /**
8017
+ * @method
8018
+ * @name bitget#closePosition
8019
+ * @description closes an open position for a market
8020
+ * @see https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
8021
+ * @param {string} symbol unified CCXT market symbol
8022
+ * @param {string} [side] one-way mode: 'buy' or 'sell', hedge-mode: 'long' or 'short'
8023
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
8024
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
8025
+ */
8026
+ await this.loadMarkets();
8027
+ const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
8028
+ let market = undefined;
8029
+ if (sandboxMode) {
8030
+ const sandboxSymbol = this.convertSymbolForSandbox(symbol);
8031
+ market = this.market(sandboxSymbol);
8032
+ }
8033
+ else {
8034
+ market = this.market(symbol);
8035
+ }
8036
+ let productType = undefined;
8037
+ [productType, params] = this.handleProductTypeAndParams(market, params);
8038
+ const request = {
8039
+ 'symbol': market['id'],
8040
+ 'productType': productType,
8041
+ };
8042
+ if (side !== undefined) {
8043
+ request['holdSide'] = side;
8044
+ }
8045
+ const response = await this.privateMixPostV2MixOrderClosePositions(this.extend(request, params));
8046
+ //
8047
+ // {
8048
+ // "code": "00000",
8049
+ // "msg": "success",
8050
+ // "requestTime": 1702975017017,
8051
+ // "data": {
8052
+ // "successList": [
8053
+ // {
8054
+ // "orderId": "1120923953904893955",
8055
+ // "clientOid": "1120923953904893956"
8056
+ // }
8057
+ // ],
8058
+ // "failureList": [],
8059
+ // "result": false
8060
+ // }
8061
+ // }
8062
+ //
8063
+ const data = this.safeValue(response, 'data', {});
8064
+ const order = this.safeValue(data, 'successList', []);
8065
+ return this.parseOrder(order[0], market);
8066
+ }
7995
8067
  async closeAllPositions(params = {}) {
7996
8068
  /**
7997
8069
  * @method
7998
- * @name bitget#closePositions
7999
- * @description closes open positions for a market
8000
- * @see https://bitgetlimited.github.io/apidoc/en/mix/#close-all-position
8001
- * @param {object} [params] extra parameters specific to the okx api endpoint
8002
- * @param {string} [params.subType] 'linear' or 'inverse'
8003
- * @param {string} [params.settle] *required and only valid when params.subType === "linear"* 'USDT' or 'USDC'
8004
- * @returns {object[]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
8070
+ * @name bitget#closeAllPositions
8071
+ * @description closes all open positions for a market type
8072
+ * @see https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
8073
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
8074
+ * @param {string} [params.productType] 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
8075
+ * @returns {object[]} A list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
8005
8076
  */
8006
8077
  await this.loadMarkets();
8007
- let subType = undefined;
8008
- let settle = undefined;
8009
- [subType, params] = this.handleSubTypeAndParams('closeAllPositions', undefined, params);
8010
- settle = this.safeString(params, 'settle', 'USDT');
8011
- params = this.omit(params, ['settle']);
8012
- const productType = this.safeString(params, 'productType');
8013
- const request = {};
8014
- if (productType === undefined) {
8015
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
8016
- let localProductType = undefined;
8017
- if (subType === 'inverse') {
8018
- localProductType = 'dmcbl';
8019
- }
8020
- else {
8021
- if (settle === 'USDT') {
8022
- localProductType = 'umcbl';
8023
- }
8024
- else if (settle === 'USDC') {
8025
- localProductType = 'cmcbl';
8026
- }
8027
- }
8028
- if (sandboxMode) {
8029
- localProductType = 's' + localProductType;
8030
- }
8031
- request['productType'] = localProductType;
8032
- }
8033
- const response = await this.privateMixPostMixV1OrderCloseAllPositions(this.extend(request, params));
8034
- //
8035
- // {
8036
- // "code": "00000",
8037
- // "msg": "success",
8038
- // "requestTime": 1700814442466,
8039
- // "data": {
8040
- // "orderInfo": [
8041
- // {
8042
- // "symbol": "XRPUSDT_UMCBL",
8043
- // "orderId": "1111861847410757635",
8044
- // "clientOid": "1111861847410757637"
8045
- // },
8046
- // ],
8047
- // "failure": [],
8048
- // "result": true
8049
- // }
8050
- // }
8078
+ let productType = undefined;
8079
+ [productType, params] = this.handleProductTypeAndParams(undefined, params);
8080
+ const request = {
8081
+ 'productType': productType,
8082
+ };
8083
+ const response = await this.privateMixPostV2MixOrderClosePositions(this.extend(request, params));
8084
+ //
8085
+ // {
8086
+ // "code": "00000",
8087
+ // "msg": "success",
8088
+ // "requestTime": 1702975017017,
8089
+ // "data": {
8090
+ // "successList": [
8091
+ // {
8092
+ // "orderId": "1120923953904893955",
8093
+ // "clientOid": "1120923953904893956"
8094
+ // }
8095
+ // ],
8096
+ // "failureList": [],
8097
+ // "result": false
8098
+ // }
8099
+ // }
8051
8100
  //
8052
8101
  const data = this.safeValue(response, 'data', {});
8053
- const orderInfo = this.safeValue(data, 'orderInfo', []);
8102
+ const orderInfo = this.safeValue(data, 'successList', []);
8054
8103
  return this.parsePositions(orderInfo, undefined, params);
8055
8104
  }
8056
8105
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
@@ -1541,18 +1541,9 @@ class bitrue extends bitrue$1 {
1541
1541
  const first = this.safeString(symbols, 0);
1542
1542
  const market = this.market(first);
1543
1543
  if (market['swap']) {
1544
- request['contractName'] = market['id'];
1545
- if (market['linear']) {
1546
- response = await this.fapiV1PublicGetTicker(this.extend(request, params));
1547
- }
1548
- else if (market['inverse']) {
1549
- response = await this.dapiV1PublicGetTicker(this.extend(request, params));
1550
- }
1551
- response['symbol'] = market['id'];
1552
- data = [response];
1544
+ throw new errors.NotSupported(this.id + ' fetchTickers does not support swap markets, please use fetchTicker instead');
1553
1545
  }
1554
1546
  else if (market['spot']) {
1555
- request['symbol'] = market['id'];
1556
1547
  response = await this.spotV1PublicGetTicker24hr(this.extend(request, params));
1557
1548
  data = response;
1558
1549
  }
@@ -1563,7 +1554,7 @@ class bitrue extends bitrue$1 {
1563
1554
  else {
1564
1555
  [type, params] = this.handleMarketTypeAndParams('fetchTickers', undefined, params);
1565
1556
  if (type !== 'spot') {
1566
- throw new errors.NotSupported(this.id + ' fetchTickers only support spot when symbols is not set');
1557
+ throw new errors.NotSupported(this.id + ' fetchTickers only support spot when symbols are not proved');
1567
1558
  }
1568
1559
  response = await this.spotV1PublicGetTicker24hr(this.extend(request, params));
1569
1560
  data = response;
@@ -296,6 +296,7 @@ class bybit extends bybit$1 {
296
296
  'v5/account/fee-rate': 10,
297
297
  'v5/account/info': 5,
298
298
  'v5/account/transaction-log': 1,
299
+ 'v5/account/smp-group': 1,
299
300
  'v5/account/mmp-state': 5,
300
301
  // asset
301
302
  'v5/asset/exchange/order-record': 5,