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
@@ -352,7 +352,7 @@ export default class Exchange {
352
352
  fetchPermissions: any;
353
353
  fetchPosition: any;
354
354
  fetchPositions: any;
355
- fetchPositionsBySymbol: any;
355
+ fetchPositionsForSymbol: any;
356
356
  fetchPositionsRisk: any;
357
357
  fetchPremiumIndexOHLCV: any;
358
358
  fetchStatus: string;
@@ -632,6 +632,13 @@ export default class Exchange {
632
632
  invertFlatStringDictionary(dict: any): {};
633
633
  reduceFeesByCurrency(fees: any): any[];
634
634
  safeTicker(ticker: object, market?: Market): Ticker;
635
+ fetchBorrowRate(code: string, amount: any, params?: {}): Promise<any>;
636
+ repayCrossMargin(code: string, amount: any, params?: {}): Promise<any>;
637
+ repayIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<any>;
638
+ borrowCrossMargin(code: string, amount: any, params?: {}): Promise<any>;
639
+ borrowIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<any>;
640
+ borrowMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<any>;
641
+ repayMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<any>;
635
642
  fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
636
643
  watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
637
644
  convertTradingViewToOHLCV(ohlcvs: any, timestamp?: string, open?: string, high?: string, low?: string, close?: string, volume?: string, ms?: boolean): any[];
@@ -684,7 +691,7 @@ export default class Exchange {
684
691
  watchPosition(symbol?: string, params?: {}): Promise<Position>;
685
692
  watchPositions(symbols?: string[], since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
686
693
  watchPositionForSymbols(symbols?: string[], since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
687
- fetchPositionsBySymbol(symbol: string, params?: {}): Promise<Position[]>;
694
+ fetchPositionsForSymbol(symbol: string, params?: {}): Promise<Position[]>;
688
695
  fetchPositions(symbols?: string[], params?: {}): Promise<Position[]>;
689
696
  fetchPositionsRisk(symbols?: string[], params?: {}): Promise<Position[]>;
690
697
  fetchBidsAsks(symbols?: string[], params?: {}): Promise<Dictionary<Ticker>>;
@@ -408,7 +408,7 @@ export default class Exchange {
408
408
  'fetchPermissions': undefined,
409
409
  'fetchPosition': undefined,
410
410
  'fetchPositions': undefined,
411
- 'fetchPositionsBySymbol': undefined,
411
+ 'fetchPositionsForSymbol': undefined,
412
412
  'fetchPositionsRisk': undefined,
413
413
  'fetchPremiumIndexOHLCV': undefined,
414
414
  'fetchStatus': 'emulated',
@@ -2305,17 +2305,17 @@ export default class Exchange {
2305
2305
  return result;
2306
2306
  }
2307
2307
  safeTicker(ticker, market = undefined) {
2308
- let open = this.safeValue(ticker, 'open');
2309
- let close = this.safeValue(ticker, 'close');
2310
- let last = this.safeValue(ticker, 'last');
2311
- let change = this.safeValue(ticker, 'change');
2312
- let percentage = this.safeValue(ticker, 'percentage');
2313
- let average = this.safeValue(ticker, 'average');
2314
- let vwap = this.safeValue(ticker, 'vwap');
2308
+ let open = this.omitZero(this.safeString(ticker, 'open'));
2309
+ let close = this.omitZero(this.safeString(ticker, 'close'));
2310
+ let last = this.omitZero(this.safeString(ticker, 'last'));
2311
+ let change = this.omitZero(this.safeString(ticker, 'change'));
2312
+ let percentage = this.omitZero(this.safeString(ticker, 'percentage'));
2313
+ let average = this.omitZero(this.safeString(ticker, 'average'));
2314
+ let vwap = this.omitZero(this.safeString(ticker, 'vwap'));
2315
2315
  const baseVolume = this.safeString(ticker, 'baseVolume');
2316
2316
  const quoteVolume = this.safeString(ticker, 'quoteVolume');
2317
2317
  if (vwap === undefined) {
2318
- vwap = Precise.stringDiv(quoteVolume, baseVolume);
2318
+ vwap = Precise.stringDiv(this.omitZero(quoteVolume), baseVolume);
2319
2319
  }
2320
2320
  if ((last !== undefined) && (close === undefined)) {
2321
2321
  close = last;
@@ -2343,24 +2343,45 @@ export default class Exchange {
2343
2343
  // timestamp and symbol operations don't belong in safeTicker
2344
2344
  // they should be done in the derived classes
2345
2345
  return this.extend(ticker, {
2346
- 'bid': this.omitZero(this.safeNumber(ticker, 'bid')),
2346
+ 'bid': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'bid'))),
2347
2347
  'bidVolume': this.safeNumber(ticker, 'bidVolume'),
2348
- 'ask': this.omitZero(this.safeNumber(ticker, 'ask')),
2348
+ 'ask': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'ask'))),
2349
2349
  'askVolume': this.safeNumber(ticker, 'askVolume'),
2350
- 'high': this.omitZero(this.safeNumber(ticker, 'high')),
2351
- 'low': this.omitZero(this.safeNumber(ticker, 'low')),
2352
- 'open': this.omitZero(this.parseNumber(open)),
2353
- 'close': this.omitZero(this.parseNumber(close)),
2354
- 'last': this.omitZero(this.parseNumber(last)),
2350
+ 'high': this.parseNumber(this.omitZero(this.safeString(ticker, 'high"'))),
2351
+ 'low': this.parseNumber(this.omitZero(this.safeNumber(ticker, 'low'))),
2352
+ 'open': this.parseNumber(this.omitZero(this.parseNumber(open))),
2353
+ 'close': this.parseNumber(this.omitZero(this.parseNumber(close))),
2354
+ 'last': this.parseNumber(this.omitZero(this.parseNumber(last))),
2355
2355
  'change': this.parseNumber(change),
2356
2356
  'percentage': this.parseNumber(percentage),
2357
- 'average': this.omitZero(this.parseNumber(average)),
2358
- 'vwap': this.omitZero(this.parseNumber(vwap)),
2357
+ 'average': this.parseNumber(average),
2358
+ 'vwap': this.parseNumber(vwap),
2359
2359
  'baseVolume': this.parseNumber(baseVolume),
2360
2360
  'quoteVolume': this.parseNumber(quoteVolume),
2361
2361
  'previousClose': this.safeNumber(ticker, 'previousClose'),
2362
2362
  });
2363
2363
  }
2364
+ async fetchBorrowRate(code, amount, params = {}) {
2365
+ throw new NotSupported(this.id + ' fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead');
2366
+ }
2367
+ async repayCrossMargin(code, amount, params = {}) {
2368
+ throw new NotSupported(this.id + ' repayCrossMargin is not support yet');
2369
+ }
2370
+ async repayIsolatedMargin(symbol, code, amount, params = {}) {
2371
+ throw new NotSupported(this.id + ' repayIsolatedMargin is not support yet');
2372
+ }
2373
+ async borrowCrossMargin(code, amount, params = {}) {
2374
+ throw new NotSupported(this.id + ' borrowCrossMargin is not support yet');
2375
+ }
2376
+ async borrowIsolatedMargin(symbol, code, amount, params = {}) {
2377
+ throw new NotSupported(this.id + ' borrowIsolatedMargin is not support yet');
2378
+ }
2379
+ async borrowMargin(code, amount, symbol = undefined, params = {}) {
2380
+ throw new NotSupported(this.id + ' borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin instead');
2381
+ }
2382
+ async repayMargin(code, amount, symbol = undefined, params = {}) {
2383
+ throw new NotSupported(this.id + ' repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin instead');
2384
+ }
2364
2385
  async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
2365
2386
  let message = '';
2366
2387
  if (this.has['fetchTrades']) {
@@ -2997,16 +3018,16 @@ export default class Exchange {
2997
3018
  async watchPositionForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
2998
3019
  return this.watchPositions(symbols, since, limit, params);
2999
3020
  }
3000
- async fetchPositionsBySymbol(symbol, params = {}) {
3021
+ async fetchPositionsForSymbol(symbol, params = {}) {
3001
3022
  /**
3002
3023
  * @method
3003
- * @name exchange#fetchPositionsBySymbol
3004
- * @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)
3005
- * @param {string} symbol unified market symbol of the market the position is held in
3024
+ * @name exchange#fetchPositionsForSymbol
3025
+ * @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
3026
+ * @param {string} symbol unified market symbol
3006
3027
  * @param {object} params extra parameters specific to the endpoint
3007
- * @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
3028
+ * @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
3008
3029
  */
3009
- throw new NotSupported(this.id + ' fetchPositionsBySymbol() is not supported yet');
3030
+ throw new NotSupported(this.id + ' fetchPositionsForSymbol() is not supported yet');
3010
3031
  }
3011
3032
  async fetchPositions(symbols = undefined, params = {}) {
3012
3033
  throw new NotSupported(this.id + ' fetchPositions() is not supported yet');
@@ -110,7 +110,7 @@ export default class Client {
110
110
  if (!this.isOpen()) {
111
111
  const error = new RequestTimeout('Connection to ' + this.url + ' failed due to a connection timeout');
112
112
  this.onError(error);
113
- this.connection.close(isNode ? 1006 : 1000);
113
+ this.connection.close(1006);
114
114
  }
115
115
  }
116
116
  setConnectionTimeout() {
@@ -358,7 +358,7 @@ export default class binance extends Exchange {
358
358
  datetime: string;
359
359
  info: any;
360
360
  };
361
- repayMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<{
361
+ repayCrossMargin(code: string, amount: any, params?: {}): Promise<{
362
362
  id: number;
363
363
  currency: string;
364
364
  amount: any;
@@ -367,7 +367,25 @@ export default class binance extends Exchange {
367
367
  datetime: any;
368
368
  info: any;
369
369
  }>;
370
- borrowMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<{
370
+ repayIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<{
371
+ id: number;
372
+ currency: string;
373
+ amount: any;
374
+ symbol: any;
375
+ timestamp: any;
376
+ datetime: any;
377
+ info: any;
378
+ }>;
379
+ borrowCrossMargin(code: string, amount: any, params?: {}): Promise<{
380
+ id: number;
381
+ currency: string;
382
+ amount: any;
383
+ symbol: any;
384
+ timestamp: any;
385
+ datetime: any;
386
+ info: any;
387
+ }>;
388
+ borrowIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<{
371
389
  id: number;
372
390
  currency: string;
373
391
  amount: any;
package/js/src/binance.js CHANGED
@@ -36,7 +36,8 @@ export default class binance extends Exchange {
36
36
  'future': true,
37
37
  'option': true,
38
38
  'addMargin': true,
39
- 'borrowMargin': true,
39
+ 'borrowCrossMargin': true,
40
+ 'borrowIsolatedMargin': true,
40
41
  'cancelAllOrders': true,
41
42
  'cancelOrder': true,
42
43
  'cancelOrders': true,
@@ -123,7 +124,8 @@ export default class binance extends Exchange {
123
124
  'fetchWithdrawals': true,
124
125
  'fetchWithdrawalWhitelist': false,
125
126
  'reduceMargin': true,
126
- 'repayMargin': true,
127
+ 'repayCrossMargin': true,
128
+ 'repayIsolatedMargin': true,
127
129
  'setLeverage': true,
128
130
  'setMargin': false,
129
131
  'setMarginMode': true,
@@ -258,6 +260,7 @@ export default class binance extends Exchange {
258
260
  'margin/capital-flow': 10,
259
261
  'margin/delist-schedule': 10,
260
262
  'margin/available-inventory': 0.3334,
263
+ 'margin/leverageBracket': 0.1,
261
264
  'loan/vip/loanable/data': 40,
262
265
  'loan/vip/collateral/data': 40,
263
266
  'loan/vip/request/data': 2.6668,
@@ -9105,32 +9108,55 @@ export default class binance extends Exchange {
9105
9108
  'info': info,
9106
9109
  };
9107
9110
  }
9108
- async repayMargin(code, amount, symbol = undefined, params = {}) {
9111
+ async repayCrossMargin(code, amount, params = {}) {
9109
9112
  /**
9110
9113
  * @method
9111
- * @name binance#repayMargin
9114
+ * @name binance#repayCrossMargin
9112
9115
  * @description repay borrowed margin and interest
9113
9116
  * @see https://binance-docs.github.io/apidocs/spot/en/#margin-account-repay-margin
9114
9117
  * @param {string} code unified currency code of the currency to repay
9115
9118
  * @param {float} amount the amount to repay
9119
+ * @param {object} [params] extra parameters specific to the binance api endpoint
9120
+ * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
9121
+ */
9122
+ await this.loadMarkets();
9123
+ const currency = this.currency(code);
9124
+ const request = {
9125
+ 'asset': currency['id'],
9126
+ 'amount': this.currencyToPrecision(code, amount),
9127
+ 'isIsolated': 'FALSE',
9128
+ };
9129
+ const response = await this.sapiPostMarginRepay(this.extend(request, params));
9130
+ //
9131
+ // {
9132
+ // "tranId": 108988250265,
9133
+ // "clientTag":""
9134
+ // }
9135
+ //
9136
+ return this.parseMarginLoan(response, currency);
9137
+ }
9138
+ async repayIsolatedMargin(symbol, code, amount, params = {}) {
9139
+ /**
9140
+ * @method
9141
+ * @name binance#repayIsolatedMargin
9142
+ * @description repay borrowed margin and interest
9143
+ * @see https://binance-docs.github.io/apidocs/spot/en/#margin-account-repay-margin
9116
9144
  * @param {string} symbol unified market symbol, required for isolated margin
9145
+ * @param {string} code unified currency code of the currency to repay
9146
+ * @param {float} amount the amount to repay
9117
9147
  * @param {object} [params] extra parameters specific to the binance api endpoint
9118
9148
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
9119
9149
  */
9120
- const [marginMode, query] = this.handleMarginModeAndParams('repayMargin', params); // cross or isolated
9121
- this.checkRequiredMarginArgument('repayMargin', symbol, marginMode);
9122
9150
  await this.loadMarkets();
9123
9151
  const currency = this.currency(code);
9152
+ const market = this.market(symbol);
9124
9153
  const request = {
9125
9154
  'asset': currency['id'],
9126
9155
  'amount': this.currencyToPrecision(code, amount),
9156
+ 'symbol': market['id'],
9157
+ 'isIsolated': 'TRUE',
9127
9158
  };
9128
- if (symbol !== undefined) {
9129
- const market = this.market(symbol);
9130
- request['symbol'] = market['id'];
9131
- request['isIsolated'] = 'TRUE';
9132
- }
9133
- const response = await this.sapiPostMarginRepay(this.extend(request, query));
9159
+ const response = await this.sapiPostMarginRepay(this.extend(request, params));
9134
9160
  //
9135
9161
  // {
9136
9162
  // "tranId": 108988250265,
@@ -9139,32 +9165,55 @@ export default class binance extends Exchange {
9139
9165
  //
9140
9166
  return this.parseMarginLoan(response, currency);
9141
9167
  }
9142
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
9168
+ async borrowCrossMargin(code, amount, params = {}) {
9143
9169
  /**
9144
9170
  * @method
9145
- * @name binance#borrowMargin
9171
+ * @name binance#borrowCrossMargin
9146
9172
  * @description create a loan to borrow margin
9147
9173
  * @see https://binance-docs.github.io/apidocs/spot/en/#margin-account-borrow-margin
9148
9174
  * @param {string} code unified currency code of the currency to borrow
9149
9175
  * @param {float} amount the amount to borrow
9176
+ * @param {object} [params] extra parameters specific to the binance api endpoint
9177
+ * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
9178
+ */
9179
+ await this.loadMarkets();
9180
+ const currency = this.currency(code);
9181
+ const request = {
9182
+ 'asset': currency['id'],
9183
+ 'amount': this.currencyToPrecision(code, amount),
9184
+ 'isIsolated': 'FALSE',
9185
+ };
9186
+ const response = await this.sapiPostMarginLoan(this.extend(request, params));
9187
+ //
9188
+ // {
9189
+ // "tranId": 108988250265,
9190
+ // "clientTag":""
9191
+ // }
9192
+ //
9193
+ return this.parseMarginLoan(response, currency);
9194
+ }
9195
+ async borrowIsolatedMargin(symbol, code, amount, params = {}) {
9196
+ /**
9197
+ * @method
9198
+ * @name binance#borrowIsolatedMargin
9199
+ * @description create a loan to borrow margin
9200
+ * @see https://binance-docs.github.io/apidocs/spot/en/#margin-account-borrow-margin
9150
9201
  * @param {string} symbol unified market symbol, required for isolated margin
9202
+ * @param {string} code unified currency code of the currency to borrow
9203
+ * @param {float} amount the amount to borrow
9151
9204
  * @param {object} [params] extra parameters specific to the binance api endpoint
9152
9205
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
9153
9206
  */
9154
- const [marginMode, query] = this.handleMarginModeAndParams('borrowMargin', params); // cross or isolated
9155
- this.checkRequiredMarginArgument('borrowMargin', symbol, marginMode);
9156
9207
  await this.loadMarkets();
9157
9208
  const currency = this.currency(code);
9209
+ const market = this.market(symbol);
9158
9210
  const request = {
9159
9211
  'asset': currency['id'],
9160
9212
  'amount': this.currencyToPrecision(code, amount),
9213
+ 'symbol': market['id'],
9214
+ 'isIsolated': 'TRUE',
9161
9215
  };
9162
- if (symbol !== undefined) {
9163
- const market = this.market(symbol);
9164
- request['symbol'] = market['id'];
9165
- request['isIsolated'] = 'TRUE';
9166
- }
9167
- const response = await this.sapiPostMarginLoan(this.extend(request, query));
9216
+ const response = await this.sapiPostMarginLoan(this.extend(request, params));
9168
9217
  //
9169
9218
  // {
9170
9219
  // "tranId": 108988250265,
@@ -218,7 +218,7 @@ export default class bitget extends Exchange {
218
218
  fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<any>;
219
219
  parseTransferStatus(status: any): string;
220
220
  parseOpenInterest(interest: any, market?: Market): import("./base/types.js").OpenInterest;
221
- borrowMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<{
221
+ borrowCrossMargin(code: string, amount: any, params?: {}): Promise<{
222
222
  id: string;
223
223
  currency: string;
224
224
  amount: number;
@@ -227,7 +227,25 @@ export default class bitget extends Exchange {
227
227
  datetime: any;
228
228
  info: any;
229
229
  }>;
230
- repayMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<{
230
+ borrowIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<{
231
+ id: string;
232
+ currency: string;
233
+ amount: number;
234
+ symbol: any;
235
+ timestamp: any;
236
+ datetime: any;
237
+ info: any;
238
+ }>;
239
+ repayIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<{
240
+ id: string;
241
+ currency: string;
242
+ amount: number;
243
+ symbol: any;
244
+ timestamp: any;
245
+ datetime: any;
246
+ info: any;
247
+ }>;
248
+ repayCrossMargin(code: string, amount: any, params?: {}): Promise<{
231
249
  id: string;
232
250
  currency: string;
233
251
  amount: number;
package/js/src/bitget.js CHANGED
@@ -33,7 +33,8 @@ export default class bitget extends Exchange {
33
33
  'future': true,
34
34
  'option': false,
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,
@@ -97,7 +98,8 @@ export default class bitget extends Exchange {
97
98
  'fetchWithdrawal': false,
98
99
  'fetchWithdrawals': true,
99
100
  'reduceMargin': true,
100
- 'repayMargin': true,
101
+ 'repayCrossMargin': true,
102
+ 'repayIsolatedMargin': true,
101
103
  'setLeverage': true,
102
104
  'setMarginMode': true,
103
105
  'setPositionMode': true,
@@ -6298,18 +6300,15 @@ export default class bitget extends Exchange {
6298
6300
  'info': interest,
6299
6301
  }, market);
6300
6302
  }
6301
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
6303
+ async borrowCrossMargin(code, amount, params = {}) {
6302
6304
  /**
6303
6305
  * @method
6304
- * @name bitget#borrowMargin
6306
+ * @name bitget#borrowCrossMargin
6305
6307
  * @description create a loan to borrow margin
6306
6308
  * @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-borrow
6307
- * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-borrow
6308
6309
  * @param {string} code unified currency code of the currency to borrow
6309
6310
  * @param {string} amount the amount to borrow
6310
- * @param {string} [symbol] unified market symbol
6311
6311
  * @param {object} [params] extra parameters specific to the bitget api endpoint
6312
- * @param {string} [params.marginMode] 'isolated' or 'cross', symbol is required for 'isolated'
6313
6312
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6314
6313
  */
6315
6314
  await this.loadMarkets();
@@ -6318,91 +6317,91 @@ export default class bitget extends Exchange {
6318
6317
  'coin': currency['info']['coinName'],
6319
6318
  'borrowAmount': this.currencyToPrecision(code, amount),
6320
6319
  };
6321
- let response = undefined;
6322
- let marginMode = undefined;
6323
- [marginMode, params] = this.handleMarginModeAndParams('borrowMargin', params);
6324
- if ((symbol !== undefined) || (marginMode === 'isolated')) {
6325
- if (symbol === undefined) {
6326
- throw new ArgumentsRequired(this.id + ' borrowMargin() requires a symbol argument');
6327
- }
6328
- const market = this.market(symbol);
6329
- const marketId = market['id'];
6330
- const parts = marketId.split('_');
6331
- const marginMarketId = this.safeStringUpper(parts, 0);
6332
- request['symbol'] = marginMarketId;
6333
- response = await this.privateMarginPostMarginV1IsolatedAccountBorrow(this.extend(request, params));
6334
- }
6335
- else {
6336
- response = await this.privateMarginPostMarginV1CrossAccountBorrow(this.extend(request, params));
6337
- }
6320
+ const response = await this.privateMarginPostMarginV1CrossAccountBorrow(this.extend(request, params));
6338
6321
  //
6339
- // isolated
6322
+ // cross
6340
6323
  //
6341
6324
  // {
6342
6325
  // "code": "00000",
6343
6326
  // "msg": "success",
6344
- // "requestTime": 1697250952516,
6327
+ // "requestTime": 1697251314271,
6345
6328
  // "data": {
6346
6329
  // "clientOid": null,
6347
- // "symbol": "BTCUSDT",
6348
6330
  // "coin": "BTC",
6349
- // "borrowAmount": "0.001"
6331
+ // "borrowAmount": "0.0001"
6350
6332
  // }
6351
6333
  // }
6352
6334
  //
6353
- // cross
6335
+ const data = this.safeValue(response, 'data', {});
6336
+ return this.parseMarginLoan(data, currency);
6337
+ }
6338
+ async borrowIsolatedMargin(symbol, code, amount, params = {}) {
6339
+ /**
6340
+ * @method
6341
+ * @name bitget#borrowIsolatedMargin
6342
+ * @description create a loan to borrow margin
6343
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-borrow
6344
+ * @param {string} symbol unified market symbol
6345
+ * @param {string} code unified currency code of the currency to borrow
6346
+ * @param {string} amount the amount to borrow
6347
+ * @param {object} [params] extra parameters specific to the bitget api endpoint
6348
+ * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6349
+ */
6350
+ await this.loadMarkets();
6351
+ const currency = this.currency(code);
6352
+ const market = this.market(symbol);
6353
+ const marketId = market['id'];
6354
+ const parts = marketId.split('_');
6355
+ const marginMarketId = this.safeStringUpper(parts, 0);
6356
+ const request = {
6357
+ 'coin': currency['info']['coinName'],
6358
+ 'borrowAmount': this.currencyToPrecision(code, amount),
6359
+ 'symbol': marginMarketId,
6360
+ };
6361
+ const response = await this.privateMarginPostMarginV1IsolatedAccountBorrow(this.extend(request, params));
6362
+ //
6363
+ // isolated
6354
6364
  //
6355
6365
  // {
6356
6366
  // "code": "00000",
6357
6367
  // "msg": "success",
6358
- // "requestTime": 1697251314271,
6368
+ // "requestTime": 1697250952516,
6359
6369
  // "data": {
6360
6370
  // "clientOid": null,
6371
+ // "symbol": "BTCUSDT",
6361
6372
  // "coin": "BTC",
6362
- // "borrowAmount": "0.0001"
6373
+ // "borrowAmount": "0.001"
6363
6374
  // }
6364
6375
  // }
6365
6376
  //
6366
6377
  const data = this.safeValue(response, 'data', {});
6367
6378
  return this.parseMarginLoan(data, currency);
6368
6379
  }
6369
- async repayMargin(code, amount, symbol = undefined, params = {}) {
6380
+ async repayIsolatedMargin(symbol, code, amount, params = {}) {
6370
6381
  /**
6371
6382
  * @method
6372
- * @name bitget#repayMargin
6383
+ * @name bitget#repayIsolatedMargin
6373
6384
  * @description repay borrowed margin and interest
6374
6385
  * @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-repay
6375
6386
  * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-repay
6387
+ * @param {string} symbol unified market symbol
6376
6388
  * @param {string} code unified currency code of the currency to repay
6377
6389
  * @param {string} amount the amount to repay
6378
- * @param {string} [symbol] unified market symbol
6379
6390
  * @param {object} [params] extra parameters specific to the bitget api endpoint
6380
- * @param {string} [params.marginMode] 'isolated' or 'cross', symbol is required for 'isolated'
6381
6391
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6382
6392
  */
6383
6393
  await this.loadMarkets();
6384
6394
  const currency = this.currency(code);
6395
+ const market = this.market(symbol);
6396
+ const marketId = market['id'];
6397
+ const parts = marketId.split('_');
6398
+ const marginMarketId = this.safeStringUpper(parts, 0);
6385
6399
  const request = {
6386
6400
  'coin': currency['info']['coinName'],
6387
6401
  'repayAmount': this.currencyToPrecision(code, amount),
6402
+ 'symbol': marginMarketId,
6388
6403
  };
6389
- let response = undefined;
6390
- let marginMode = undefined;
6391
- [marginMode, params] = this.handleMarginModeAndParams('repayMargin', params);
6392
- if ((symbol !== undefined) || (marginMode === 'isolated')) {
6393
- if (symbol === undefined) {
6394
- throw new ArgumentsRequired(this.id + ' repayMargin() requires a symbol argument');
6395
- }
6396
- const market = this.market(symbol);
6397
- const marketId = market['id'];
6398
- const parts = marketId.split('_');
6399
- const marginMarketId = this.safeStringUpper(parts, 0);
6400
- request['symbol'] = marginMarketId;
6401
- response = await this.privateMarginPostMarginV1IsolatedAccountRepay(this.extend(request, params));
6402
- }
6403
- else {
6404
- response = await this.privateMarginPostMarginV1CrossAccountRepay(this.extend(request, params));
6405
- }
6404
+ const response = await this.privateMarginPostMarginV1IsolatedAccountRepay(this.extend(request, params));
6406
6405
  //
6407
6406
  // isolated
6408
6407
  //
@@ -6419,6 +6418,29 @@ export default class bitget extends Exchange {
6419
6418
  // }
6420
6419
  // }
6421
6420
  //
6421
+ const data = this.safeValue(response, 'data', {});
6422
+ return this.parseMarginLoan(data, currency);
6423
+ }
6424
+ async repayCrossMargin(code, amount, params = {}) {
6425
+ /**
6426
+ * @method
6427
+ * @name bitget#repayCrossMargin
6428
+ * @description repay borrowed margin and interest
6429
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-repay
6430
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-repay
6431
+ * @param {string} code unified currency code of the currency to repay
6432
+ * @param {string} amount the amount to repay
6433
+ * @param {object} [params] extra parameters specific to the bitget api endpoint
6434
+ * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6435
+ */
6436
+ await this.loadMarkets();
6437
+ const currency = this.currency(code);
6438
+ const request = {
6439
+ 'coin': currency['info']['coinName'],
6440
+ 'repayAmount': this.currencyToPrecision(code, amount),
6441
+ };
6442
+ const response = await this.privateMarginPostMarginV1CrossAccountRepay(this.extend(request, params));
6443
+ //
6422
6444
  // cross
6423
6445
  //
6424
6446
  // {
@@ -101,8 +101,8 @@ export default class bitmart extends Exchange {
101
101
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
102
102
  parseTransactionStatus(status: any): string;
103
103
  parseTransaction(transaction: any, currency?: Currency): Transaction;
104
- repayMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<any>;
105
- borrowMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<any>;
104
+ repayIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<any>;
105
+ borrowIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<any>;
106
106
  parseMarginLoan(info: any, currency?: Currency): {
107
107
  id: string;
108
108
  currency: string;