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/bitmart.js CHANGED
@@ -34,7 +34,8 @@ export default class bitmart extends Exchange {
34
34
  'swap': true,
35
35
  'future': false,
36
36
  'option': false,
37
- 'borrowMargin': true,
37
+ 'borrowCrossMargin': false,
38
+ 'borrowIsolatedMargin': true,
38
39
  'cancelAllOrders': true,
39
40
  'cancelOrder': true,
40
41
  'cancelOrders': false,
@@ -96,7 +97,8 @@ export default class bitmart extends Exchange {
96
97
  'fetchWithdrawal': true,
97
98
  'fetchWithdrawals': true,
98
99
  'reduceMargin': false,
99
- 'repayMargin': true,
100
+ 'repayCrossMargin': false,
101
+ 'repayIsolatedMargin': true,
100
102
  'setLeverage': true,
101
103
  'setMarginMode': false,
102
104
  'transfer': true,
@@ -3200,22 +3202,18 @@ export default class bitmart extends Exchange {
3200
3202
  'fee': fee,
3201
3203
  };
3202
3204
  }
3203
- async repayMargin(code, amount, symbol = undefined, params = {}) {
3205
+ async repayIsolatedMargin(symbol, code, amount, params = {}) {
3204
3206
  /**
3205
3207
  * @method
3206
- * @name bitmart#repayMargin
3208
+ * @name bitmart#repayIsolatedMargin
3207
3209
  * @description repay borrowed margin and interest
3208
3210
  * @see https://developer-pro.bitmart.com/en/spot/#margin-repay-isolated
3211
+ * @param {string} symbol unified market symbol
3209
3212
  * @param {string} code unified currency code of the currency to repay
3210
3213
  * @param {string} amount the amount to repay
3211
- * @param {string} symbol unified market symbol
3212
3214
  * @param {object} [params] extra parameters specific to the bitmart api endpoint
3213
- * @param {string} [params.marginMode] 'isolated' is the default and 'cross' is unavailable
3214
3215
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
3215
3216
  */
3216
- if (symbol === undefined) {
3217
- throw new ArgumentsRequired(this.id + ' repayMargin() requires a symbol argument');
3218
- }
3219
3217
  await this.loadMarkets();
3220
3218
  const market = this.market(symbol);
3221
3219
  const currency = this.currency(code);
@@ -3224,7 +3222,6 @@ export default class bitmart extends Exchange {
3224
3222
  'currency': currency['id'],
3225
3223
  'amount': this.currencyToPrecision(code, amount),
3226
3224
  };
3227
- params = this.omit(params, 'marginMode');
3228
3225
  const response = await this.privatePostSpotV1MarginIsolatedRepay(this.extend(request, params));
3229
3226
  //
3230
3227
  // {
@@ -3243,22 +3240,18 @@ export default class bitmart extends Exchange {
3243
3240
  'symbol': symbol,
3244
3241
  });
3245
3242
  }
3246
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
3243
+ async borrowIsolatedMargin(symbol, code, amount, params = {}) {
3247
3244
  /**
3248
3245
  * @method
3249
- * @name bitmart#borrowMargin
3246
+ * @name bitmart#borrowIsolatedMargin
3250
3247
  * @description create a loan to borrow margin
3251
3248
  * @see https://developer-pro.bitmart.com/en/spot/#margin-borrow-isolated
3249
+ * @param {string} symbol unified market symbol
3252
3250
  * @param {string} code unified currency code of the currency to borrow
3253
3251
  * @param {string} amount the amount to borrow
3254
- * @param {string} symbol unified market symbol
3255
3252
  * @param {object} [params] extra parameters specific to the bitmart api endpoint
3256
- * @param {string} [params.marginMode] 'isolated' is the default and 'cross' is unavailable
3257
3253
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
3258
3254
  */
3259
- if (symbol === undefined) {
3260
- throw new ArgumentsRequired(this.id + ' borrowMargin() requires a symbol argument');
3261
- }
3262
3255
  await this.loadMarkets();
3263
3256
  const market = this.market(symbol);
3264
3257
  const currency = this.currency(code);
@@ -3267,7 +3260,6 @@ export default class bitmart extends Exchange {
3267
3260
  'currency': currency['id'],
3268
3261
  'amount': this.currencyToPrecision(code, amount),
3269
3262
  };
3270
- params = this.omit(params, 'marginMode');
3271
3263
  const response = await this.privatePostSpotV1MarginIsolatedBorrow(this.extend(request, params));
3272
3264
  //
3273
3265
  // {
package/js/src/bitrue.js CHANGED
@@ -96,7 +96,7 @@ export default class bitrue extends Exchange {
96
96
  'kline': 'https://www.bitrue.com/kline-api',
97
97
  },
98
98
  'www': 'https://www.bitrue.com',
99
- 'referral': 'https://www.bitrue.com/activity/task/task-landing?inviteCode=EZWETQE&cn=900000',
99
+ 'referral': 'https://www.bitrue.com/affiliate/landing?cn=600000&inviteCode=EZWETQE',
100
100
  'doc': [
101
101
  'https://github.com/Bitrue-exchange/bitrue-official-api-docs',
102
102
  ],
package/js/src/bybit.d.ts CHANGED
@@ -157,8 +157,8 @@ export default class bybit extends Exchange {
157
157
  };
158
158
  transfer(code: string, amount: any, fromAccount: any, toAccount: any, params?: {}): Promise<any>;
159
159
  fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
160
- borrowMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<any>;
161
- repayMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<any>;
160
+ borrowCrossMargin(code: string, amount: any, params?: {}): Promise<any>;
161
+ repayCrossMargin(code: string, amount: any, params?: {}): Promise<any>;
162
162
  parseMarginLoan(info: any, currency?: Currency): {
163
163
  id: string;
164
164
  currency: string;
package/js/src/bybit.js CHANGED
@@ -35,6 +35,7 @@ export default class bybit extends Exchange {
35
35
  'swap': true,
36
36
  'future': true,
37
37
  'option': true,
38
+ 'borrowCrossMargin': true,
38
39
  'cancelAllOrders': true,
39
40
  'cancelOrder': true,
40
41
  'createOrder': true,
@@ -97,6 +98,7 @@ export default class bybit extends Exchange {
97
98
  'fetchUnderlyingAssets': false,
98
99
  'fetchVolatilityHistory': true,
99
100
  'fetchWithdrawals': true,
101
+ 'repayCrossMargin': true,
100
102
  'setLeverage': true,
101
103
  'setMarginMode': true,
102
104
  'setPositionMode': true,
@@ -3434,7 +3436,9 @@ export default class bybit extends Exchange {
3434
3436
  const result = await this.fetchOrders(symbol, undefined, undefined, this.extend(request, params));
3435
3437
  const length = result.length;
3436
3438
  if (length === 0) {
3437
- throw new OrderNotFound('Order ' + id.toString() + ' does not exist.');
3439
+ const isTrigger = this.safeValueN(params, ['trigger', 'stop'], false);
3440
+ const extra = isTrigger ? '' : 'If you are trying to fetch SL/TP conditional order, you might try setting params["trigger"] = true';
3441
+ throw new OrderNotFound('Order ' + id.toString() + ' was not found.' + extra);
3438
3442
  }
3439
3443
  if (length > 1) {
3440
3444
  throw new InvalidOrder(this.id + ' returned more than one order');
@@ -3460,7 +3464,7 @@ export default class bybit extends Exchange {
3460
3464
  * @param {boolean} [params.isLeverage] *unified spot only* false then spot trading true then margin trading
3461
3465
  * @param {string} [params.tpslMode] *contract only* 'full' or 'partial'
3462
3466
  * @param {string} [params.mmp] *option only* market maker protection
3463
- * @param {string} [params.triggerDirection] *contract only* the direction for trigger orders, 'up' or 'down'
3467
+ * @param {string} [params.triggerDirection] *contract only* the direction for trigger orders, 'above' or 'below'
3464
3468
  * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
3465
3469
  * @param {float} [params.stopLossPrice] The price at which a stop loss order is triggered at
3466
3470
  * @param {float} [params.takeProfitPrice] The price at which a take profit order is triggered at
@@ -3592,21 +3596,30 @@ export default class bybit extends Exchange {
3592
3596
  const isStopLoss = stopLoss !== undefined;
3593
3597
  const isTakeProfit = takeProfit !== undefined;
3594
3598
  const isBuy = side === 'buy';
3595
- const setTriggerDirection = (stopLossTriggerPrice || triggerPrice) ? !isBuy : isBuy;
3596
- const defaultTriggerDirection = setTriggerDirection ? 2 : 1;
3597
- const triggerDirection = this.safeString(params, 'triggerDirection');
3598
- params = this.omit(params, 'triggerDirection');
3599
- let selectedDirection = defaultTriggerDirection;
3600
- if (triggerDirection !== undefined) {
3601
- const isAsending = ((triggerDirection === 'up') || (triggerDirection === '1'));
3602
- selectedDirection = isAsending ? 1 : 2;
3603
- }
3604
3599
  if (triggerPrice !== undefined) {
3605
- request['triggerDirection'] = selectedDirection;
3600
+ const triggerDirection = this.safeString(params, 'triggerDirection');
3601
+ params = this.omit(params, ['triggerPrice', 'stopPrice', 'triggerDirection']);
3602
+ if (market['spot']) {
3603
+ if (triggerDirection !== undefined) {
3604
+ throw new NotSupported(this.id + ' createOrder() : trigger order does not support triggerDirection for spot markets yet');
3605
+ }
3606
+ }
3607
+ else {
3608
+ if (triggerDirection === undefined) {
3609
+ throw new ArgumentsRequired(this.id + ' stop/trigger orders require a triggerDirection parameter, either "above" or "below" to determine the direction of the trigger.');
3610
+ }
3611
+ const isAsending = ((triggerDirection === 'above') || (triggerDirection === '1'));
3612
+ request['triggerDirection'] = isAsending ? 1 : 2;
3613
+ }
3606
3614
  request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
3607
3615
  }
3608
3616
  else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
3609
- request['triggerDirection'] = selectedDirection;
3617
+ if (isBuy) {
3618
+ request['triggerDirection'] = isStopLossTriggerOrder ? 1 : 2;
3619
+ }
3620
+ else {
3621
+ request['triggerDirection'] = isStopLossTriggerOrder ? 2 : 1;
3622
+ }
3610
3623
  triggerPrice = isStopLossTriggerOrder ? stopLossTriggerPrice : takeProfitTriggerPrice;
3611
3624
  request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
3612
3625
  request['reduceOnly'] = true;
@@ -4406,8 +4419,8 @@ export default class bybit extends Exchange {
4406
4419
  return await this.fetchUsdcOrders(symbol, since, limit, params);
4407
4420
  }
4408
4421
  request['category'] = type;
4409
- const isStop = this.safeValue(params, 'stop', false);
4410
- params = this.omit(params, ['stop']);
4422
+ const isStop = this.safeValueN(params, ['trigger', 'stop'], false);
4423
+ params = this.omit(params, ['trigger', 'stop']);
4411
4424
  if (isStop) {
4412
4425
  if (type === 'spot') {
4413
4426
  request['orderFilter'] = 'tpslOrder';
@@ -6613,29 +6626,24 @@ export default class bybit extends Exchange {
6613
6626
  const data = this.addPaginationCursorToResult(response);
6614
6627
  return this.parseTransfers(data, currency, since, limit);
6615
6628
  }
6616
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
6629
+ async borrowCrossMargin(code, amount, params = {}) {
6617
6630
  /**
6618
6631
  * @method
6619
- * @name bybit#borrowMargin
6632
+ * @name bybit#borrowCrossMargin
6620
6633
  * @description create a loan to borrow margin
6621
6634
  * @see https://bybit-exchange.github.io/docs/v5/spot-margin-normal/borrow
6622
6635
  * @param {string} code unified currency code of the currency to borrow
6623
6636
  * @param {float} amount the amount to borrow
6624
- * @param {string} symbol not used by bybit.borrowMargin ()
6625
6637
  * @param {object} [params] extra parameters specific to the bybit api endpoint
6626
6638
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6627
6639
  */
6628
6640
  await this.loadMarkets();
6629
6641
  const currency = this.currency(code);
6630
- const [marginMode, query] = this.handleMarginModeAndParams('borrowMargin', params);
6631
- if (marginMode === 'isolated') {
6632
- throw new NotSupported(this.id + ' borrowMargin () cannot use isolated margin');
6633
- }
6634
6642
  const request = {
6635
6643
  'coin': currency['id'],
6636
6644
  'qty': this.currencyToPrecision(code, amount),
6637
6645
  };
6638
- const response = await this.privatePostV5SpotCrossMarginTradeLoan(this.extend(request, query));
6646
+ const response = await this.privatePostV5SpotCrossMarginTradeLoan(this.extend(request, params));
6639
6647
  //
6640
6648
  // {
6641
6649
  // "retCode": 0,
@@ -6650,33 +6658,28 @@ export default class bybit extends Exchange {
6650
6658
  const result = this.safeValue(response, 'result', {});
6651
6659
  const transaction = this.parseMarginLoan(result, currency);
6652
6660
  return this.extend(transaction, {
6653
- 'symbol': symbol,
6661
+ 'symbol': undefined,
6654
6662
  'amount': amount,
6655
6663
  });
6656
6664
  }
6657
- async repayMargin(code, amount, symbol = undefined, params = {}) {
6665
+ async repayCrossMargin(code, amount, params = {}) {
6658
6666
  /**
6659
6667
  * @method
6660
- * @name bybit#repayMargin
6668
+ * @name bybit#repayCrossMargin
6661
6669
  * @description repay borrowed margin and interest
6662
6670
  * @see https://bybit-exchange.github.io/docs/v5/spot-margin-normal/repay
6663
6671
  * @param {string} code unified currency code of the currency to repay
6664
6672
  * @param {float} amount the amount to repay
6665
- * @param {string} symbol not used by bybit.repayMargin ()
6666
6673
  * @param {object} [params] extra parameters specific to the bybit api endpoint
6667
6674
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6668
6675
  */
6669
6676
  await this.loadMarkets();
6670
6677
  const currency = this.currency(code);
6671
- const [marginMode, query] = this.handleMarginModeAndParams('repayMargin', params);
6672
- if (marginMode === 'isolated') {
6673
- throw new NotSupported(this.id + ' repayMargin () cannot use isolated margin');
6674
- }
6675
6678
  const request = {
6676
6679
  'coin': currency['id'],
6677
6680
  'qty': this.numberToString(amount),
6678
6681
  };
6679
- const response = await this.privatePostV5SpotCrossMarginTradeRepay(this.extend(request, query));
6682
+ const response = await this.privatePostV5SpotCrossMarginTradeRepay(this.extend(request, params));
6680
6683
  //
6681
6684
  // {
6682
6685
  // "retCode": 0,
@@ -6691,7 +6694,7 @@ export default class bybit extends Exchange {
6691
6694
  const result = this.safeValue(response, 'result', {});
6692
6695
  const transaction = this.parseMarginLoan(result, currency);
6693
6696
  return this.extend(transaction, {
6694
- 'symbol': symbol,
6697
+ 'symbol': undefined,
6695
6698
  'amount': amount,
6696
6699
  });
6697
6700
  }
@@ -234,6 +234,7 @@ export default class coinbasepro extends Exchange {
234
234
  * @method
235
235
  * @name coinbasepro#fetchCurrencies
236
236
  * @description fetches all available currencies on an exchange
237
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getcurrencies
237
238
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
238
239
  * @returns {object} an associative dictionary of currencies
239
240
  */
@@ -304,6 +305,7 @@ export default class coinbasepro extends Exchange {
304
305
  * @method
305
306
  * @name coinbasepro#fetchMarkets
306
307
  * @description retrieves data on all markets for coinbasepro
308
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproducts
307
309
  * @param {object} [params] extra parameters specific to the exchange api endpoint
308
310
  * @returns {object[]} an array of objects representing market data
309
311
  */
@@ -424,6 +426,7 @@ export default class coinbasepro extends Exchange {
424
426
  * @method
425
427
  * @name coinbasepro#fetchAccounts
426
428
  * @description fetch all the accounts associated with a profile
429
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounts
427
430
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
428
431
  * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
429
432
  */
@@ -489,6 +492,7 @@ export default class coinbasepro extends Exchange {
489
492
  * @method
490
493
  * @name coinbasepro#fetchBalance
491
494
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
495
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounts
492
496
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
493
497
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
494
498
  */
@@ -621,6 +625,7 @@ export default class coinbasepro extends Exchange {
621
625
  * @method
622
626
  * @name coinbasepro#fetchTickers
623
627
  * @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
628
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproduct
624
629
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
625
630
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
626
631
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -856,6 +861,7 @@ export default class coinbasepro extends Exchange {
856
861
  * @method
857
862
  * @name coinbasepro#fetchTradingFees
858
863
  * @description fetch the trading fees for multiple markets
864
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getfees
859
865
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
860
866
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
861
867
  */
@@ -1354,6 +1360,8 @@ export default class coinbasepro extends Exchange {
1354
1360
  * @method
1355
1361
  * @name coinbasepro#deposit
1356
1362
  * @description Creates a new deposit address, as required by coinbasepro
1363
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postdepositpaymentmethod
1364
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postdepositcoinbaseaccount
1357
1365
  * @param {string} code Unified CCXT currency code (e.g. `"USDT"`)
1358
1366
  * @param {float} amount The amount of currency to send in the deposit (e.g. `20`)
1359
1367
  * @param {string} address Not used by coinbasepro
@@ -1395,6 +1403,8 @@ export default class coinbasepro extends Exchange {
1395
1403
  * @method
1396
1404
  * @name coinbasepro#withdraw
1397
1405
  * @description make a withdrawal
1406
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postwithdrawpaymentmethod
1407
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postwithdrawcoinbaseaccount
1398
1408
  * @param {string} code unified currency code
1399
1409
  * @param {float} amount the amount to withdraw
1400
1410
  * @param {string} address the address to withdraw to
@@ -1678,6 +1688,8 @@ export default class coinbasepro extends Exchange {
1678
1688
  * @method
1679
1689
  * @name coinbasepro#fetchDeposits
1680
1690
  * @description fetch all deposits made to an account
1691
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
1692
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounttransfers
1681
1693
  * @param {string} code unified currency code
1682
1694
  * @param {int} [since] the earliest time in ms to fetch deposits for
1683
1695
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -1691,6 +1703,8 @@ export default class coinbasepro extends Exchange {
1691
1703
  * @method
1692
1704
  * @name coinbasepro#fetchWithdrawals
1693
1705
  * @description fetch all withdrawals made from an account
1706
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
1707
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounttransfers
1694
1708
  * @param {string} code unified currency code
1695
1709
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
1696
1710
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -1801,6 +1815,7 @@ export default class coinbasepro extends Exchange {
1801
1815
  * @method
1802
1816
  * @name coinbasepro#createDepositAddress
1803
1817
  * @description create a currency deposit address
1818
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postcoinbaseaccountaddresses
1804
1819
  * @param {string} code unified currency code of the currency for the deposit address
1805
1820
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
1806
1821
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
@@ -190,8 +190,8 @@ export default class coinex extends Exchange {
190
190
  datetime: string;
191
191
  info: any;
192
192
  };
193
- borrowMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<any>;
194
- repayMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<any>;
193
+ borrowIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<any>;
194
+ repayIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<any>;
195
195
  parseMarginLoan(info: any, currency?: Currency): {
196
196
  id: number;
197
197
  currency: string;
package/js/src/coinex.js CHANGED
@@ -41,7 +41,8 @@ export default class coinex extends Exchange {
41
41
  'future': false,
42
42
  'option': false,
43
43
  'addMargin': true,
44
- 'borrowMargin': true,
44
+ 'borrowCrossMargin': false,
45
+ 'borrowIsolatedMargin': true,
45
46
  'cancelAllOrders': true,
46
47
  'cancelOrder': true,
47
48
  'createDepositAddress': true,
@@ -94,7 +95,8 @@ export default class coinex extends Exchange {
94
95
  'fetchWithdrawal': false,
95
96
  'fetchWithdrawals': true,
96
97
  'reduceMargin': true,
97
- 'repayMargin': true,
98
+ 'repayCrossMargin': false,
99
+ 'repayIsolatedMargin': true,
98
100
  'setLeverage': true,
99
101
  'setMarginMode': true,
100
102
  'setPositionMode': false,
@@ -3259,16 +3261,19 @@ export default class coinex extends Exchange {
3259
3261
  const maintenanceMargin = this.safeString(position, 'mainten_margin_amount');
3260
3262
  const maintenanceMarginPercentage = this.safeString(position, 'mainten_margin');
3261
3263
  const collateral = this.safeString(position, 'margin_amount');
3262
- const leverage = this.safeNumber(position, 'leverage');
3264
+ const leverage = this.safeString(position, 'leverage');
3265
+ const notional = this.safeString(position, 'open_val');
3266
+ const initialMargin = Precise.stringDiv(notional, leverage);
3267
+ const initialMarginPercentage = Precise.stringDiv('1', leverage);
3263
3268
  return this.safePosition({
3264
3269
  'info': position,
3265
3270
  'id': positionId,
3266
3271
  'symbol': symbol,
3267
- 'notional': undefined,
3272
+ 'notional': this.parseNumber(notional),
3268
3273
  'marginMode': marginMode,
3269
3274
  'liquidationPrice': liquidationPrice,
3270
- 'entryPrice': entryPrice,
3271
- 'unrealizedPnl': unrealizedPnl,
3275
+ 'entryPrice': this.parseNumber(entryPrice),
3276
+ 'unrealizedPnl': this.parseNumber(unrealizedPnl),
3272
3277
  'percentage': undefined,
3273
3278
  'contracts': contracts,
3274
3279
  'contractSize': this.safeNumber(market, 'contractSize'),
@@ -3279,15 +3284,15 @@ export default class coinex extends Exchange {
3279
3284
  'timestamp': timestamp,
3280
3285
  'datetime': this.iso8601(timestamp),
3281
3286
  'lastUpdateTimestamp': undefined,
3282
- 'maintenanceMargin': maintenanceMargin,
3283
- 'maintenanceMarginPercentage': maintenanceMarginPercentage,
3284
- 'collateral': collateral,
3285
- 'initialMargin': undefined,
3286
- 'initialMarginPercentage': undefined,
3287
- 'leverage': leverage,
3287
+ 'maintenanceMargin': this.parseNumber(maintenanceMargin),
3288
+ 'maintenanceMarginPercentage': this.parseNumber(maintenanceMarginPercentage),
3289
+ 'collateral': this.parseNumber(collateral),
3290
+ 'initialMargin': this.parseNumber(initialMargin),
3291
+ 'initialMarginPercentage': this.parseNumber(initialMarginPercentage),
3292
+ 'leverage': this.parseNumber(leverage),
3288
3293
  'marginRatio': undefined,
3289
- 'stopLossPrice': this.safeNumber(position, 'stop_loss_price'),
3290
- 'takeProfitPrice': this.safeNumber(position, 'take_profit_price'),
3294
+ 'stopLossPrice': this.omitZero(this.safeString(position, 'stop_loss_price')),
3295
+ 'takeProfitPrice': this.omitZero(this.safeString(position, 'take_profit_price')),
3291
3296
  });
3292
3297
  }
3293
3298
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
@@ -4606,21 +4611,18 @@ export default class coinex extends Exchange {
4606
4611
  'info': info,
4607
4612
  };
4608
4613
  }
4609
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
4614
+ async borrowIsolatedMargin(symbol, code, amount, params = {}) {
4610
4615
  /**
4611
4616
  * @method
4612
- * @name coinex#borrowMargin
4617
+ * @name coinex#borrowIsolatedMargin
4613
4618
  * @description create a loan to borrow margin
4614
4619
  * @see https://github.com/coinexcom/coinex_exchange_api/wiki/086margin_loan
4620
+ * @param {string} symbol unified market symbol, required for coinex
4615
4621
  * @param {string} code unified currency code of the currency to borrow
4616
4622
  * @param {float} amount the amount to borrow
4617
- * @param {string} symbol unified market symbol, required for coinex
4618
4623
  * @param {object} [params] extra parameters specific to the coinex api endpoint
4619
4624
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
4620
4625
  */
4621
- if (symbol === undefined) {
4622
- throw new ArgumentsRequired(this.id + ' borrowMargin() requires a symbol argument');
4623
- }
4624
4626
  await this.loadMarkets();
4625
4627
  const market = this.market(symbol);
4626
4628
  const currency = this.currency(code);
@@ -4646,22 +4648,19 @@ export default class coinex extends Exchange {
4646
4648
  'symbol': symbol,
4647
4649
  });
4648
4650
  }
4649
- async repayMargin(code, amount, symbol = undefined, params = {}) {
4651
+ async repayIsolatedMargin(symbol, code, amount, params = {}) {
4650
4652
  /**
4651
4653
  * @method
4652
- * @name coinex#repayMargin
4654
+ * @name coinex#repayIsolatedMargin
4653
4655
  * @description repay borrowed margin and interest
4654
4656
  * @see https://github.com/coinexcom/coinex_exchange_api/wiki/087margin_flat
4657
+ * @param {string} symbol unified market symbol, required for coinex
4655
4658
  * @param {string} code unified currency code of the currency to repay
4656
4659
  * @param {float} amount the amount to repay
4657
- * @param {string} symbol unified market symbol, required for coinex
4658
4660
  * @param {object} [params] extra parameters specific to the coinex api endpoint
4659
4661
  * @param {string} [params.loan_id] extra parameter that is not required
4660
4662
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
4661
4663
  */
4662
- if (symbol === undefined) {
4663
- throw new ArgumentsRequired(this.id + ' repayMargin() requires a symbol argument');
4664
- }
4665
4664
  await this.loadMarkets();
4666
4665
  const market = this.market(symbol);
4667
4666
  const currency = this.currency(code);
@@ -4670,10 +4669,6 @@ export default class coinex extends Exchange {
4670
4669
  'coin_type': currency['id'],
4671
4670
  'amount': this.currencyToPrecision(code, amount),
4672
4671
  };
4673
- const loanId = this.safeInteger(params, 'loan_id');
4674
- if (loanId !== undefined) {
4675
- request['loan_id'] = loanId;
4676
- }
4677
4672
  const response = await this.privatePostMarginFlat(this.extend(request, params));
4678
4673
  //
4679
4674
  // {
package/js/src/htx.d.ts CHANGED
@@ -239,10 +239,12 @@ export default class htx extends Exchange {
239
239
  fetchOpenInterestHistory(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").OpenInterest[]>;
240
240
  fetchOpenInterest(symbol: string, params?: {}): Promise<import("./base/types.js").OpenInterest>;
241
241
  parseOpenInterest(interest: any, market?: Market): import("./base/types.js").OpenInterest;
242
- borrowMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<any>;
243
- repayMargin(code: string, amount: any, symbol?: Str, params?: {}): Promise<any>;
242
+ borrowIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<any>;
243
+ borrowCrossMargin(code: string, amount: any, params?: {}): Promise<any>;
244
+ repayIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<any>;
245
+ repayCrossMargin(code: string, amount: any, params?: {}): Promise<any>;
244
246
  parseMarginLoan(info: any, currency?: Currency): {
245
- id: number;
247
+ id: string;
246
248
  currency: string;
247
249
  amount: any;
248
250
  symbol: any;