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
@@ -32,7 +32,8 @@ class htx extends htx$1 {
32
32
  'future': true,
33
33
  'option': undefined,
34
34
  'addMargin': undefined,
35
- 'borrowMargin': true,
35
+ 'borrowCrossMargin': true,
36
+ 'borrowIsolatedMargin': true,
36
37
  'cancelAllOrders': true,
37
38
  'cancelOrder': true,
38
39
  'cancelOrders': true,
@@ -112,7 +113,8 @@ class htx extends htx$1 {
112
113
  'fetchWithdrawals': true,
113
114
  'fetchWithdrawalWhitelist': undefined,
114
115
  'reduceMargin': undefined,
115
- 'repayMargin': true,
116
+ 'repayCrossMargin': true,
117
+ 'repayIsolatedMargin': true,
116
118
  'setLeverage': true,
117
119
  'setMarginMode': false,
118
120
  'setPositionMode': false,
@@ -1162,10 +1164,6 @@ class htx extends htx$1 {
1162
1164
  'deposit-earning': 'deposit-earning',
1163
1165
  'otc-options': 'otc-options',
1164
1166
  },
1165
- 'marginAccounts': {
1166
- 'cross': 'super-margin',
1167
- 'isolated': 'margin',
1168
- },
1169
1167
  'typesByAccount': {
1170
1168
  'pro': 'spot',
1171
1169
  'futures': 'future',
@@ -8128,41 +8126,60 @@ class htx extends htx$1 {
8128
8126
  'info': interest,
8129
8127
  }, market);
8130
8128
  }
8131
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
8129
+ async borrowIsolatedMargin(symbol, code, amount, params = {}) {
8132
8130
  /**
8133
8131
  * @method
8134
- * @name huobi#borrowMargin
8132
+ * @name huobi#borrowIsolatedMargin
8135
8133
  * @description create a loan to borrow margin
8136
8134
  * @see https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-isolated
8137
8135
  * @see https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-cross
8136
+ * @param {string} symbol unified market symbol, required for isolated margin
8138
8137
  * @param {string} code unified currency code of the currency to borrow
8139
8138
  * @param {float} amount the amount to borrow
8140
- * @param {string} symbol unified market symbol, required for isolated margin
8141
8139
  * @param {object} [params] extra parameters specific to the huobi api endpoint
8142
8140
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
8143
8141
  */
8144
8142
  await this.loadMarkets();
8145
8143
  const currency = this.currency(code);
8144
+ const market = this.market(symbol);
8146
8145
  const request = {
8147
8146
  'currency': currency['id'],
8148
8147
  'amount': this.currencyToPrecision(code, amount),
8148
+ 'symbol': market['id'],
8149
8149
  };
8150
- let marginMode = undefined;
8151
- [marginMode, params] = this.handleMarginModeAndParams('borrowMargin', params);
8152
- marginMode = (marginMode === undefined) ? 'cross' : marginMode;
8153
- let method = undefined;
8154
- if (marginMode === 'isolated') {
8155
- if (symbol === undefined) {
8156
- throw new errors.ArgumentsRequired(this.id + ' borrowMargin() requires a symbol argument');
8157
- }
8158
- const market = this.market(symbol);
8159
- request['symbol'] = market['id'];
8160
- method = 'privatePostMarginOrders';
8161
- }
8162
- else if (marginMode === 'cross') {
8163
- method = 'privatePostCrossMarginOrders';
8164
- }
8165
- const response = await this[method](this.extend(request, params));
8150
+ const response = await this.privatePostMarginOrders(this.extend(request, params));
8151
+ //
8152
+ // Isolated
8153
+ //
8154
+ // {
8155
+ // "data": 1000
8156
+ // }
8157
+ //
8158
+ const transaction = this.parseMarginLoan(response, currency);
8159
+ return this.extend(transaction, {
8160
+ 'amount': amount,
8161
+ 'symbol': symbol,
8162
+ });
8163
+ }
8164
+ async borrowCrossMargin(code, amount, params = {}) {
8165
+ /**
8166
+ * @method
8167
+ * @name huobi#borrowCrossMargin
8168
+ * @description create a loan to borrow margin
8169
+ * @see https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-isolated
8170
+ * @see https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-cross
8171
+ * @param {string} code unified currency code of the currency to borrow
8172
+ * @param {float} amount the amount to borrow
8173
+ * @param {object} [params] extra parameters specific to the huobi api endpoint
8174
+ * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
8175
+ */
8176
+ await this.loadMarkets();
8177
+ const currency = this.currency(code);
8178
+ const request = {
8179
+ 'currency': currency['id'],
8180
+ 'amount': this.currencyToPrecision(code, amount),
8181
+ };
8182
+ const response = await this.privatePostCrossMarginOrders(this.extend(request, params));
8166
8183
  //
8167
8184
  // Cross
8168
8185
  //
@@ -8171,38 +8188,65 @@ class htx extends htx$1 {
8171
8188
  // "data": null
8172
8189
  // }
8173
8190
  //
8174
- // Isolated
8191
+ const transaction = this.parseMarginLoan(response, currency);
8192
+ return this.extend(transaction, {
8193
+ 'amount': amount,
8194
+ });
8195
+ }
8196
+ async repayIsolatedMargin(symbol, code, amount, params = {}) {
8197
+ /**
8198
+ * @method
8199
+ * @name huobi#repayIsolatedMargin
8200
+ * @description repay borrowed margin and interest
8201
+ * @see https://huobiapi.github.io/docs/spot/v1/en/#repay-margin-loan-cross-isolated
8202
+ * @param {string} code unified currency code of the currency to repay
8203
+ * @param {float} amount the amount to repay
8204
+ * @param {string} symbol unified market symbol
8205
+ * @param {object} [params] extra parameters specific to the huobi api endpoint
8206
+ * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
8207
+ */
8208
+ await this.loadMarkets();
8209
+ const currency = this.currency(code);
8210
+ const accountId = await this.fetchAccountIdByType('spot', 'isolated', symbol, params);
8211
+ const request = {
8212
+ 'currency': currency['id'],
8213
+ 'amount': this.currencyToPrecision(code, amount),
8214
+ 'accountId': accountId,
8215
+ };
8216
+ const response = await this.v2PrivatePostAccountRepayment(this.extend(request, params));
8175
8217
  //
8176
8218
  // {
8177
- // "data": 1000
8219
+ // "code":200,
8220
+ // "data": [
8221
+ // {
8222
+ // "repayId":1174424,
8223
+ // "repayTime":1600747722018
8224
+ // }
8225
+ // ]
8178
8226
  // }
8179
8227
  //
8180
- const transaction = this.parseMarginLoan(response, currency);
8228
+ const data = this.safeValue(response, 'Data', []);
8229
+ const loan = this.safeValue(data, 0);
8230
+ const transaction = this.parseMarginLoan(loan, currency);
8181
8231
  return this.extend(transaction, {
8182
8232
  'amount': amount,
8183
8233
  'symbol': symbol,
8184
8234
  });
8185
8235
  }
8186
- async repayMargin(code, amount, symbol = undefined, params = {}) {
8236
+ async repayCrossMargin(code, amount, params = {}) {
8187
8237
  /**
8188
8238
  * @method
8189
- * @name huobi#repayMargin
8239
+ * @name huobi#repayCrossMargin
8190
8240
  * @description repay borrowed margin and interest
8191
8241
  * @see https://huobiapi.github.io/docs/spot/v1/en/#repay-margin-loan-cross-isolated
8192
8242
  * @param {string} code unified currency code of the currency to repay
8193
8243
  * @param {float} amount the amount to repay
8194
- * @param {string} symbol unified market symbol
8195
8244
  * @param {object} [params] extra parameters specific to the huobi api endpoint
8196
8245
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
8197
8246
  */
8198
8247
  await this.loadMarkets();
8199
8248
  const currency = this.currency(code);
8200
- let marginMode = undefined;
8201
- [marginMode, params] = this.handleMarginModeAndParams('repayMargin', params);
8202
- marginMode = (marginMode === undefined) ? 'cross' : marginMode;
8203
- const marginAccounts = this.safeValue(this.options, 'marginAccounts', {});
8204
- const accountType = this.getSupportedMapping(marginMode, marginAccounts);
8205
- const accountId = await this.fetchAccountIdByType(accountType, marginMode, symbol, params);
8249
+ const accountId = await this.fetchAccountIdByType('spot', 'cross', undefined, params);
8206
8250
  const request = {
8207
8251
  'currency': currency['id'],
8208
8252
  'amount': this.currencyToPrecision(code, amount),
@@ -8225,7 +8269,6 @@ class htx extends htx$1 {
8225
8269
  const transaction = this.parseMarginLoan(loan, currency);
8226
8270
  return this.extend(transaction, {
8227
8271
  'amount': amount,
8228
- 'symbol': symbol,
8229
8272
  });
8230
8273
  }
8231
8274
  parseMarginLoan(info, currency = undefined) {
@@ -8252,7 +8295,7 @@ class htx extends htx$1 {
8252
8295
  //
8253
8296
  const timestamp = this.safeInteger(info, 'repayTime');
8254
8297
  return {
8255
- 'id': this.safeInteger2(info, 'repayId', 'data'),
8298
+ 'id': this.safeString2(info, 'repayId', 'data'),
8256
8299
  'currency': this.safeCurrencyCode(undefined, currency),
8257
8300
  'amount': undefined,
8258
8301
  'symbol': undefined,