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/dist/cjs/ccxt.js CHANGED
@@ -76,7 +76,6 @@ var hollaex = require('./src/hollaex.js');
76
76
  var htx = require('./src/htx.js');
77
77
  var huobi = require('./src/huobi.js');
78
78
  var huobijp = require('./src/huobijp.js');
79
- var huobipro = require('./src/huobipro.js');
80
79
  var idex = require('./src/idex.js');
81
80
  var independentreserve = require('./src/independentreserve.js');
82
81
  var indodax = require('./src/indodax.js');
@@ -91,13 +90,10 @@ var luno = require('./src/luno.js');
91
90
  var lykke = require('./src/lykke.js');
92
91
  var mercado = require('./src/mercado.js');
93
92
  var mexc = require('./src/mexc.js');
94
- var mexc3 = require('./src/mexc3.js');
95
93
  var ndax = require('./src/ndax.js');
96
94
  var novadax = require('./src/novadax.js');
97
95
  var oceanex = require('./src/oceanex.js');
98
96
  var okcoin = require('./src/okcoin.js');
99
- var okex = require('./src/okex.js');
100
- var okex5 = require('./src/okex5.js');
101
97
  var okx = require('./src/okx.js');
102
98
  var p2b = require('./src/p2b.js');
103
99
  var paymium = require('./src/paymium.js');
@@ -155,7 +151,6 @@ var hollaex$1 = require('./src/pro/hollaex.js');
155
151
  var htx$1 = require('./src/pro/htx.js');
156
152
  var huobi$1 = require('./src/pro/huobi.js');
157
153
  var huobijp$1 = require('./src/pro/huobijp.js');
158
- var huobipro$1 = require('./src/pro/huobipro.js');
159
154
  var idex$1 = require('./src/pro/idex.js');
160
155
  var independentreserve$1 = require('./src/pro/independentreserve.js');
161
156
  var kraken$1 = require('./src/pro/kraken.js');
@@ -164,10 +159,8 @@ var kucoin$1 = require('./src/pro/kucoin.js');
164
159
  var kucoinfutures$1 = require('./src/pro/kucoinfutures.js');
165
160
  var luno$1 = require('./src/pro/luno.js');
166
161
  var mexc$1 = require('./src/pro/mexc.js');
167
- var mexc3$1 = require('./src/pro/mexc3.js');
168
162
  var ndax$1 = require('./src/pro/ndax.js');
169
163
  var okcoin$1 = require('./src/pro/okcoin.js');
170
- var okex$1 = require('./src/pro/okex.js');
171
164
  var okx$1 = require('./src/pro/okx.js');
172
165
  var phemex$1 = require('./src/pro/phemex.js');
173
166
  var poloniex$1 = require('./src/pro/poloniex.js');
@@ -180,7 +173,7 @@ var woo$1 = require('./src/pro/woo.js');
180
173
 
181
174
  //-----------------------------------------------------------------------------
182
175
  // this is updated by vss.js when building
183
- const version = '4.1.58';
176
+ const version = '4.1.60';
184
177
  Exchange["default"].ccxtVersion = version;
