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
package/js/src/mexc.js CHANGED
@@ -33,7 +33,7 @@ export default class mexc extends Exchange {
33
33
  'future': false,
34
34
  'option': false,
35
35
  'addMargin': true,
36
- 'borrowMargin': true,
36
+ 'borrowMargin': false,
37
37
  'cancelAllOrders': true,
38
38
  'cancelOrder': true,
39
39
  'cancelOrders': undefined,
@@ -105,7 +105,7 @@ export default class mexc extends Exchange {
105
105
  'fetchWithdrawal': undefined,
106
106
  'fetchWithdrawals': true,
107
107
  'reduceMargin': true,
108
- 'repayMargin': true,
108
+ 'repayMargin': false,
109
109
  'setLeverage': true,
110
110
  'setMarginMode': undefined,
111
111
  'setPositionMode': true,
@@ -216,10 +216,6 @@ export default class mexc extends Exchange {
216
216
  'capital/deposit/address': 1,
217
217
  'capital/sub-account/universalTransfer': 1,
218
218
  'capital/convert': 1,
219
- 'margin/tradeMode': 1,
220
- 'margin/order': 1,
221
- 'margin/loan': 1,
222
- 'margin/repay': 1,
223
219
  'mxDeduct/enable': 1,
224
220
  'userDataStream': 1,
225
221
  },
@@ -439,18 +435,18 @@ export default class mexc extends Exchange {
439
435
  'networks': {
440
436
  'BTC': 'BTC',
441
437
  'BCH': 'BCH',
442
- 'TRC20': 'TRC20',
443
- 'ERC20': 'ERC20',
444
- 'BEP20': 'BEP20(BSC)',
445
- 'OPTIMISM': 'OP',
446
- 'SOL': 'SOL',
438
+ 'TRC20': 'Tron(TRC20)',
439
+ 'ERC20': 'Ethereum(ERC20)',
440
+ 'BEP20': 'BNBSmartChain(BEP20)',
441
+ 'OPTIMISM': 'Optimism(OP)',
442
+ 'SOL': 'Solana(SOL)',
447
443
  'CRC20': 'CRONOS',
448
- 'ALGO': 'ALGO',
444
+ 'ALGO': 'Algorand(ALGO)',
449
445
  'XRP': 'XRP',
450
- 'MATIC': 'MATIC',
446
+ 'MATIC': 'Polygon(MATIC)',
451
447
  'AVAXX': 'AVAX_XCHAIN',
452
- 'AVAXC': 'AVAX_CCHAIN',
453
- 'ARBONE': 'Arbitrum One',
448
+ 'AVAXC': 'AvalancheCChain(AVAXCCHAIN)',
449
+ 'ARBONE': 'ArbitrumOne(ARB)',
454
450
  'ARBNOVA': 'ARBNOVA',
455
451
  'FTM': 'FTM',
456
452
  'WAVES': 'WAVES',
@@ -1035,10 +1031,15 @@ export default class mexc extends Exchange {
1035
1031
  networkId = parts.join('');
1036
1032
  networkId = networkId.replace('-20', '20');
1037
1033
  const networksById = {
1038
- 'ETH': 'ETH',
1039
- 'ERC20': 'ERC20',
1040
- 'BEP20(BSC)': 'BEP20',
1041
- 'TRX': 'TRC20',
1034
+ 'Ethereum(ERC20)': 'ERC20',
1035
+ 'Algorand(ALGO)': 'ALGO',
1036
+ 'ArbitrumOne(ARB)': 'ARBONE',
1037
+ 'AvalancheCChain(AVAXCCHAIN)': 'AVAXC',
1038
+ 'BNBSmartChain(BEP20)': 'BEP20',
1039
+ 'Polygon(MATIC)': 'MATIC',
1040
+ 'Optimism(OP)': 'OPTIMISM',
1041
+ 'Solana(SOL)': 'SOL',
1042
+ 'Tron(TRC20)': 'TRC20',
1042
1043
  };
1043
1044
  return this.safeString(networksById, networkId, networkId);
1044
1045
  }
@@ -2133,13 +2134,7 @@ export default class mexc extends Exchange {
2133
2134
  async createSpotOrder(market, type, side, amount, price = undefined, marginMode = undefined, params = {}) {
2134
2135
  await this.loadMarkets();
2135
2136
  const request = this.createSpotOrderRequest(market, type, side, amount, price, marginMode, params);
2136
- let response = undefined;
2137
- if (marginMode !== undefined) {
2138
- response = await this.spotPrivatePostMarginOrder(this.extend(request, params));
2139
- }
2140
- else {
2141
- response = await this.spotPrivatePostOrder(this.extend(request, params));
2142
- }
2137
+ const response = await this.spotPrivatePostOrder(this.extend(request, params));
2143
2138
  //
2144
2139
  // spot
2145
2140
  //
@@ -5026,82 +5021,6 @@ export default class mexc extends Exchange {
5026
5021
  'hedged': (positionMode === 1),
5027
5022
  };
5028
5023
  }
5029
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
5030
- /**
5031
- * @method
5032
- * @name mexc3#borrowMargin
5033
- * @description create a loan to borrow margin
5034
- * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#loan
5035
- * @param {string} code unified currency code of the currency to borrow
5036
- * @param {float} amount the amount to borrow
5037
- * @param {string} symbol unified market symbol
5038
- * @param {object} [params] extra parameters specific to the mexc3 api endpoint
5039
- * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
5040
- */
5041
- if (symbol === undefined) {
5042
- throw new ArgumentsRequired(this.id + ' borrowMargin() requires a symbol argument');
5043
- }
5044
- await this.loadMarkets();
5045
- const market = this.market(symbol);
5046
- const currency = this.currency(code);
5047
- const request = {
5048
- 'asset': currency['id'],
5049
- 'amount': this.currencyToPrecision(code, amount),
5050
- 'symbol': market['id'],
5051
- };
5052
- const response = await this.spotPrivatePostMarginLoan(this.extend(request, params));
5053
- //
5054
- // {
5055
- // "tranId": "762407666453712896"
5056
- // }
5057
- //
5058
- const transaction = this.parseMarginLoan(response, currency);
5059
- return this.extend(transaction, {
5060
- 'amount': amount,
5061
- 'symbol': symbol,
5062
- });
5063
- }
5064
- async repayMargin(code, amount, symbol = undefined, params = {}) {
5065
- /**
5066
- * @method
5067
- * @name mexc3#repayMargin
5068
- * @description repay borrowed margin and interest
5069
- * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#repayment
5070
- * @param {string} code unified currency code of the currency to repay
5071
- * @param {float} amount the amount to repay
5072
- * @param {string} symbol unified market symbol
5073
- * @param {object} [params] extra parameters specific to the mexc3 api endpoint
5074
- * @param {string} [params.borrowId] transaction id '762407666453712896'
5075
- * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
5076
- */
5077
- if (symbol === undefined) {
5078
- throw new ArgumentsRequired(this.id + ' repayMargin() requires a symbol argument');
5079
- }
5080
- await this.loadMarkets();
5081
- const id = this.safeString2(params, 'id', 'borrowId');
5082
- if (id === undefined) {
5083
- throw new ArgumentsRequired(this.id + ' repayMargin() requires a borrowId argument in the params');
5084
- }
5085
- const market = this.market(symbol);
5086
- const currency = this.currency(code);
5087
- const request = {
5088
- 'asset': currency['id'],
5089
- 'amount': this.currencyToPrecision(code, amount),
5090
- 'borrowId': id,
5091
- 'symbol': market['id'],
5092
- };
5093
- const response = await this.spotPrivatePostMarginRepay(this.extend(request, params));
5094
- //
5095
- // {
5096
- // "tranId": "762407666453712896"
5097
- // }
5098
- //
5099
- const transaction = this.parseMarginLoan(response, currency);
5100
- return this.extend(transaction, {
5101
- 'amount': amount,
5102
- 'symbol': symbol,
5103
- });
5104
- }
5105
5024
  async fetchTransactionFees(codes = undefined, params = {}) {
5106
5025
  /**
5107
5026
  * @method
@@ -5289,22 +5208,6 @@ export default class mexc extends Exchange {
5289
5208
  }
5290
5209
  return this.assignDefaultDepositWithdrawFees(result);
5291
5210
  }
5292
- parseMarginLoan(info, currency = undefined) {
5293
- //
5294
- // {
5295
- // "tranId": "762407666453712896"
5296
- // }
5297
- //
5298
- return {
5299
- 'id': this.safeString(info, 'tranId'),
5300
- 'currency': this.safeCurrencyCode(undefined, currency),
5301
- 'amount': undefined,
5302
- 'symbol': undefined,
5303
- 'timestamp': undefined,
5304
- 'datetime': undefined,
5305
- 'info': info,
5306
- };
5307
- }
5308
5211
  handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
5309
5212
  /**
5310
5213
  * @ignore
package/js/src/okx.d.ts CHANGED
@@ -106,6 +106,7 @@ export default class okx extends Exchange {
106
106
  fetchLeverage(symbol: string, params?: {}): Promise<any>;
107
107
  fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
108
108
  fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
109
+ fetchPositionsForSymbol(symbol: string, params?: {}): Promise<import("./base/types.js").Position[]>;
109
110
  parsePosition(position: any, market?: Market): import("./base/types.js").Position;
110
111
  transfer(code: string, amount: any, fromAccount: any, toAccount: any, params?: {}): Promise<{
111
112
  info: any;
@@ -257,8 +258,24 @@ export default class okx extends Exchange {
257
258
  datetime: string;
258
259
  info: any;
259
260
  };
260
- borrowMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<any>;
261
- repayMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<any>;
261
+ borrowCrossMargin(code: string, amount: any, params?: {}): Promise<{
262
+ id: any;
263
+ currency: string;
264
+ amount: number;
265
+ symbol: any;
266
+ timestamp: any;
267
+ datetime: any;
268
+ info: any;
269
+ }>;
270
+ repayCrossMargin(code: string, amount: any, params?: {}): Promise<{
271
+ id: any;
272
+ currency: string;
273
+ amount: number;
274
+ symbol: any;
275
+ timestamp: any;
276
+ datetime: any;
277
+ info: any;
278
+ }>;
262
279
  parseMarginLoan(info: any, currency?: Currency): {
263
280
  id: any;
264
281
  currency: string;
package/js/src/okx.js CHANGED
@@ -97,6 +97,7 @@ export default class okx extends Exchange {
97
97
  'fetchPermissions': undefined,
98
98
  'fetchPosition': true,
99
99
  'fetchPositions': true,
100
+ 'fetchPositionsForSymbol': true,
100
101
  'fetchPositionsRisk': false,
101
102
  'fetchPremiumIndexOHLCV': false,
102
103
  'fetchSettlementHistory': true,
@@ -119,7 +120,7 @@ export default class okx extends Exchange {
119
120
  'fetchWithdrawals': true,
120
121
  'fetchWithdrawalWhitelist': false,
121
122
  'reduceMargin': true,
122
- 'repayMargin': true,
123
+ 'repayCrossMargin': true,
123
124
  'setLeverage': true,
124
125
  'setMargin': false,
125
126
  'setMarginMode': true,
@@ -5021,7 +5022,7 @@ export default class okx extends Exchange {
5021
5022
  if (position === undefined) {
5022
5023
  return undefined;
5023
5024
  }
5024
- return this.parsePosition(position);
5025
+ return this.parsePosition(position, market);
5025
5026
  }
5026
5027
  async fetchPositions(symbols = undefined, params = {}) {
5027
5028
  /**
@@ -5108,6 +5109,19 @@ export default class okx extends Exchange {
5108
5109
  }
5109
5110
  return this.filterByArrayPositions(result, 'symbol', symbols, false);
5110
5111
  }
5112
+ async fetchPositionsForSymbol(symbol, params = {}) {
5113
+ /**
5114
+ * @method
5115
+ * @name okx#fetchPositions
5116
+ * @see https://www.okx.com/docs-v5/en/#rest-api-account-get-positions
5117
+ * @description fetch all open positions for specific symbol
5118
+ * @param {string} symbol unified market symbol
5119
+ * @param {object} [params] extra parameters specific to the okx api endpoint
5120
+ * @param {string} [params.instType] MARGIN (if needed)
5121
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
5122
+ */
5123
+ return await this.fetchPositions([symbol], params);
5124
+ }
5111
5125
  parsePosition(position, market = undefined) {
5112
5126
  //
5113
5127
  // {
@@ -6406,15 +6420,14 @@ export default class okx extends Exchange {
6406
6420
  'info': info,
6407
6421
  };
6408
6422
  }
6409
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
6423
+ async borrowCrossMargin(code, amount, params = {}) {
6410
6424
  /**
6411
6425
  * @method
6412
- * @name okx#borrowMargin
6413
- * @description create a loan to borrow margin
6426
+ * @name okx#borrowCrossMargin
6427
+ * @description create a loan to borrow margin (need to be VIP 5 and above)
6414
6428
  * @see https://www.okx.com/docs-v5/en/#rest-api-account-vip-loans-borrow-and-repay
6415
6429
  * @param {string} code unified currency code of the currency to borrow
6416
6430
  * @param {float} amount the amount to borrow
6417
- * @param {string} symbol not used by okx.borrowMargin ()
6418
6431
  * @param {object} [params] extra parameters specific to the okx api endpoint
6419
6432
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6420
6433
  */
@@ -6445,20 +6458,16 @@ export default class okx extends Exchange {
6445
6458
  //
6446
6459
  const data = this.safeValue(response, 'data', []);
6447
6460
  const loan = this.safeValue(data, 0);
6448
- const transaction = this.parseMarginLoan(loan, currency);
6449
- return this.extend(transaction, {
6450
- 'symbol': symbol,
6451
- });
6461
+ return this.parseMarginLoan(loan, currency);
6452
6462
  }
6453
- async repayMargin(code, amount, symbol = undefined, params = {}) {
6463
+ async repayCrossMargin(code, amount, params = {}) {
6454
6464
  /**
6455
6465
  * @method
6456
- * @name okx#repayMargin
6466
+ * @name okx#repayCrossMargin
6457
6467
  * @description repay borrowed margin and interest
6458
6468
  * @see https://www.okx.com/docs-v5/en/#rest-api-account-vip-loans-borrow-and-repay
6459
6469
  * @param {string} code unified currency code of the currency to repay
6460
6470
  * @param {float} amount the amount to repay
6461
- * @param {string} symbol not used by okx.repayMargin ()
6462
6471
  * @param {object} [params] extra parameters specific to the okx api endpoint
6463
6472
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6464
6473
  */
@@ -6489,10 +6498,7 @@ export default class okx extends Exchange {
6489
6498
  //
6490
6499
  const data = this.safeValue(response, 'data', []);
6491
6500
  const loan = this.safeValue(data, 0);
6492
- const transaction = this.parseMarginLoan(loan, currency);
6493
- return this.extend(transaction, {
6494
- 'symbol': symbol,
6495
- });
6501
+ return this.parseMarginLoan(loan, currency);
6496
6502
  }
6497
6503
  parseMarginLoan(info, currency = undefined) {
6498
6504
  //
@@ -21,6 +21,13 @@ export default class bitget extends bitgetRest {
21
21
  return this.deepExtend(super.describe(), {
22
22
  'has': {
23
23
  'ws': true,
24
+ 'createOrderWs': false,
25
+ 'editOrderWs': false,
26
+ 'fetchOpenOrdersWs': false,
27
+ 'fetchOrderWs': false,
28
+ 'cancelOrderWs': false,
29
+ 'cancelOrdersWs': false,
30
+ 'cancelAllOrdersWs': false,
24
31
  'watchBalance': true,
25
32
  'watchMyTrades': true,
26
33
  'watchOHLCV': true,
@@ -14,6 +14,13 @@ export default class bitmart extends bitmartRest {
14
14
  describe() {
15
15
  return this.deepExtend(super.describe(), {
16
16
  'has': {
17
+ 'createOrderWs': false,
18
+ 'editOrderWs': false,
19
+ 'fetchOpenOrdersWs': false,
20
+ 'fetchOrderWs': false,
21
+ 'cancelOrderWs': false,
22
+ 'cancelOrdersWs': false,
23
+ 'cancelAllOrdersWs': false,
17
24
  'ws': true,
18
25
  'watchTicker': true,
19
26
  'watchOrderBook': true,
@@ -15,6 +15,15 @@ export default class bitvavo extends bitvavoRest {
15
15
  return this.deepExtend(super.describe(), {
16
16
  'has': {
17
17
  'ws': true,
18
+ 'createOrderWs': false,
19
+ 'editOrderWs': false,
20
+ 'fetchOpenOrdersWs': false,
21
+ 'fetchOrderWs': false,
22
+ 'cancelOrderWs': false,
23
+ 'cancelOrdersWs': false,
24
+ 'cancelAllOrdersWs': false,
25
+ 'fetchTradesWs': false,
26
+ 'fetchBalanceWs': false,
18
27
  'watchOrderBook': true,
19
28
  'watchTrades': true,
20
29
  'watchTicker': true,
@@ -15,6 +15,15 @@ export default class bybit extends bybitRest {
15
15
  return this.deepExtend(super.describe(), {
16
16
  'has': {
17
17
  'ws': true,
18
+ 'createOrderWs': false,
19
+ 'editOrderWs': false,
20
+ 'fetchOpenOrdersWs': false,
21
+ 'fetchOrderWs': false,
22
+ 'cancelOrderWs': false,
23
+ 'cancelOrdersWs': false,
24
+ 'cancelAllOrdersWs': false,
25
+ 'fetchTradesWs': false,
26
+ 'fetchBalanceWs': false,
18
27
  'watchBalance': true,
19
28
  'watchMyTrades': true,
20
29
  'watchOHLCV': true,
@@ -15,7 +15,7 @@ export default class htx extends htxRest {
15
15
  watchOrderBookSnapshot(client: any, message: any, subscription: any): Promise<any>;
16
16
  handleDelta(bookside: any, delta: any): void;
17
17
  handleDeltas(bookside: any, deltas: any): void;
18
- handleOrderBookMessage(client: Client, message: any, orderbook: any): any;
18
+ handleOrderBookMessage(client: Client, message: any): void;
19
19
  handleOrderBook(client: Client, message: any): void;
20
20
  handleOrderBookSubscription(client: Client, message: any, subscription: any): void;
21
21
  watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
@@ -38,7 +38,7 @@ export default class htx extends htxRest {
38
38
  handleMessage(client: Client, message: any): void;
39
39
  handleMyTrade(client: Client, message: any, extendParams?: {}): void;
40
40
  parseWsTrade(trade: any, market?: any): import("../base/types.js").Trade;
41
- getUrlByMarketType(type: any, isLinear?: boolean, isPrivate?: boolean): any;
41
+ getUrlByMarketType(type: any, isLinear?: boolean, isPrivate?: boolean, isFeed?: boolean): any;
42
42
  subscribePublic(url: any, symbol: any, messageHash: any, method?: any, params?: {}): Promise<any>;
43
43
  subscribePrivate(channel: any, messageHash: any, type: any, subtype: any, params?: {}, subscriptionParams?: {}): Promise<any>;
44
44
  authenticate(params?: {}): Promise<any>;