ccxt 4.1.58 → 4.1.60

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 (73) hide show
  1. package/README.md +5 -5
  2. package/build.sh +2 -2
  3. package/dist/ccxt.browser.js +1017 -1031
  4. package/dist/ccxt.browser.min.js +2 -2
  5. package/dist/cjs/ccxt.js +1 -19
  6. package/dist/cjs/src/base/Exchange.js +45 -24
  7. package/dist/cjs/src/base/ws/Client.js +1 -1
  8. package/dist/cjs/src/binance.js +71 -22
  9. package/dist/cjs/src/bitget.js +74 -52
  10. package/dist/cjs/src/bitmart.js +10 -18
  11. package/dist/cjs/src/bitrue.js +1 -1
  12. package/dist/cjs/src/bybit.js +36 -33
  13. package/dist/cjs/src/coinbasepro.js +15 -0
  14. package/dist/cjs/src/coinex.js +25 -30
  15. package/dist/cjs/src/htx.js +82 -39
  16. package/dist/cjs/src/kucoin.js +209 -163
  17. package/dist/cjs/src/mexc.js +21 -118
  18. package/dist/cjs/src/okx.js +23 -17
  19. package/dist/cjs/src/pro/bitget.js +7 -0
  20. package/dist/cjs/src/pro/bitmart.js +7 -0
  21. package/dist/cjs/src/pro/bitvavo.js +9 -0
  22. package/dist/cjs/src/pro/bybit.js +9 -0
  23. package/dist/cjs/src/pro/htx.js +86 -61
  24. package/dist/cjs/src/pro/kucoin.js +7 -0
  25. package/dist/cjs/src/pro/mexc.js +9 -0
  26. package/js/ccxt.d.ts +2 -23
  27. package/js/ccxt.js +2 -16
  28. package/js/src/abstract/binance.d.ts +1 -0
  29. package/js/src/abstract/binancecoinm.d.ts +1 -0
  30. package/js/src/abstract/binanceus.d.ts +1 -0
  31. package/js/src/abstract/binanceusdm.d.ts +1 -0
  32. package/js/src/abstract/mexc.d.ts +0 -4
  33. package/js/src/base/Exchange.d.ts +9 -2
  34. package/js/src/base/Exchange.js +45 -24
  35. package/js/src/base/ws/Client.js +1 -1
  36. package/js/src/binance.d.ts +20 -2
  37. package/js/src/binance.js +71 -22
  38. package/js/src/bitget.d.ts +20 -2
  39. package/js/src/bitget.js +74 -52
  40. package/js/src/bitmart.d.ts +2 -2
  41. package/js/src/bitmart.js +10 -18
  42. package/js/src/bitrue.js +1 -1
  43. package/js/src/bybit.d.ts +2 -2
  44. package/js/src/bybit.js +36 -33
  45. package/js/src/coinbasepro.js +15 -0
  46. package/js/src/coinex.d.ts +2 -2
  47. package/js/src/coinex.js +25 -30
  48. package/js/src/htx.d.ts +5 -3
  49. package/js/src/htx.js +82 -39
  50. package/js/src/kucoin.d.ts +20 -2
  51. package/js/src/kucoin.js +209 -163
  52. package/js/src/mexc.d.ts +0 -11
  53. package/js/src/mexc.js +21 -118
  54. package/js/src/okx.d.ts +19 -2
  55. package/js/src/okx.js +23 -17
  56. package/js/src/pro/bitget.js +7 -0
  57. package/js/src/pro/bitmart.js +7 -0
  58. package/js/src/pro/bitvavo.js +9 -0
  59. package/js/src/pro/bybit.js +9 -0
  60. package/js/src/pro/htx.d.ts +2 -2
  61. package/js/src/pro/htx.js +86 -61
  62. package/js/src/pro/kucoin.js +7 -0
  63. package/js/src/pro/mexc.js +9 -0
  64. package/package.json +1 -1
  65. package/skip-tests.json +5 -1
  66. package/js/src/abstract/huobipro.d.ts +0 -547
  67. package/js/src/abstract/huobipro.js +0 -11
  68. package/js/src/abstract/mexc3.d.ts +0 -180
  69. package/js/src/abstract/mexc3.js +0 -11
  70. package/js/src/abstract/okex.d.ts +0 -280
  71. package/js/src/abstract/okex.js +0 -11
  72. package/js/src/abstract/okex5.d.ts +0 -280
  73. package/js/src/abstract/okex5.js +0 -11
