ccxt 4.1.97 → 4.1.98

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
@@ -208,13 +208,13 @@ console.log(version, Object.keys(exchanges));
208
208
 
209
209
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
210
210
 
211
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.97/dist/ccxt.browser.js
212
- * unpkg: https://unpkg.com/ccxt@4.1.97/dist/ccxt.browser.js
211
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.98/dist/ccxt.browser.js
212
+ * unpkg: https://unpkg.com/ccxt@4.1.98/dist/ccxt.browser.js
213
213
 
214
214
  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.
215
215
 
216
216
  ```HTML
217
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.97/dist/ccxt.browser.js"></script>
217
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.98/dist/ccxt.browser.js"></script>
218
218
  ```
219
219
 
220
220
  Creates a global `ccxt` object:
package/build.sh CHANGED
@@ -41,7 +41,7 @@ function run_tests {
41
41
  if [ -z "$ws_pid" ]; then
42
42
  if [ -z "$ws_args" ] || { [ -n "$ws_args" ] && [ "$ws_args" != "skip" ]; }; then
43
43
  # shellcheck disable=SC2086
44
- node run-tests-ws --js --python-async --php-async $ws_args &
44
+ node run-tests --ws --js --python-async --php-async $ws_args &
45
45
  local ws_pid=$!
46
46
  fi
47
47
  fi
@@ -23150,7 +23150,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
23150
23150
  'amount': this.currencyToPrecision(code, amount),
23151
23151
  };
23152
23152
  request['type'] = this.safeString(params, 'type');
23153
- let method = 'sapiPostAssetTransfer';
23153
+ params = this.omit(params, 'type');
23154
+ let response = undefined;
23154
23155
  if (request['type'] === undefined) {
23155
23156
  const symbol = this.safeString(params, 'symbol');
23156
23157
  if (symbol !== undefined) {
@@ -23190,16 +23191,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
23190
23191
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' transfer () does not allow transfers between ' + fromAccount + ' and ' + toAccount);
23191
23192
  }
23192
23193
  else if (toSpot && fromIsolated) {
23193
- method = 'sapiPostMarginIsolatedTransfer';
23194
23194
  request['transFrom'] = 'ISOLATED_MARGIN';
23195
23195
  request['transTo'] = 'SPOT';
23196
23196
  request['symbol'] = fromId;
23197
+ response = await this.sapiPostMarginIsolatedTransfer(this.extend(request, params));
23197
23198
  }
23198
23199
  else if (fromSpot && toIsolated) {
23199
- method = 'sapiPostMarginIsolatedTransfer';
23200
23200
  request['transFrom'] = 'SPOT';
23201
23201
  request['transTo'] = 'ISOLATED_MARGIN';
23202
23202
  request['symbol'] = toId;
23203
+ response = await this.sapiPostMarginIsolatedTransfer(this.extend(request, params));
23203
23204
  }
23204
23205
  else {
23205
23206
  if (fromIsolated) {
@@ -23217,8 +23218,9 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
23217
23218
  request['type'] = fromId + '_' + toId;
23218
23219
  }
23219
23220
  }
23220
- params = this.omit(params, 'type');
23221
- const response = await this[method](this.extend(request, params));
23221
+ if (response === undefined) {
23222
+ response = await this.sapiPostAssetTransfer(this.extend(request, params));
23223
+ }
23222
23224
  //
23223
23225
  // {
23224
23226
  // "tranId":13526853623
@@ -24011,7 +24013,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24011
24013
  */
24012
24014
  await this.loadMarkets();
24013
24015
  const request = {};
24014
- let method = undefined;
24015
24016
  let paginate = false;