185
178
  const exchanges = {
186
179
  'ace': ace,
@@ -247,7 +240,6 @@ const exchanges = {
247
240
  'htx': htx,
248
241
  'huobi': huobi,
249
242
  'huobijp': huobijp,
250
- 'huobipro': huobipro,
251
243
  'idex': idex,
252
244
  'independentreserve': independentreserve,
253
245
  'indodax': indodax,
@@ -262,13 +254,10 @@ const exchanges = {
262
254
  'lykke': lykke,
263
255
  'mercado': mercado,
264
256
  'mexc': mexc,
265
- 'mexc3': mexc3,
266
257
  'ndax': ndax,
267
258
  'novadax': novadax,
268
259
  'oceanex': oceanex,
269
260
  'okcoin': okcoin,
270
- 'okex': okex,
271
- 'okex5': okex5,
272
261
  'okx': okx,
273
262
  'p2b': p2b,
274
263
  'paymium': paymium,
@@ -328,7 +317,6 @@ const pro = {
328
317
  'htx': htx$1,
329
318
  'huobi': huobi$1,
330
319
  'huobijp': huobijp$1,
331
- 'huobipro': huobipro$1,
332
320
  'idex': idex$1,
333
321
  'independentreserve': independentreserve$1,
334
322
  'kraken': kraken$1,
@@ -337,10 +325,8 @@ const pro = {
337
325
  'kucoinfutures': kucoinfutures$1,
338
326
  'luno': luno$1,
339
327
  'mexc': mexc$1,
340
- 'mexc3': mexc3$1,
341
328
  'ndax': ndax$1,
342
329
  'okcoin': okcoin$1,
343
- 'okex': okex$1,
344
330
  'okx': okx$1,
345
331
  'phemex': phemex$1,
346
332
  'poloniex': poloniex$1,
@@ -456,7 +442,6 @@ exports.hollaex = hollaex;
456
442
  exports.htx = htx;
457
443
  exports.huobi = huobi;
458
444
  exports.huobijp = huobijp;
459
- exports.huobipro = huobipro;
460
445
  exports.idex = idex;
461
446
  exports.independentreserve = independentreserve;
462
447
  exports.indodax = indodax;
@@ -471,13 +456,10 @@ exports.luno = luno;
471
456
  exports.lykke = lykke;
472
457
  exports.mercado = mercado;
473
458
  exports.mexc = mexc;
474
- exports.mexc3 = mexc3;
475
459
  exports.ndax = ndax;
476
460
  exports.novadax = novadax;
477
461
  exports.oceanex = oceanex;
478
462
  exports.okcoin = okcoin;
479
- exports.okex = okex;
480
- exports.okex5 = okex5;
481
463
  exports.okx = okx;
482
464
  exports.p2b = p2b;
483
465
  exports.paymium = paymium;
@@ -414,7 +414,7 @@ class Exchange {
414
414
  'fetchPermissions': undefined,
415
415
  'fetchPosition': undefined,
416
416
  'fetchPositions': undefined,
417
- 'fetchPositionsBySymbol': undefined,
417
+ 'fetchPositionsForSymbol': undefined,
418
418
  'fetchPositionsRisk': undefined,
419
419
  'fetchPremiumIndexOHLCV': undefined,
420
420
  'fetchStatus': 'emulated',
@@ -2309,17 +2309,17 @@ class Exchange {
2309
2309
  return result;
2310
2310
  }
2311
2311
  safeTicker(ticker, market = undefined) {
2312
- let open = this.safeValue(ticker, 'open');
2313
- let close = this.safeValue(ticker, 'close');
2314
- let last = this.safeValue(ticker, 'last');
2315
- let change = this.safeValue(ticker, 'change');
2316
- let percentage = this.safeValue(ticker, 'percentage');
2317
- let average = this.safeValue(ticker, 'average');
2318
- let vwap = this.safeValue(ticker, 'vwap');
2312
+ let open = this.omitZero(this.safeString(ticker, 'open'));
2313
+ let close = this.omitZero(this.safeString(ticker, 'close'));
2314
+ let last = this.omitZero(this.safeString(ticker, 'last'));
2315
+ let change = this.omitZero(this.safeString(ticker, 'change'));
2316
+ let percentage = this.omitZero(this.safeString(ticker, 'percentage'));
2317
+ let average = this.omitZero(this.safeString(ticker, 'average'));
2318
+ let vwap = this.omitZero(this.safeString(ticker, 'vwap'));
2319
2319
  const baseVolume = this.safeString(ticker, 'baseVolume');
2320
2320
  const quoteVolume = this.safeString(ticker, 'quoteVolume');
2321
2321
  if (vwap === undefined) {
2322
- vwap = Precise["default"].stringDiv(quoteVolume, baseVolume);
2322
+ vwap = Precise["default"].stringDiv(this.omitZero(quoteVolume), baseVolume);
2323
2323
  }
2324
2324
  if ((last !== undefined) && (close === undefined)) {
2325
2325
  close = last;
@@ -2347,24 +2347,45 @@ class Exchange {
2347
2347
  // timestamp and symbol operations don't belong in safeTicker
2348
2348
  // they should be done in the derived classes
2349
2349
  return this.extend(ticker, {
2350
- 'bid': this.omitZero(this.safeNumber(ticker, 'bid')),
2350
+ 'bid': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'bid'))),
2351
2351
  'bidVolume': this.safeNumber(ticker, 'bidVolume'),
2352
- 'ask': this.omitZero(this.safeNumber(ticker, 'ask')),
2352
+ 'ask': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'ask'))),
2353
2353
  'askVolume': this.safeNumber(ticker, 'askVolume'),
2354
- 'high': this.omitZero(this.safeNumber(ticker, 'high')),
2355
- 'low': this.omitZero(this.safeNumber(ticker, 'low')),
2356
- 'open': this.omitZero(this.parseNumber(open)),
2357
- 'close': this.omitZero(this.parseNumber(close)),
2358
- 'last': this.omitZero(this.parseNumber(last)),
2354
+ 'high': this.parseNumber(this.omitZero(this.safeString(ticker, 'high"'))),
2355
+ 'low': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'low'))),
2356
+ 'open': this.parseNumber(this.omitZero(this.parseNumber(open))),
2357
+ 'close': this.parseNumber(this.omitZero(this.parseNumber(close))),
2358
+ 'last': this.parseNumber(this.omitZero(this.parseNumber(last))),
2359
2359
  'change': this.parseNumber(change),
2360
2360
  'percentage': this.parseNumber(percentage),
2361
- 'average': this.omitZero(this.parseNumber(average)),
2362
- 'vwap': this.omitZero(this.parseNumber(vwap)),
2361
+ 'average': this.parseNumber(average),
2362
+ 'vwap': this.parseNumber(vwap),
2363
2363
  'baseVolume': this.parseNumber(baseVolume),
2364
2364
  'quoteVolume': this.parseNumber(quoteVolume),
2365
2365
  'previousClose': this.safeNumber(ticker, 'previousClose'),
2366
2366
  });