@@ -30,7 +30,7 @@ class mexc extends mexc$1 {
30
30
  'future': false,
31
31
  'option': false,
32
32
  'addMargin': true,
33
- 'borrowMargin': true,
33
+ 'borrowMargin': false,
34
34
  'cancelAllOrders': true,
35
35
  'cancelOrder': true,
36
36
  'cancelOrders': undefined,
@@ -102,7 +102,7 @@ class mexc extends mexc$1 {
102
102
  'fetchWithdrawal': undefined,
103
103
  'fetchWithdrawals': true,
104
104
  'reduceMargin': true,
105
- 'repayMargin': true,
105
+ 'repayMargin': false,
106
106
  'setLeverage': true,
107
107
  'setMarginMode': undefined,
108
108
  'setPositionMode': true,
@@ -213,10 +213,6 @@ class mexc extends mexc$1 {
213
213
  'capital/deposit/address': 1,
214
214
  'capital/sub-account/universalTransfer': 1,
215
215
  'capital/convert': 1,
216
- 'margin/tradeMode': 1,
217
- 'margin/order': 1,
218
- 'margin/loan': 1,
219
- 'margin/repay': 1,
220
216
  'mxDeduct/enable': 1,
221
217
  'userDataStream': 1,
222
218
  },
@@ -436,18 +432,18 @@ class mexc extends mexc$1 {
436
432
  'networks': {
437
433
  'BTC': 'BTC',
438
434
  'BCH': 'BCH',
439
- 'TRC20': 'TRC20',
440
- 'ERC20': 'ERC20',
441
- 'BEP20': 'BEP20(BSC)',
442
- 'OPTIMISM': 'OP',
443
- 'SOL': 'SOL',
435
+ 'TRC20': 'Tron(TRC20)',
436
+ 'ERC20': 'Ethereum(ERC20)',
437
+ 'BEP20': 'BNBSmartChain(BEP20)',
438
+ 'OPTIMISM': 'Optimism(OP)',
439
+ 'SOL': 'Solana(SOL)',
444
440
  'CRC20': 'CRONOS',
445
- 'ALGO': 'ALGO',
441
+ 'ALGO': 'Algorand(ALGO)',
446
442
  'XRP': 'XRP',
447
- 'MATIC': 'MATIC',
443
+ 'MATIC': 'Polygon(MATIC)',
448
444
  'AVAXX': 'AVAX_XCHAIN',
449
- 'AVAXC': 'AVAX_CCHAIN',
450
- 'ARBONE': 'Arbitrum One',
445
+ 'AVAXC': 'AvalancheCChain(AVAXCCHAIN)',
446
+ 'ARBONE': 'ArbitrumOne(ARB)',
451
447
  'ARBNOVA': 'ARBNOVA',
452
448
  'FTM': 'FTM',
453
449
  'WAVES': 'WAVES',
@@ -1032,10 +1028,15 @@ class mexc extends mexc$1 {
1032
1028
  networkId = parts.join('');
1033
1029
  networkId = networkId.replace('-20', '20');
1034
1030
  const networksById = {
1035
- 'ETH': 'ETH',
1036
- 'ERC20': 'ERC20',
1037
- 'BEP20(BSC)': 'BEP20',
1038
- 'TRX': 'TRC20',
1031
+ 'Ethereum(ERC20)': 'ERC20',
1032
+ 'Algorand(ALGO)': 'ALGO',
1033
+ 'ArbitrumOne(ARB)': 'ARBONE',
1034
+ 'AvalancheCChain(AVAXCCHAIN)': 'AVAXC',
1035
+ 'BNBSmartChain(BEP20)': 'BEP20',
1036
+ 'Polygon(MATIC)': 'MATIC',
1037
+ 'Optimism(OP)': 'OPTIMISM',
1038
+ 'Solana(SOL)': 'SOL',
1039
+ 'Tron(TRC20)': 'TRC20',
1039
1040
  };
1040
1041
  return this.safeString(networksById, networkId, networkId);
1041
1042
  }
@@ -2130,13 +2131,7 @@ class mexc extends mexc$1 {
2130
2131
  async createSpotOrder(market, type, side, amount, price = undefined, marginMode = undefined, params = {}) {
2131
2132
  await this.loadMarkets();
2132
2133
  const request = this.createSpotOrderRequest(market, type, side, amount, price, marginMode, params);
2133
- let response = undefined;
2134
- if (marginMode !== undefined) {
2135
- response = await this.spotPrivatePostMarginOrder(this.extend(request, params));
2136
- }
2137
- else {
2138
- response = await this.spotPrivatePostOrder(this.extend(request, params));
2139
- }
2134
+ const response = await this.spotPrivatePostOrder(this.extend(request, params));
2140
2135
  //
2141
2136
  // spot
2142
2137
  //
@@ -5022,82 +5017,6 @@ class mexc extends mexc$1 {
5022
5017
  'hedged': (positionMode === 1),
5023
5018
  };
5024
5019
  }
5025
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
5026
- /**
5027
- * @method
5028
- * @name mexc3#borrowMargin
5029
- * @description create a loan to borrow margin
5030
- * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#loan
5031
- * @param {string} code unified currency code of the currency to borrow
5032
- * @param {float} amount the amount to borrow
5033
- * @param {string} symbol unified market symbol
5034
- * @param {object} [params] extra parameters specific to the mexc3 api endpoint
5035
- * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
5036
- */
5037
- if (symbol === undefined) {
5038
- throw new errors.ArgumentsRequired(this.id + ' borrowMargin() requires a symbol argument');
5039
- }
5040
- await this.loadMarkets();
5041
- const market = this.market(symbol);
5042
- const currency = this.currency(code);
5043
- const request = {
5044
- 'asset': currency['id'],
5045
- 'amount': this.currencyToPrecision(code, amount),
5046
- 'symbol': market['id'],
5047
- };
5048
- const response = await this.spotPrivatePostMarginLoan(this.extend(request, params));
5049
- //
5050
- // {
5051
- // "tranId": "762407666453712896"
5052
- // }
5053
- //
5054
- const transaction = this.parseMarginLoan(response, currency);
5055
- return this.extend(transaction, {
5056
- 'amount': amount,
5057
- 'symbol': symbol,
5058
- });
5059
- }
5060
- async repayMargin(code, amount, symbol = undefined, params = {}) {
5061
- /**
5062
- * @method
5063
- * @name mexc3#repayMargin
5064
- * @description repay borrowed margin and interest
5065
- * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#repayment
5066
- * @param {string} code unified currency code of the currency to repay
5067
- * @param {float} amount the amount to repay
5068
- * @param {string} symbol unified market symbol
5069
- * @param {object} [params] extra parameters specific to the mexc3 api endpoint
5070
- * @param {string} [params.borrowId] transaction id '762407666453712896'
5071
- * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
5072
- */
5073
- if (symbol === undefined) {
5074
- throw new errors.ArgumentsRequired(this.id + ' repayMargin() requires a symbol argument');
5075
- }
5076
- await this.loadMarkets();
5077
- const id = this.safeString2(params, 'id', 'borrowId');
5078
- if (id === undefined) {
5079
- throw new errors.ArgumentsRequired(this.id + ' repayMargin() requires a borrowId argument in the params');
5080
- }
5081
- const market = this.market(symbol);
5082
- const currency = this.currency(code);
5083
- const request = {
5084
- 'asset': currency['id'],
5085
- 'amount': this.currencyToPrecision(code, amount),
5086
- 'borrowId': id,
5087
- 'symbol': market['id'],
5088
- };
5089
- const response = await this.spotPrivatePostMarginRepay(this.extend(request, params));
5090
- //
5091
- // {
5092
- // "tranId": "762407666453712896"
5093
- // }
5094
- //
5095
- const transaction = this.parseMarginLoan(response, currency);
5096
- return this.extend(transaction, {
5097
- 'amount': amount,
5098
- 'symbol': symbol,
5099
- });
5100
- }
5101
5020
  async fetchTransactionFees(codes = undefined, params = {}) {
5102
5021
  /**
5103
5022
  * @method
@@ -5285,22 +5204,6 @@ class mexc extends mexc$1 {
5285
5204
  }
5286
5205
  return this.assignDefaultDepositWithdrawFees(result);
5287
5206
  }
5288
- parseMarginLoan(info, currency = undefined) {
5289
- //
5290
- // {
5291
- // "tranId": "762407666453712896"
5292
- // }
5293
- //
5294
- return {
5295
- 'id': this.safeString(info, 'tranId'),
5296
- 'currency': this.safeCurrencyCode(undefined, currency),
5297
- 'amount': undefined,
5298
- 'symbol': undefined,
5299
- 'timestamp': undefined,
5300
- 'datetime': undefined,
5301
- 'info': info,
5302
- };
5303
- }
5304
5207
  handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
5305
5208
  /**
5306
5209
  * @ignore
@@ -94,6 +94,7 @@ class okx extends okx$1 {
94
94
  'fetchPermissions': undefined,
95
95
  'fetchPosition': true,
96
96
  'fetchPositions': true,
97
+ 'fetchPositionsForSymbol': true,
97
98
  'fetchPositionsRisk': false,
98
99
  'fetchPremiumIndexOHLCV': false,
99
100
  'fetchSettlementHistory': true,
@@ -116,7 +117,7 @@ class okx extends okx$1 {
116
117
  'fetchWithdrawals': true,
117
118
  'fetchWithdrawalWhitelist': false,
118
119
  'reduceMargin': true,
119
- 'repayMargin': true,
120
+ 'repayCrossMargin': true,
120
121
  'setLeverage': true,
121
122
  'setMargin': false,
122
123
  'setMarginMode': true,
@@ -5018,7 +5019,7 @@ class okx extends okx$1 {
5018
5019
  if (position === undefined) {
5019
5020
  return undefined;
5020
5021
  }
5021
- return this.parsePosition(position);
5022
+ return this.parsePosition(position, market);
5022
5023
  }
5023
5024
  async fetchPositions(symbols = undefined, params = {}) {
5024
5025
  /**
@@ -5105,6 +5106,19 @@ class okx extends okx$1 {
5105
5106
  }
5106
5107
  return this.filterByArrayPositions(result, 'symbol', symbols, false);
5107
5108
  }
5109
+ async fetchPositionsForSymbol(symbol, params = {}) {
5110
+ /**
5111
+ * @method
5112
+ * @name okx#fetchPositions
5113
+ * @see https://www.okx.com/docs-v5/en/#rest-api-account-get-positions
5114
+ * @description fetch all open positions for specific symbol
5115
+ * @param {string} symbol unified market symbol
5116
+ * @param {object} [params] extra parameters specific to the okx api endpoint
5117
+ * @param {string} [params.instType] MARGIN (if needed)
5118
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
5119
+ */
5120
+ return await this.fetchPositions([symbol], params);
5121
+ }
5108
5122
  parsePosition(position, market = undefined) {
5109
5123
  //
5110
5124
  // {
@@ -6403,15 +6417,14 @@ class okx extends okx$1 {
6403
6417
  'info': info,
6404
6418
  };
6405
6419
  }
6406
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
6420
+ async borrowCrossMargin(code, amount, params = {}) {
6407
6421
  /**
6408
6422
  * @method
6409
- * @name okx#borrowMargin
6410
- * @description create a loan to borrow margin
6423
+ * @name okx#borrowCrossMargin
6424
+ * @description create a loan to borrow margin (need to be VIP 5 and above)
6411
6425
  * @see https://www.okx.com/docs-v5/en/#rest-api-account-vip-loans-borrow-and-repay
6412
6426
  * @param {string} code unified currency code of the currency to borrow
6413
6427
  * @param {float} amount the amount to borrow
6414
- * @param {string} symbol not used by okx.borrowMargin ()
6415
6428
  * @param {object} [params] extra parameters specific to the okx api endpoint
6416
6429
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6417
6430
  */
@@ -6442,20 +6455,16 @@ class okx extends okx$1 {
6442
6455
  //
6443
6456
  const data = this.safeValue(response, 'data', []);
6444
6457
  const loan = this.safeValue(data, 0);
6445
- const transaction = this.parseMarginLoan(loan, currency);
6446
- return this.extend(transaction, {
6447
- 'symbol': symbol,
6448
- });
6458
+ return this.parseMarginLoan(loan, currency);
6449
6459
  }
6450
- async repayMargin(code, amount, symbol = undefined, params = {}) {
6460
+ async repayCrossMargin(code, amount, params = {}) {
6451
6461
  /**
6452
6462
  * @method
6453
- * @name okx#repayMargin
6463
+ * @name okx#repayCrossMargin
6454
6464
  * @description repay borrowed margin and interest
6455
6465
  * @see https://www.okx.com/docs-v5/en/#rest-api-account-vip-loans-borrow-and-repay
6456
6466
  * @param {string} code unified currency code of the currency to repay
6457
6467
  * @param {float} amount the amount to repay
6458
- * @param {string} symbol not used by okx.repayMargin ()
6459
6468
  * @param {object} [params] extra parameters specific to the okx api endpoint
6460
6469
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6461
6470
  */
@@ -6486,10 +6495,7 @@ class okx extends okx$1 {
6486
6495
  //
6487
6496
  const data = this.safeValue(response, 'data', []);
6488
6497
  const loan = this.safeValue(data, 0);
6489
- const transaction = this.parseMarginLoan(loan, currency);
6490
- return this.extend(transaction, {
6491
- 'symbol': symbol,
6492
- });
6498
+ return this.parseMarginLoan(loan, currency);
6493
6499
  }
6494
6500
  parseMarginLoan(info, currency = undefined) {
6495
6501
  //
@@ -18,6 +18,13 @@ class bitget extends bitget$1 {
18
18
  return this.deepExtend(super.describe(), {
19
19
  'has': {
20
20
  'ws': true,
21
+ 'createOrderWs': false,
22
+ 'editOrderWs': false,
23
+ 'fetchOpenOrdersWs': false,
24
+ 'fetchOrderWs': false,
25
+ 'cancelOrderWs': false,
26
+ 'cancelOrdersWs': false,
27
+ 'cancelAllOrdersWs': false,
21
28
  'watchBalance': true,
22
29
  'watchMyTrades': true,
23
30
  'watchOHLCV': true,
@@ -11,6 +11,13 @@ class bitmart extends bitmart$1 {
11
11
  describe() {
12
12
  return this.deepExtend(super.describe(), {
13
13
  'has': {
14
+ 'createOrderWs': false,
15
+ 'editOrderWs': false,
16
+ 'fetchOpenOrdersWs': false,
17
+ 'fetchOrderWs': false,
18
+ 'cancelOrderWs': false,
19
+ 'cancelOrdersWs': false,
20
+ 'cancelAllOrdersWs': false,
14
21
  'ws': true,
15
22
  'watchTicker': true,
16
23
  'watchOrderBook': true,
@@ -12,6 +12,15 @@ class bitvavo extends bitvavo$1 {
12
12
  return this.deepExtend(super.describe(), {
13
13
  'has': {
14
14
  'ws': true,
15
+ 'createOrderWs': false,
16
+ 'editOrderWs': false,
17
+ 'fetchOpenOrdersWs': false,
18
+ 'fetchOrderWs': false,
19
+ 'cancelOrderWs': false,
20
+ 'cancelOrdersWs': false,
21
+ 'cancelAllOrdersWs': false,
22
+ 'fetchTradesWs': false,
23
+ 'fetchBalanceWs': false,
15
24
  'watchOrderBook': true,
16
25
  'watchTrades': true,
17
26
  'watchTicker': true,
@@ -12,6 +12,15 @@ class bybit extends bybit$1 {
12
12
  return this.deepExtend(super.describe(), {
13
13
  'has': {
14
14
  'ws': true,
15
+ 'createOrderWs': false,
16
+ 'editOrderWs': false,
17
+ 'fetchOpenOrdersWs': false,
18
+ 'fetchOrderWs': false,
19
+ 'cancelOrderWs': false,
20
+ 'cancelOrdersWs': false,
21
+ 'cancelAllOrdersWs': false,
22
+ 'fetchTradesWs': false,
23
+ 'fetchBalanceWs': false,
15
24
  'watchBalance': true,
16
25
  'watchMyTrades': true,
17
26
  'watchOHLCV': true,