ccxt 4.2.43 → 4.2.45

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.
Files changed (46) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1489 -463
  3. package/dist/ccxt.browser.min.js +6 -6
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +54 -0
  6. package/dist/cjs/src/binance.js +627 -51
  7. package/dist/cjs/src/bingx.js +46 -6
  8. package/dist/cjs/src/bitstamp.js +1 -1
  9. package/dist/cjs/src/blofin.js +2 -1
  10. package/dist/cjs/src/bybit.js +96 -43
  11. package/dist/cjs/src/coinbase.js +221 -41
  12. package/dist/cjs/src/deribit.js +1 -1
  13. package/dist/cjs/src/krakenfutures.js +3 -2
  14. package/dist/cjs/src/kucoin.js +9 -5
  15. package/dist/cjs/src/mexc.js +348 -266
  16. package/dist/cjs/src/pro/gate.js +76 -42
  17. package/dist/cjs/src/pro/hitbtc.js +1 -0
  18. package/dist/cjs/src/probit.js +3 -3
  19. package/js/ccxt.d.ts +1 -1
  20. package/js/ccxt.js +1 -1
  21. package/js/src/abstract/coinbase.d.ts +1 -0
  22. package/js/src/base/Exchange.d.ts +4 -0
  23. package/js/src/base/Exchange.js +54 -0
  24. package/js/src/binance.d.ts +1 -0
  25. package/js/src/binance.js +627 -51
  26. package/js/src/bingx.d.ts +2 -1
  27. package/js/src/bingx.js +46 -6
  28. package/js/src/bitstamp.js +1 -1
  29. package/js/src/blofin.js +2 -1
  30. package/js/src/bybit.d.ts +4 -1
  31. package/js/src/bybit.js +96 -43
  32. package/js/src/coinbase.d.ts +10 -4
  33. package/js/src/coinbase.js +221 -41
  34. package/js/src/coinbasepro.d.ts +1 -1
  35. package/js/src/deribit.js +1 -1
  36. package/js/src/krakenfutures.js +3 -2
  37. package/js/src/kucoin.js +9 -5
  38. package/js/src/mexc.d.ts +4 -5
  39. package/js/src/mexc.js +348 -266
  40. package/js/src/pro/gate.d.ts +4 -0
  41. package/js/src/pro/gate.js +76 -42
  42. package/js/src/pro/hitbtc.js +1 -0
  43. package/js/src/probit.js +3 -3
  44. package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
  45. package/package.json +1 -1
  46. package/skip-tests.json +2 -0
@@ -50,6 +50,7 @@ class bingx extends bingx$1 {
50
50
  'fetchClosedOrders': true,
51
51
  'fetchCurrencies': true,
52
52
  'fetchDepositAddress': true,
53
+ 'fetchDepositAddressesByNetwork': true,
53
54
  'fetchDeposits': true,
54
55
  'fetchDepositWithdrawFee': 'emulated',
55
56
  'fetchDepositWithdrawFees': true,
@@ -385,7 +386,9 @@ class bingx extends bingx$1 {
385
386
  },
386
387
  'broad': {},
387
388
  },
388
- 'commonCurrencies': {},
389
+ 'commonCurrencies': {
390
+ 'SNOW': 'Snowman', // Snowman vs SnowSwap conflict
391
+ },
389
392
  'options': {
390
393
  'defaultType': 'spot',
391
394
  'accountsByType': {
@@ -400,6 +403,13 @@ class bingx extends bingx$1 {
400
403
  },
401
404
  'recvWindow': 5 * 1000,
402
405
  'broker': 'CCXT',
406
+ 'defaultNetworks': {
407
+ 'ETH': 'ETH',
408
+ 'USDT': 'ERC20',
409
+ 'USDC': 'ERC20',
410
+ 'BTC': 'BTC',
411
+ 'LTC': 'LTC',
412
+ },
403
413
  },
404
414
  });
405
415
  }
@@ -3083,15 +3093,15 @@ class bingx extends bingx$1 {
3083
3093
  'status': status,
3084
3094
  };