24016
24017
  [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
24017
24018
  if (paginate) {
@@ -24028,15 +24029,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24028
24029
  let subType = undefined;
24029
24030
  [subType, params] = this.handleSubTypeAndParams('fetchFundingRateHistory', market, params, 'linear');
24030
24031
  params = this.omit(params, 'type');
24031
- if (this.isLinear(type, subType)) {
24032
- method = 'fapiPublicGetFundingRate';
24033
- }
24034
- else if (this.isInverse(type, subType)) {
24035
- method = 'dapiPublicGetFundingRate';
24036
- }
24037
- if (method === undefined) {
24038
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchFundingRateHistory() is not supported for ' + type + ' markets');
24039
- }
24040
24032
  if (since !== undefined) {
24041
24033
  request['startTime'] = since;
24042
24034
  }
@@ -24049,7 +24041,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24049
24041
  if (limit !== undefined) {
24050
24042
  request['limit'] = limit;
24051
24043
  }
24052
- const response = await this[method](this.extend(request, params));
24044
+ let response = undefined;
24045
+ if (this.isLinear(type, subType)) {
24046
+ response = await this.fapiPublicGetFundingRate(this.extend(request, params));
24047
+ }
24048
+ else if (this.isInverse(type, subType)) {
24049
+ response = await this.dapiPublicGetFundingRate(this.extend(request, params));
24050
+ }
24051
+ else {
24052
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchFundingRateHistory() is not supported for ' + type + ' markets');
24053
+ }
24053
24054
  //
24054
24055
  // {
24055
24056
  // "symbol": "BTCUSDT",
@@ -24085,22 +24086,21 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24085
24086
  */
24086
24087
  await this.loadMarkets();
24087
24088
  symbols = this.marketSymbols(symbols);
24088
- let method = undefined;
24089
24089
  const defaultType = this.safeString2(this.options, 'fetchFundingRates', 'defaultType', 'future');
24090
24090
  const type = this.safeString(params, 'type', defaultType);
24091
24091
  let subType = undefined;
24092
24092
  [subType, params] = this.handleSubTypeAndParams('fetchFundingRates', undefined, params, 'linear');
24093
24093
  const query = this.omit(params, 'type');
24094
+ let response = undefined;
24094
24095
  if (this.isLinear(type, subType)) {
24095
- method = 'fapiPublicGetPremiumIndex';
24096
+ response = await this.fapiPublicGetPremiumIndex(query);
24096
24097
  }
24097
24098
  else if (this.isInverse(type, subType)) {
24098
- method = 'dapiPublicGetPremiumIndex';
24099
+ response = await this.dapiPublicGetPremiumIndex(query);
24099
24100
  }
24100
24101
  else {
24101
24102
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchFundingRates() supports linear and inverse contracts only');
24102
24103
  }
24103
- const response = await this[method](query);
24104
24104
  const result = [];
24105
24105
  for (let i = 0; i < response.length; i++) {
24106
24106
  const entry = response[i];
@@ -24568,22 +24568,21 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24568
24568
  // it contains useful stuff like the maintenance margin and initial margin for positions
24569
24569
  const leverageBrackets = this.safeValue(this.options, 'leverageBrackets');
24570
24570
  if ((leverageBrackets === undefined) || (reload)) {
24571
- let method = undefined;
24572
24571
  const defaultType = this.safeString(this.options, 'defaultType', 'future');
24573
24572
  const type = this.safeString(params, 'type', defaultType);
24574
24573
  const query = this.omit(params, 'type');
24575
24574
  let subType = undefined;
24576
24575
  [subType, params] = this.handleSubTypeAndParams('loadLeverageBrackets', undefined, params, 'linear');
24576
+ let response = undefined;
24577
24577
  if (this.isLinear(type, subType)) {
24578
- method = 'fapiPrivateGetLeverageBracket';
24578
+ response = await this.fapiPrivateGetLeverageBracket(query);
24579
24579
  }
24580
24580
  else if (this.isInverse(type, subType)) {
24581
- method = 'dapiPrivateV2GetLeverageBracket';
24581
+ response = await this.dapiPrivateV2GetLeverageBracket(query);
24582
24582
  }
24583
24583
  else {
24584
24584
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' loadLeverageBrackets() supports linear and inverse contracts only');
24585
24585
  }
24586
- const response = await this[method](query);
24587
24586
  this.options['leverageBrackets'] = {};
24588
24587
  for (let i = 0; i < response.length; i++) {
24589
24588
  const entry = response[i];
@@ -25045,7 +25044,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25045
25044
  */
25046
25045
  await this.loadMarkets();
25047
25046
  let market = undefined;
25048
- let method = undefined;
25049
25047
  const request = {
25050
25048
  'incomeType': 'FUNDING_FEE', // "TRANSFER","WELCOME_BONUS", "REALIZED_PNL","FUNDING_FEE", "COMMISSION" and "INSURANCE_CLEAR"
25051
25049
  };
@@ -25067,16 +25065,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25067
25065
  const defaultType = this.safeString2(this.options, 'fetchFundingHistory', 'defaultType', 'future');
25068
25066
  const type = this.safeString(params, 'type', defaultType);
25069
25067
  params = this.omit(params, 'type');
25068
+ let response = undefined;
25070
25069
  if (this.isLinear(type, subType)) {
25071
- method = 'fapiPrivateGetIncome';
25070
+ response = await this.fapiPrivateGetIncome(this.extend(request, params));
25072
25071
  }
25073
25072
  else if (this.isInverse(type, subType)) {
25074
- method = 'dapiPrivateGetIncome';
25073
+ response = await this.dapiPrivateGetIncome(this.extend(request, params));
25075
25074
  }
25076
25075
  else {
25077
25076
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchFundingHistory() supports linear and inverse contracts only');
25078
25077
  }
25079
- const response = await this[method](this.extend(request, params));
25080
25078
  return this.parseIncomes(response, market, since, limit);
25081
25079
  }
25082
25080
  async setLeverage(leverage, symbol = undefined, params = {}) {
@@ -25830,17 +25828,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25830
25828
  'symbol': market['id'],
25831
25829
  'amount': amount,
25832
25830
  };
25833
- let method = undefined;
25831
+ let response = undefined;
25834
25832
  let code = undefined;
25835
25833
  if (market['linear']) {
25836
- method = 'fapiPrivatePostPositionMargin';
25837
25834
  code = market['quote'];
25835
+ response = await this.fapiPrivatePostPositionMargin(this.extend(request, params));
25838
25836
  }
25839
25837
  else {
25840
- method = 'dapiPrivatePostPositionMargin';
25841
25838
  code = market['base'];
25839
+ response = await this.dapiPrivatePostPositionMargin(this.extend(request, params));
25842
25840
  }
25843
- const response = await this[method](this.extend(request, params));
25844
25841
  //
25845
25842
  // {
25846
25843
  // "code": 200,
@@ -27001,7 +26998,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
27001
26998
  'cancelOrder': true,
27002
26999
  'cancelOrders': true,
27003
27000
  'closeAllPositions': true,
27004
- 'closePosition': false,
27001
+ 'closePosition': true,
27005
27002
  'createMarketBuyOrderWithCost': true,
27006
27003
  'createMarketOrderWithCost': true,
27007
27004
  'createMarketSellOrderWithCost': true,
@@ -30350,12 +30347,44 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
30350
30347
  'datetime': this.iso8601(timestamp),
30351
30348
  });
30352
30349
  }