2367
2367
  }
2368
+ async fetchBorrowRate(code, amount, params = {}) {
2369
+ throw new errors.NotSupported(this.id + ' fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead');
2370
+ }
2371
+ async repayCrossMargin(code, amount, params = {}) {
2372
+ throw new errors.NotSupported(this.id + ' repayCrossMargin is not support yet');
2373
+ }
2374
+ async repayIsolatedMargin(symbol, code, amount, params = {}) {
2375
+ throw new errors.NotSupported(this.id + ' repayIsolatedMargin is not support yet');
2376
+ }
2377
+ async borrowCrossMargin(code, amount, params = {}) {
2378
+ throw new errors.NotSupported(this.id + ' borrowCrossMargin is not support yet');
2379
+ }
2380
+ async borrowIsolatedMargin(symbol, code, amount, params = {}) {
2381
+ throw new errors.NotSupported(this.id + ' borrowIsolatedMargin is not support yet');
2382
+ }
2383
+ async borrowMargin(code, amount, symbol = undefined, params = {}) {
2384
+ throw new errors.NotSupported(this.id + ' borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin instead');
2385
+ }
2386
+ async repayMargin(code, amount, symbol = undefined, params = {}) {
2387
+ throw new errors.NotSupported(this.id + ' repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin instead');
2388
+ }
2368
2389
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
2369
2390
  let message = '';