3085
3095
  }
3086
- async fetchDepositAddress(code, params = {}) {
3096
+ async fetchDepositAddressesByNetwork(code, params = {}) {
3087
3097
  /**
3088
3098
  * @method
3089
- * @name bingx#fetchDepositAddress
3090
- * @description fetch the deposit address for a currency associated with this account
3091
- * @see https://bingx-api.github.io/docs/#/common/sub-account#Query%20Main%20Account%20Deposit%20Address
3099
+ * @name bingx#fetchDepositAddressesByNetwork
3100
+ * @description fetch the deposit addresses for a currency associated with this account
3101
+ * @see https://bingx-api.github.io/docs/#/en-us/common/wallet-api.html#Query%20Main%20Account%20Deposit%20Address
3092
3102
  * @param {string} code unified currency code
3093
3103
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3094
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
3104
+ * @returns {object} a dictionary [address structures]{@link https://docs.ccxt.com/#/?id=address-structure}, indexed by the network
3095
3105
  */
3096
3106
  await this.loadMarkets();
3097
3107
  const currency = this.currency(code);
@@ -3126,6 +3136,36 @@ class bingx extends bingx$1 {
3126
3136
  const parsed = this.parseDepositAddresses(data, [currency['code']], false);
3127
3137
  return this.indexBy(parsed, 'network');
3128
3138
  }
3139
+ async fetchDepositAddress(code, params = {}) {
3140
+ /**
3141
+ * @method
3142
+ * @name bingx#fetchDepositAddress
3143
+ * @description fetch the deposit address for a currency associated with this account
3144
+ * @see https://bingx-api.github.io/docs/#/en-us/common/wallet-api.html#Query%20Main%20Account%20Deposit%20Address
3145
+ * @param {string} code unified currency code
3146
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3147
+ * @param {string} [params.network] The chain of currency. This only apply for multi-chain currency, and there is no need for single chain currency
3148
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
3149
+ */
3150
+ const network = this.safeString(params, 'network');
3151
+ params = this.omit(params, ['network']);
3152
+ const addressStructures = await this.fetchDepositAddressesByNetwork(code, params);
3153
+ if (network !== undefined) {
3154
+ return this.safeDict(addressStructures, network);
3155
+ }
3156
+ else {
3157
+ const options = this.safeDict(this.options, 'defaultNetworks');
3158
+ const defaultNetworkForCurrency = this.safeString(options, code);
3159
+ if (defaultNetworkForCurrency !== undefined) {
3160
+ return this.safeDict(addressStructures, defaultNetworkForCurrency);
3161
+ }
3162
+ else {
3163
+ const keys = Object.keys(addressStructures);
3164
+ const key = this.safeString(keys, 0);
3165
+ return this.safeDict(addressStructures, key);
3166
+ }
3167
+ }
3168
+ }
3129
3169
  parseDepositAddress(depositAddress, currency = undefined) {
3130
3170
  //
3131
3171
  // {
@@ -818,7 +818,7 @@ class bitstamp extends bitstamp$1 {
818
818
  for (let i = 0; i < ids.length; i++) {
819
819
  const id = ids[i];
820
820
  if (id.indexOf('_') < 0) {
821
- const value = this.safeNumber(transaction, id);
821
+ const value = this.safeInteger(transaction, id);
822
822
  if ((value !== undefined) && (value !== 0)) {
823
823
  return id;
824
824
  }
@@ -955,7 +955,8 @@ class blofin extends blofin$1 {
955
955
  const request = {};
956
956
  let response = undefined;
957
957
  if (accountType !== undefined) {
958
- const parsedAccountType = this.safeString(this.options, 'accountsByType', accountType);
958
+ const options = this.safeDict(this.options, 'accountsByType', {});
959
+ const parsedAccountType = this.safeString(options, accountType, accountType);
959
960
  request['accountType'] = parsedAccountType;
960
961
  response = await this.privateGetAssetBalances(this.extend(request, params));
961
962
  }
@@ -56,7 +56,9 @@ class bybit extends bybit$1 {
56
56
  'fetchBorrowInterest': false,
57
57
  'fetchBorrowRateHistories': false,
58
58
  'fetchBorrowRateHistory': false,
59
+ 'fetchCanceledAndClosedOrders': true,
59
60
  'fetchCanceledOrders': true,
61
+ 'fetchClosedOrder': true,
60
62
  'fetchClosedOrders': true,
61
63
  'fetchCrossBorrowRate': true,
62
64
  'fetchCrossBorrowRates': false,
@@ -84,10 +86,11 @@ class bybit extends bybit$1 {
84
86
  'fetchOHLCV': true,
85
87
  'fetchOpenInterest': true,
86
88
  'fetchOpenInterestHistory': true,
89
+ 'fetchOpenOrder': true,
87
90
  'fetchOpenOrders': true,
88
- 'fetchOrder': true,
91
+ 'fetchOrder': false,
89
92
  'fetchOrderBook': true,
90
- 'fetchOrders': true,
93
+ 'fetchOrders': false,
91
94
  'fetchOrderTrades': true,
92
95
  'fetchPosition': true,
93
96
  'fetchPositions': true,
@@ -3441,35 +3444,6 @@ class bybit extends bybit$1 {
3441
3444
  'trades': undefined,
3442
3445
  }, market);
3443
3446
  }
3444
- async fetchOrder(id, symbol = undefined, params = {}) {
3445
- /**
3446
- * @method
3447
- * @name bybit#fetchOrder
3448
- * @description fetches information on an order made by the user
3449
- * @see https://bybit-exchange.github.io/docs/v5/order/order-list
3450
- * @param {string} symbol unified symbol of the market the order was made in
3451
- * @param {object} [params] extra parameters specific to the exchange API endpoint
3452
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
3453
- */
3454
- if (symbol === undefined) {
3455
- throw new errors.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
3456
- }
3457
- await this.loadMarkets();
3458
- const request = {
3459
- 'orderId': id,
3460
- };
3461
- const result = await this.fetchOrders(symbol, undefined, undefined, this.extend(request, params));
3462
- const length = result.length;
3463
- if (length === 0) {
3464
- const isTrigger = this.safeBoolN(params, ['trigger', 'stop'], false);
3465
- const extra = isTrigger ? '' : 'If you are trying to fetch SL/TP conditional order, you might try setting params["trigger"] = true';
3466
- throw new errors.OrderNotFound('Order ' + id.toString() + ' was not found.' + extra);
3467
- }
3468
- if (length > 1) {
3469
- throw new errors.InvalidOrder(this.id + ' returned more than one order');
3470
- }
3471
- return this.safeValue(result, 0);
3472
- }
3473
3447
  async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
3474
3448
  /**
3475
3449
  * @method
@@ -4505,29 +4479,99 @@ class bybit extends bybit$1 {
4505
4479
  const data = this.safeValue(result, 'dataList', []);
4506
4480
  return this.parseOrders(data, market, since, limit);
4507
4481
  }
4482
+ async fetchOrder(id, symbol = undefined, params = {}) {
4483
+ throw new errors.NotSupported(this.id + ' fetchOrder() is not supported after the 5/02 update, please use fetchOpenOrder or fetchClosedOrder');
4484
+ }
4508
4485
  async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4486
+ throw new errors.NotSupported(this.id + ' fetchOrders() is not supported after the 5/02 update, please use fetchOpenOrders, fetchClosedOrders or fetchCanceledOrders');
4487
+ }
4488
+ async fetchClosedOrder(id, symbol = undefined, params = {}) {
4489
+ /**
4490
+ * @method
4491
+ * @name bybit#fetchClosedOrder
4492
+ * @description fetches information on a closed order made by the user
4493
+ * @see https://bybit-exchange.github.io/docs/v5/order/order-list
4494
+ * @param {string} id order id
4495
+ * @param {string} [symbol] unified symbol of the market the order was made in
4496
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4497
+ * @param {boolean} [params.stop] set to true for fetching a closed stop order
4498
+ * @param {string} [params.type] market type, ['swap', 'option', 'spot']
4499
+ * @param {string} [params.subType] market subType, ['linear', 'inverse']
4500
+ * @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
4501
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4502
+ */
4503
+ await this.loadMarkets();
4504
+ const request = {
4505
+ 'orderId': id,
4506
+ };
4507
+ const result = await this.fetchClosedOrders(symbol, undefined, undefined, this.extend(request, params));
4508
+ const length = result.length;
4509
+ if (length === 0) {
4510
+ const isTrigger = this.safeBoolN(params, ['trigger', 'stop'], false);
4511
+ const extra = isTrigger ? '' : 'If you are trying to fetch SL/TP conditional order, you might try setting params["trigger"] = true';
4512
+ throw new errors.OrderNotFound('Order ' + id.toString() + ' was not found.' + extra);
4513
+ }
4514
+ if (length > 1) {
4515
+ throw new errors.InvalidOrder(this.id + ' returned more than one order');
4516
+ }
4517
+ return this.safeValue(result, 0);
4518
+ }
4519
+ async fetchOpenOrder(id, symbol = undefined, params = {}) {
4520
+ /**
4521
+ * @method
4522
+ * @name bybit#fetchOpenOrder
4523
+ * @description fetches information on an open order made by the user
4524
+ * @see https://bybit-exchange.github.io/docs/v5/order/open-order
4525
+ * @param {string} id order id
4526
+ * @param {string} [symbol] unified symbol of the market the order was made in
4527
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4528
+ * @param {boolean} [params.stop] set to true for fetching an open stop order
4529
+ * @param {string} [params.type] market type, ['swap', 'option', 'spot']
4530
+ * @param {string} [params.subType] market subType, ['linear', 'inverse']
4531
+ * @param {string} [params.baseCoin] Base coin. Supports linear, inverse & option
4532
+ * @param {string} [params.settleCoin] Settle coin. Supports linear, inverse & option
4533
+ * @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
4534
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4535
+ */
4536
+ await this.loadMarkets();
4537
+ const request = {
4538
+ 'orderId': id,
4539
+ };
4540
+ const result = await this.fetchOpenOrders(symbol, undefined, undefined, this.extend(request, params));
4541
+ const length = result.length;
4542
+ if (length === 0) {
4543
+ const isTrigger = this.safeBoolN(params, ['trigger', 'stop'], false);
4544
+ const extra = isTrigger ? '' : 'If you are trying to fetch SL/TP conditional order, you might try setting params["trigger"] = true';
4545
+ throw new errors.OrderNotFound('Order ' + id.toString() + ' was not found.' + extra);
4546
+ }
4547
+ if (length > 1) {
4548
+ throw new errors.InvalidOrder(this.id + ' returned more than one order');
4549
+ }
4550
+ return this.safeValue(result, 0);
4551
+ }
4552
+ async fetchCanceledAndClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4509
4553
  /**
4510
4554
  * @method
4511
- * @name bybit#fetchOrders
4512
- * @description fetches information on multiple orders made by the user
4555
+ * @name bybit#fetchCanceledAndClosedOrders
4556
+ * @description fetches information on multiple canceled and closed orders made by the user
4513
4557
  * @see https://bybit-exchange.github.io/docs/v5/order/order-list
4514
- * @param {string} symbol unified market symbol of the market orders were made in
4558
+ * @param {string} [symbol] unified market symbol of the market orders were made in
4515
4559
  * @param {int} [since] the earliest time in ms to fetch orders for
4516
4560
  * @param {int} [limit] the maximum number of order structures to retrieve
4517
4561
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4518
- * @param {boolean} [params.stop] true if stop order
4562
+ * @param {boolean} [params.stop] set to true for fetching stop orders
4519
4563
  * @param {string} [params.type] market type, ['swap', 'option', 'spot']
4520
4564
  * @param {string} [params.subType] market subType, ['linear', 'inverse']
4521
4565
  * @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
4522
4566
  * @param {int} [params.until] the latest time in ms to fetch entries for
4523
- * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
4567
+ * @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)
4524
4568
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
4525
4569
  */
4526
4570
  await this.loadMarkets();
4527
4571
  let paginate = false;
4528
- [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
4572
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchCanceledAndClosedOrders', 'paginate');
4529
4573
  if (paginate) {
4530
- return await this.fetchPaginatedCallCursor('fetchOrders', symbol, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
4574
+ return await this.fetchPaginatedCallCursor('fetchCanceledAndClosedOrders', symbol, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
4531
4575
  }
4532
4576
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
4533
4577
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
@@ -4540,7 +4584,7 @@ class bybit extends bybit$1 {
4540
4584
  request['symbol'] = market['id'];
4541
4585
  }
4542
4586
  let type = undefined;
4543
- [type, params] = this.getBybitType('fetchOrders', market, params);
4587
+ [type, params] = this.getBybitType('fetchCanceledAndClosedOrders', market, params);
4544
4588
  if (((type === 'option') || isUsdcSettled) && !isUnifiedAccount) {
4545
4589
  return await this.fetchUsdcOrders(symbol, since, limit, params);
4546
4590
  }
@@ -4622,17 +4666,23 @@ class bybit extends bybit$1 {
4622
4666
  * @name bybit#fetchClosedOrders
4623
4667
  * @description fetches information on multiple closed orders made by the user
4624
4668
  * @see https://bybit-exchange.github.io/docs/v5/order/order-list
4625
- * @param {string} symbol unified market symbol of the market orders were made in
4669
+ * @param {string} [symbol] unified market symbol of the market orders were made in
4626
4670
  * @param {int} [since] the earliest time in ms to fetch orders for
4627
4671
  * @param {int} [limit] the maximum number of order structures to retrieve
4628
4672
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4673
+ * @param {boolean} [params.stop] set to true for fetching closed stop orders
4674
+ * @param {string} [params.type] market type, ['swap', 'option', 'spot']
4675
+ * @param {string} [params.subType] market subType, ['linear', 'inverse']
4676
+ * @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
4677
+ * @param {int} [params.until] the latest time in ms to fetch entries for
4678
+ * @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)
4629
4679
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
4630
4680
  */
4631
4681
  await this.loadMarkets();
4632
4682
  const request = {
4633
4683
  'orderStatus': 'Filled',
4634
4684
  };
4635
- return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
4685
+ return await this.fetchCanceledAndClosedOrders(symbol, since, limit, this.extend(request, params));
4636
4686
  }
4637
4687
  async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4638
4688
  /**
@@ -4640,20 +4690,23 @@ class bybit extends bybit$1 {
4640
4690
  * @name bybit#fetchCanceledOrders
4641
4691
  * @description fetches information on multiple canceled orders made by the user
4642
4692
  * @see https://bybit-exchange.github.io/docs/v5/order/order-list
4643
- * @param {string} symbol unified market symbol of the market orders were made in
4693
+ * @param {string} [symbol] unified market symbol of the market orders were made in
4644
4694
  * @param {int} [since] timestamp in ms of the earliest order, default is undefined
4645
4695
  * @param {int} [limit] max number of orders to return, default is undefined
4646
4696
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4647
4697
  * @param {boolean} [params.stop] true if stop order
4648
4698
  * @param {string} [params.type] market type, ['swap', 'option', 'spot']
4649
4699
  * @param {string} [params.subType] market subType, ['linear', 'inverse']
4700
+ * @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
4701
+ * @param {int} [params.until] the latest time in ms to fetch entries for
4702
+ * @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)
4650
4703
  * @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
4651
4704
  */
4652
4705
  await this.loadMarkets();
4653
4706
  const request = {
4654
4707
  'orderStatus': 'Cancelled',
4655
4708
  };
4656
- return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
4709
+ return await this.fetchCanceledAndClosedOrders(symbol, since, limit, this.extend(request, params));
4657
4710
  }
4658
4711
  async fetchUsdcOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
4659
4712
  await this.loadMarkets();