30350
+ async closePosition(symbol, side = undefined, params = {}) {
30351
+ /**
30352
+ * @method
30353
+ * @name bingx#closePosition
30354
+ * @description closes open positions for a market
30355
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#One-Click%20Close%20All%20Positions
30356
+ * @param {string} symbol Unified CCXT market symbol
30357
+ * @param {string} [side] not used by bingx
30358
+ * @param {object} [params] extra parameters specific to the bingx api endpoint
30359
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
30360
+ */
30361
+ await this.loadMarkets();
30362
+ const market = this.market(symbol);
30363
+ const request = {
30364
+ 'symbol': market['id'],
30365
+ };
30366
+ const response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
30367
+ //
30368
+ // {
30369
+ // "code": 0,
30370
+ // "msg": "",
30371
+ // "data": {
30372
+ // "success": [
30373
+ // 1727686766700486656,
30374
+ // ],
30375
+ // "failed": null
30376
+ // }
30377
+ // }
30378
+ //
30379
+ const data = this.safeValue(response, 'data');
30380
+ return this.parseOrder(data);
30381
+ }
30353
30382
  async closeAllPositions(params = {}) {
30354
30383
  /**
30355
30384
  * @method
30356
30385
  * @name bitget#closePositions
30357
30386
  * @description closes open positions for a market
30358
- * @see https://bitgetlimited.github.io/apidoc/en/mix/#close-all-position
30387
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#One-Click%20Close%20All%20Positions
30359
30388
  * @param {object} [params] extra parameters specific to the okx api endpoint
30360
30389
  * @param {string} [params.recvWindow] request valid time window value
30361
30390
  * @returns {object[]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
@@ -41595,12 +41624,12 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41595
41624
  '30m': '30min',
41596
41625
  '1h': '1h',
41597
41626
  '4h': '4h',
41598
- '6h': '6h',
41599
- '12h': '12h',
41600
- '1d': '1day',
41601
- '3d': '3day',
41602
- '1w': '1week',
41603
- '1M': '1M',
41627
+ '6h': '6Hutc',
41628
+ '12h': '12Hutc',
41629
+ '1d': '1Dutc',
41630
+ '3d': '3Dutc',
41631
+ '1w': '1Wutc',
41632
+ '1M': '1Mutc',
41604
41633
  },
41605
41634
  'swap': {
41606
41635
  '1m': '1m',
@@ -41611,12 +41640,12 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41611
41640
  '1h': '1H',
41612
41641
  '2h': '2H',
41613
41642
  '4h': '4H',
41614
- '6h': '6H',
41615
- '12h': '12H',
41616
- '1d': '1D',
41617
- '3d': '3D',
41618
- '1w': '1W',
41619
- '1M': '1M',
41643
+ '6h': '6Hutc',
41644
+ '12h': '12Hutc',
41645
+ '1d': '1Dutc',
41646
+ '3d': '3Dutc',
41647
+ '1w': '1Wutc',
41648
+ '1M': '1Mutc',
41620
41649
  },
41621
41650
  },
41622
41651
  'fetchMarkets': [
@@ -43218,7 +43247,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
43218
43247
  const currencyCode = this.safeCurrencyCode(this.safeString(feeStructure, 'feeCoin'));
43219
43248
  fee = {
43220
43249
  'currency': currencyCode,
43221
- 'cost': _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringNeg(this.safeString(feeStructure, 'totalFee')),
43250
+ 'cost': _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(this.safeString(feeStructure, 'totalFee')),
43222
43251
  };
43223
43252
  }
43224
43253
  return this.safeTrade({
@@ -199251,7 +199280,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
199251
199280
  * @name phemex#setLeverage
199252
199281
  * @description set the level of leverage for a market
199253
199282
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#set-leverage
199254
- * @param {float} leverage the rate of leverage
199283
+ * @param {float} leverage the rate of leverage, 100 > leverage > -100 excluding numbers between -1 to 1
199255
199284
  * @param {string} symbol unified market symbol
199256
199285
  * @param {object} [params] extra parameters specific to the exchange API endpoint
199257
199286
  * @param {bool} [params.hedged] set to true if hedged position mode is enabled (by default long and short leverage are set to the same value)
@@ -199264,8 +199293,8 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
199264
199293
  if (symbol === undefined) {
199265
199294
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
199266
199295
  }
199267
- if ((leverage < 1) || (leverage > 100)) {
199268
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' setLeverage() leverage should be between 1 and 100');
199296
+ if ((leverage < -100) || (leverage > 100)) {
199297
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' setLeverage() leverage should be between -100 and 100');
199269
199298
  }
199270
199299
  await this.loadMarkets();
199271
199300
  const isHedged = this.safeValue(params, 'hedged', false);
@@ -208620,7 +208649,8 @@ class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
208620
208649
  const data = this.safeValue(message, 'data', []);
208621
208650
  const messageHash = this.safeString(message, 'dataType');
208622
208651
  const marketId = messageHash.split('@')[0];
208623
- const marketType = client.url.indexOf('swap') >= 0 ? 'swap' : 'spot';
208652
+ const isSwap = client.url.indexOf('swap') >= 0;
208653
+ const marketType = isSwap ? 'swap' : 'spot';
208624
208654
  const market = this.safeMarket(marketId, undefined, undefined, marketType);
208625
208655
  const symbol = market['symbol'];
208626
208656
  let trades = undefined;
@@ -208735,7 +208765,8 @@ class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
208735
208765
  const data = this.safeValue(message, 'data', []);
208736
208766
  const messageHash = this.safeString(message, 'dataType');
208737
208767
  const marketId = messageHash.split('@')[0];
208738
- const marketType = client.url.indexOf('swap') >= 0 ? 'swap' : 'spot';
208768
+ const isSwap = client.url.indexOf('swap') >= 0;
208769
+ const marketType = isSwap ? 'swap' : 'spot';
208739
208770
  const market = this.safeMarket(marketId, undefined, undefined, marketType);
208740
208771
  const symbol = market['symbol'];
208741
208772
  let orderbook = this.safeValue(this.orderbooks, symbol);
@@ -208827,7 +208858,8 @@ class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
208827
208858
  const messageHash = this.safeString(message, 'dataType');
208828
208859
  const timeframeId = messageHash.split('_')[1];
208829
208860
  const marketId = messageHash.split('@')[0];
208830
- const marketType = client.url.indexOf('swap') >= 0 ? 'swap' : 'spot';
208861
+ const isSwap = client.url.indexOf('swap') >= 0;
208862
+ const marketType = isSwap ? 'swap' : 'spot';
208831
208863
  const market = this.safeMarket(marketId, undefined, undefined, marketType);
208832
208864
  const symbol = market['symbol'];
208833
208865
  this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
@@ -213463,7 +213495,7 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213463
213495
  const symbolKeys = Object.keys(symbols);
213464
213496
  for (let i = 0; i < symbolKeys.length; i++) {
213465
213497
  const symbol = symbolKeys[i];
213466
- const symbolSpecificMessageHash = messageHash + ':' + symbol;
213498
+ const symbolSpecificMessageHash = messageHash + '::' + symbol;
213467
213499
  client.resolve(newOrders, symbolSpecificMessageHash);
213468
213500
  }
213469
213501
  client.resolve(newOrders, messageHash);
@@ -288604,7 +288636,7 @@ SOFTWARE.
288604
288636
 
288605
288637
  //-----------------------------------------------------------------------------
288606
288638
  // this is updated by vss.js when building
288607
- const version = '4.1.97';
288639
+ const version = '4.1.98';
288608
288640
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
288609
288641
  //-----------------------------------------------------------------------------
288610
288642