2370
2391
  if (this.has['fetchTrades']) {
@@ -3001,16 +3022,16 @@ class Exchange {
3001
3022
  async watchPositionForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
3002
3023
  return this.watchPositions(symbols, since, limit, params);
3003
3024
  }
3004
- async fetchPositionsBySymbol(symbol, params = {}) {
3025
+ async fetchPositionsForSymbol(symbol, params = {}) {
3005
3026
  /**
3006
3027
  * @method
3007
- * @name exchange#fetchPositionsBySymbol
3008
- * @description specifically fetches positions for specific symbol, unlike fetchPositions (which can work with multiple symbols, but because of that, it might be slower & more rate-limit consuming)
3009
- * @param {string} symbol unified market symbol of the market the position is held in
3028
+ * @name exchange#fetchPositionsForSymbol
3029
+ * @description fetches all open positions for specific symbol, unlike fetchPositions (which is designed to work with multiple symbols) so this method might be preffered for ony-market purposes, because of less rate-limit consumption and speed
3030
+ * @param {string} symbol unified market symbol
3010
3031
  * @param {object} params extra parameters specific to the endpoint
3011
- * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure} with maximum 3 items - one position for "one-way" mode, and two positions (long & short) for "two-way" (a.k.a. hedge) mode
3032
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure} with maximum 3 items - possible one position for "one-way" mode, and possible two positions (long & short) for "two-way" (a.k.a. hedge) mode
3012
3033
  */
3013
- throw new errors.NotSupported(this.id + ' fetchPositionsBySymbol() is not supported yet');
3034
+ throw new errors.NotSupported(this.id + ' fetchPositionsForSymbol() is not supported yet');
3014
3035
  }
3015
3036
  async fetchPositions(symbols = undefined, params = {}) {
3016
3037
  throw new errors.NotSupported(this.id + ' fetchPositions() is not supported yet');
@@ -111,7 +111,7 @@ class Client {
111
111
  if (!this.isOpen()) {
112
112
  const error = new errors.RequestTimeout('Connection to ' + this.url + ' failed due to a connection timeout');
113
113
  this.onError(error);
114
- this.connection.close(platform.isNode ? 1006 : 1000);
114
+ this.connection.close(1006);
115
115
  }
116
116
  }
117
117
  setConnectionTimeout() {
@@ -33,7 +33,8 @@ class binance extends binance$1 {
33
33
  'future': true,
34
34
  'option': true,
35
35
  'addMargin': true,
36
- 'borrowMargin': true,
36
+ 'borrowCrossMargin': true,
37
+ 'borrowIsolatedMargin': true,
37
38
  'cancelAllOrders': true,
38
39
  'cancelOrder': true,
39
40
  'cancelOrders': true,
@@ -120,7 +121,8 @@ class binance extends binance$1 {
120
121
  'fetchWithdrawals': true,
121
122
  'fetchWithdrawalWhitelist': false,
122
123
  'reduceMargin': true,
123
- 'repayMargin': true,
124
+ 'repayCrossMargin': true,
125
+ 'repayIsolatedMargin': true,
124
126
  'setLeverage': true,
125
127
  'setMargin': false,
126
128
  'setMarginMode': true,
@@ -255,6 +257,7 @@ class binance extends binance$1 {
255
257
  'margin/capital-flow': 10,
256
258
  'margin/delist-schedule': 10,
257
259
  'margin/available-inventory': 0.3334,
260
+ 'margin/leverageBracket': 0.1,
258
261
  'loan/vip/loanable/data': 40,
259
262
  'loan/vip/collateral/data': 40,
260
263
  'loan/vip/request/data': 2.6668,
@@ -9102,32 +9105,55 @@ class binance extends binance$1 {
9102
9105
  'info': info,
9103
9106
  };
9104
9107
  }
9105
- async repayMargin(code, amount, symbol = undefined, params = {}) {
9108
+ async repayCrossMargin(code, amount, params = {}) {
9106
9109
  /**
9107
9110
  * @method
9108
- * @name binance#repayMargin
9111
+ * @name binance#repayCrossMargin
9109
9112
  * @description repay borrowed margin and interest
9110
9113
  * @see https://binance-docs.github.io/apidocs/spot/en/#margin-account-repay-margin
9111
9114
  * @param {string} code unified currency code of the currency to repay
9112
9115
  * @param {float} amount the amount to repay
9116
+ * @param {object} [params] extra parameters specific to the binance api endpoint
9117
+ * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
9118
+ */
9119
+ await this.loadMarkets();
9120
+ const currency = this.currency(code);
9121
+ const request = {
9122
+ 'asset': currency['id'],
9123
+ 'amount': this.currencyToPrecision(code, amount),
9124
+ 'isIsolated': 'FALSE',
9125
+ };
9126
+ const response = await this.sapiPostMarginRepay(this.extend(request, params));
9127
+ //
9128
+ // {
9129
+ // "tranId": 108988250265,
9130
+ // "clientTag":""
9131
+ // }
9132
+ //
9133
+ return this.parseMarginLoan(response, currency);
9134
+ }
9135
+ async repayIsolatedMargin(symbol, code, amount, params = {}) {
9136
+ /**
9137
+ * @method
9138
+ * @name binance#repayIsolatedMargin
9139
+ * @description repay borrowed margin and interest
9140
+ * @see https://binance-docs.github.io/apidocs/spot/en/#margin-account-repay-margin
9113
9141
  * @param {string} symbol unified market symbol, required for isolated margin
9142
+ * @param {string} code unified currency code of the currency to repay
9143
+ * @param {float} amount the amount to repay
9114
9144
  * @param {object} [params] extra parameters specific to the binance api endpoint
9115
9145
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
9116
9146
  */
9117
- const [marginMode, query] = this.handleMarginModeAndParams('repayMargin', params); // cross or isolated
9118
- this.checkRequiredMarginArgument('repayMargin', symbol, marginMode);
9119
9147
  await this.loadMarkets();
9120
9148
  const currency = this.currency(code);
9149
+ const market = this.market(symbol);
9121
9150
  const request = {
9122
9151
  'asset': currency['id'],
9123
9152
  'amount': this.currencyToPrecision(code, amount),
9153
+ 'symbol': market['id'],
9154
+ 'isIsolated': 'TRUE',
9124
9155
  };
9125
- if (symbol !== undefined) {
9126
- const market = this.market(symbol);
9127
- request['symbol'] = market['id'];
9128
- request['isIsolated'] = 'TRUE';
9129
- }
9130
- const response = await this.sapiPostMarginRepay(this.extend(request, query));
9156
+ const response = await this.sapiPostMarginRepay(this.extend(request, params));
9131
9157
  //
9132
9158
  // {
9133
9159
  // "tranId": 108988250265,
@@ -9136,32 +9162,55 @@ class binance extends binance$1 {
9136
9162
  //
9137
9163
  return this.parseMarginLoan(response, currency);
9138
9164
  }
9139
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
9165
+ async borrowCrossMargin(code, amount, params = {}) {
9140
9166
  /**
9141
9167
  * @method
9142
- * @name binance#borrowMargin
9168
+ * @name binance#borrowCrossMargin
9143
9169
  * @description create a loan to borrow margin
9144
9170
  * @see https://binance-docs.github.io/apidocs/spot/en/#margin-account-borrow-margin
9145
9171
  * @param {string} code unified currency code of the currency to borrow
9146
9172
  * @param {float} amount the amount to borrow
9173
+ * @param {object} [params] extra parameters specific to the binance api endpoint
9174
+ * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
9175
+ */
9176
+ await this.loadMarkets();
9177
+ const currency = this.currency(code);
9178
+ const request = {
9179
+ 'asset': currency['id'],
9180
+ 'amount': this.currencyToPrecision(code, amount),
9181
+ 'isIsolated': 'FALSE',
9182
+ };
9183
+ const response = await this.sapiPostMarginLoan(this.extend(request, params));
9184
+ //
9185
+ // {
9186
+ // "tranId": 108988250265,
9187
+ // "clientTag":""
9188
+ // }
9189
+ //
9190
+ return this.parseMarginLoan(response, currency);
9191
+ }
9192
+ async borrowIsolatedMargin(symbol, code, amount, params = {}) {
9193
+ /**
9194
+ * @method
9195
+ * @name binance#borrowIsolatedMargin
9196
+ * @description create a loan to borrow margin
9197
+ * @see https://binance-docs.github.io/apidocs/spot/en/#margin-account-borrow-margin
9147
9198
  * @param {string} symbol unified market symbol, required for isolated margin
9199
+ * @param {string} code unified currency code of the currency to borrow
9200
+ * @param {float} amount the amount to borrow
9148
9201
  * @param {object} [params] extra parameters specific to the binance api endpoint
9149
9202
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
9150
9203
  */
9151
- const [marginMode, query] = this.handleMarginModeAndParams('borrowMargin', params); // cross or isolated
9152
- this.checkRequiredMarginArgument('borrowMargin', symbol, marginMode);
9153
9204
  await this.loadMarkets();
9154
9205
  const currency = this.currency(code);
9206
+ const market = this.market(symbol);
9155
9207
  const request = {
9156
9208
  'asset': currency['id'],
9157
9209
  'amount': this.currencyToPrecision(code, amount),
9210
+ 'symbol': market['id'],
9211
+ 'isIsolated': 'TRUE',
9158
9212
  };
9159
- if (symbol !== undefined) {
9160
- const market = this.market(symbol);
9161
- request['symbol'] = market['id'];
9162
- request['isIsolated'] = 'TRUE';
9163
- }
9164
- const response = await this.sapiPostMarginLoan(this.extend(request, query));
9213
+ const response = await this.sapiPostMarginLoan(this.extend(request, params));
9165
9214
  //
9166
9215
  // {
9167
9216
  // "tranId": 108988250265,
@@ -30,7 +30,8 @@ class bitget extends bitget$1 {
30
30
  'future': true,
31
31
  'option': false,
32
32
  'addMargin': true,
33
- 'borrowMargin': true,
33
+ 'borrowCrossMargin': true,
34
+ 'borrowIsolatedMargin': true,
34
35
  'cancelAllOrders': true,
35
36
  'cancelOrder': true,
36
37
  'cancelOrders': true,
@@ -94,7 +95,8 @@ class bitget extends bitget$1 {
94
95
  'fetchWithdrawal': false,
95
96
  'fetchWithdrawals': true,
96
97
  'reduceMargin': true,
97
- 'repayMargin': true,
98
+ 'repayCrossMargin': true,
99
+ 'repayIsolatedMargin': true,
98
100
  'setLeverage': true,
99
101
  'setMarginMode': true,
100
102
  'setPositionMode': true,
@@ -6295,18 +6297,15 @@ class bitget extends bitget$1 {
6295
6297
  'info': interest,
6296
6298
  }, market);
6297
6299
  }
6298
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
6300
+ async borrowCrossMargin(code, amount, params = {}) {
6299
6301
  /**
6300
6302
  * @method
6301
- * @name bitget#borrowMargin
6303
+ * @name bitget#borrowCrossMargin
6302
6304
  * @description create a loan to borrow margin
6303
6305
  * @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-borrow
6304
- * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-borrow
6305
6306
  * @param {string} code unified currency code of the currency to borrow
6306
6307
  * @param {string} amount the amount to borrow
6307
- * @param {string} [symbol] unified market symbol
6308
6308
  * @param {object} [params] extra parameters specific to the bitget api endpoint
6309
- * @param {string} [params.marginMode] 'isolated' or 'cross', symbol is required for 'isolated'
6310
6309
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6311
6310
  */
6312
6311
  await this.loadMarkets();
@@ -6315,91 +6314,91 @@ class bitget extends bitget$1 {
6315
6314
  'coin': currency['info']['coinName'],
6316
6315
  'borrowAmount': this.currencyToPrecision(code, amount),
6317
6316
  };
6318
- let response = undefined;
6319
- let marginMode = undefined;
6320
- [marginMode, params] = this.handleMarginModeAndParams('borrowMargin', params);
6321
- if ((symbol !== undefined) || (marginMode === 'isolated')) {
6322
- if (symbol === undefined) {
6323
- throw new errors.ArgumentsRequired(this.id + ' borrowMargin() requires a symbol argument');
6324
- }
6325
- const market = this.market(symbol);
6326
- const marketId = market['id'];
6327
- const parts = marketId.split('_');
6328
- const marginMarketId = this.safeStringUpper(parts, 0);
6329
- request['symbol'] = marginMarketId;
6330
- response = await this.privateMarginPostMarginV1IsolatedAccountBorrow(this.extend(request, params));
6331
- }
6332
- else {
6333
- response = await this.privateMarginPostMarginV1CrossAccountBorrow(this.extend(request, params));
6334
- }
6317
+ const response = await this.privateMarginPostMarginV1CrossAccountBorrow(this.extend(request, params));
6335
6318
  //
6336
- // isolated
6319
+ // cross
6337
6320
  //
6338
6321
  // {
6339
6322
  // "code": "00000",
6340
6323
  // "msg": "success",
6341
- // "requestTime": 1697250952516,
6324
+ // "requestTime": 1697251314271,
6342
6325
  // "data": {
6343
6326
  // "clientOid": null,
6344
- // "symbol": "BTCUSDT",
6345
6327
  // "coin": "BTC",
6346
- // "borrowAmount": "0.001"
6328
+ // "borrowAmount": "0.0001"
6347
6329
  // }
6348
6330
  // }
6349
6331
  //
6350
- // cross
6332
+ const data = this.safeValue(response, 'data', {});
6333
+ return this.parseMarginLoan(data, currency);
6334
+ }
6335
+ async borrowIsolatedMargin(symbol, code, amount, params = {}) {
6336
+ /**
6337
+ * @method
6338
+ * @name bitget#borrowIsolatedMargin
6339
+ * @description create a loan to borrow margin
6340
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-borrow
6341
+ * @param {string} symbol unified market symbol
6342
+ * @param {string} code unified currency code of the currency to borrow
6343
+ * @param {string} amount the amount to borrow
6344
+ * @param {object} [params] extra parameters specific to the bitget api endpoint
6345
+ * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6346
+ */
6347
+ await this.loadMarkets();
6348
+ const currency = this.currency(code);
6349
+ const market = this.market(symbol);
6350
+ const marketId = market['id'];
6351
+ const parts = marketId.split('_');
6352
+ const marginMarketId = this.safeStringUpper(parts, 0);
6353
+ const request = {
6354
+ 'coin': currency['info']['coinName'],
6355
+ 'borrowAmount': this.currencyToPrecision(code, amount),
6356
+ 'symbol': marginMarketId,
6357
+ };
6358
+ const response = await this.privateMarginPostMarginV1IsolatedAccountBorrow(this.extend(request, params));
6359
+ //
6360
+ // isolated
6351
6361
  //
6352
6362
  // {
6353
6363
  // "code": "00000",
6354
6364
  // "msg": "success",
6355
- // "requestTime": 1697251314271,
6365
+ // "requestTime": 1697250952516,
6356
6366
  // "data": {
6357
6367
  // "clientOid": null,
6368
+ // "symbol": "BTCUSDT",
6358
6369
  // "coin": "BTC",
6359
- // "borrowAmount": "0.0001"
6370
+ // "borrowAmount": "0.001"
6360
6371
  // }
6361
6372
  // }
6362
6373
  //
6363
6374
  const data = this.safeValue(response, 'data', {});
6364
6375
  return this.parseMarginLoan(data, currency);
6365
6376
  }
6366
- async repayMargin(code, amount, symbol = undefined, params = {}) {
6377
+ async repayIsolatedMargin(symbol, code, amount, params = {}) {
6367
6378
  /**
6368
6379
  * @method
6369
- * @name bitget#repayMargin
6380
+ * @name bitget#repayIsolatedMargin
6370
6381
  * @description repay borrowed margin and interest
6371
6382
  * @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-repay
6372
6383
  * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-repay
6384
+ * @param {string} symbol unified market symbol
6373
6385
  * @param {string} code unified currency code of the currency to repay
6374
6386
  * @param {string} amount the amount to repay
6375
- * @param {string} [symbol] unified market symbol
6376
6387
  * @param {object} [params] extra parameters specific to the bitget api endpoint
6377
- * @param {string} [params.marginMode] 'isolated' or 'cross', symbol is required for 'isolated'
6378
6388
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6379
6389
  */
6380
6390
  await this.loadMarkets();
6381
6391
  const currency = this.currency(code);
6392
+ const market = this.market(symbol);
6393
+ const marketId = market['id'];
6394
+ const parts = marketId.split('_');
6395
+ const marginMarketId = this.safeStringUpper(parts, 0);
6382
6396
  const request = {
6383
6397
  'coin': currency['info']['coinName'],
6384
6398
  'repayAmount': this.currencyToPrecision(code, amount),
6399
+ 'symbol': marginMarketId,
6385
6400
  };
6386
- let response = undefined;
6387
- let marginMode = undefined;
6388
- [marginMode, params] = this.handleMarginModeAndParams('repayMargin', params);
6389
- if ((symbol !== undefined) || (marginMode === 'isolated')) {
6390
- if (symbol === undefined) {
6391
- throw new errors.ArgumentsRequired(this.id + ' repayMargin() requires a symbol argument');
6392
- }
6393
- const market = this.market(symbol);
6394
- const marketId = market['id'];
6395
- const parts = marketId.split('_');
6396
- const marginMarketId = this.safeStringUpper(parts, 0);
6397
- request['symbol'] = marginMarketId;
6398
- response = await this.privateMarginPostMarginV1IsolatedAccountRepay(this.extend(request, params));
6399
- }
6400
- else {
6401
- response = await this.privateMarginPostMarginV1CrossAccountRepay(this.extend(request, params));
6402
- }
6401
+ const response = await this.privateMarginPostMarginV1IsolatedAccountRepay(this.extend(request, params));
6403
6402
  //
6404
6403
  // isolated
6405
6404
  //
@@ -6416,6 +6415,29 @@ class bitget extends bitget$1 {
6416
6415
  // }
6417
6416
  // }
6418
6417
  //
6418
+ const data = this.safeValue(response, 'data', {});
6419
+ return this.parseMarginLoan(data, currency);
6420
+ }
6421
+ async repayCrossMargin(code, amount, params = {}) {
6422
+ /**
6423
+ * @method
6424
+ * @name bitget#repayCrossMargin
6425
+ * @description repay borrowed margin and interest
6426
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-repay
6427
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-repay
6428
+ * @param {string} code unified currency code of the currency to repay
6429
+ * @param {string} amount the amount to repay
6430
+ * @param {object} [params] extra parameters specific to the bitget api endpoint
6431
+ * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6432
+ */
6433
+ await this.loadMarkets();
6434
+ const currency = this.currency(code);
6435
+ const request = {
6436
+ 'coin': currency['info']['coinName'],
6437
+ 'repayAmount': this.currencyToPrecision(code, amount),
6438
+ };
6439
+ const response = await this.privateMarginPostMarginV1CrossAccountRepay(this.extend(request, params));
6440
+ //
6419
6441
  // cross
6420
6442
  //
6421
6443
  // {