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
@@ -31,7 +31,8 @@ class bitmart extends bitmart$1 {
31
31
  'swap': true,
32
32
  'future': false,
33
33
  'option': false,
34
- 'borrowMargin': true,
34
+ 'borrowCrossMargin': false,
35
+ 'borrowIsolatedMargin': true,
35
36
  'cancelAllOrders': true,
36
37
  'cancelOrder': true,
37
38
  'cancelOrders': false,
@@ -93,7 +94,8 @@ class bitmart extends bitmart$1 {
93
94
  'fetchWithdrawal': true,
94
95
  'fetchWithdrawals': true,
95
96
  'reduceMargin': false,
96
- 'repayMargin': true,
97
+ 'repayCrossMargin': false,
98
+ 'repayIsolatedMargin': true,
97
99
  'setLeverage': true,
98
100
  'setMarginMode': false,
99
101
  'transfer': true,
@@ -3197,22 +3199,18 @@ class bitmart extends bitmart$1 {
3197
3199
  'fee': fee,
3198
3200
  };
3199
3201
  }
3200
- async repayMargin(code, amount, symbol = undefined, params = {}) {
3202
+ async repayIsolatedMargin(symbol, code, amount, params = {}) {
3201
3203
  /**
3202
3204
  * @method
3203
- * @name bitmart#repayMargin
3205
+ * @name bitmart#repayIsolatedMargin
3204
3206
  * @description repay borrowed margin and interest
3205
3207
  * @see https://developer-pro.bitmart.com/en/spot/#margin-repay-isolated
3208
+ * @param {string} symbol unified market symbol
3206
3209
  * @param {string} code unified currency code of the currency to repay
3207
3210
  * @param {string} amount the amount to repay
3208
- * @param {string} symbol unified market symbol
3209
3211
  * @param {object} [params] extra parameters specific to the bitmart api endpoint
3210
- * @param {string} [params.marginMode] 'isolated' is the default and 'cross' is unavailable
3211
3212
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
3212
3213
  */
3213
- if (symbol === undefined) {
3214
- throw new errors.ArgumentsRequired(this.id + ' repayMargin() requires a symbol argument');
3215
- }
3216
3214
  await this.loadMarkets();
3217
3215
  const market = this.market(symbol);
3218
3216
  const currency = this.currency(code);
@@ -3221,7 +3219,6 @@ class bitmart extends bitmart$1 {
3221
3219
  'currency': currency['id'],
3222
3220
  'amount': this.currencyToPrecision(code, amount),
3223
3221
  };
3224
- params = this.omit(params, 'marginMode');
3225
3222
  const response = await this.privatePostSpotV1MarginIsolatedRepay(this.extend(request, params));
3226
3223
  //
3227
3224
  // {
@@ -3240,22 +3237,18 @@ class bitmart extends bitmart$1 {
3240
3237
  'symbol': symbol,
3241
3238
  });
3242
3239
  }
3243
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
3240
+ async borrowIsolatedMargin(symbol, code, amount, params = {}) {
3244
3241
  /**
3245
3242
  * @method
3246
- * @name bitmart#borrowMargin
3243
+ * @name bitmart#borrowIsolatedMargin
3247
3244
  * @description create a loan to borrow margin
3248
3245
  * @see https://developer-pro.bitmart.com/en/spot/#margin-borrow-isolated
3246
+ * @param {string} symbol unified market symbol
3249
3247
  * @param {string} code unified currency code of the currency to borrow
3250
3248
  * @param {string} amount the amount to borrow
3251
- * @param {string} symbol unified market symbol
3252
3249
  * @param {object} [params] extra parameters specific to the bitmart api endpoint
3253
- * @param {string} [params.marginMode] 'isolated' is the default and 'cross' is unavailable
3254
3250
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
3255
3251
  */
3256
- if (symbol === undefined) {
3257
- throw new errors.ArgumentsRequired(this.id + ' borrowMargin() requires a symbol argument');
3258
- }
3259
3252
  await this.loadMarkets();
3260
3253
  const market = this.market(symbol);
3261
3254
  const currency = this.currency(code);
@@ -3264,7 +3257,6 @@ class bitmart extends bitmart$1 {
3264
3257
  'currency': currency['id'],
3265
3258
  'amount': this.currencyToPrecision(code, amount),
3266
3259
  };
3267
- params = this.omit(params, 'marginMode');
3268
3260
  const response = await this.privatePostSpotV1MarginIsolatedBorrow(this.extend(request, params));
3269
3261
  //
3270
3262
  // {
@@ -93,7 +93,7 @@ class bitrue extends bitrue$1 {
93
93
  'kline': 'https://www.bitrue.com/kline-api',
94
94
  },
95
95
  'www': 'https://www.bitrue.com',
96
- 'referral': 'https://www.bitrue.com/activity/task/task-landing?inviteCode=EZWETQE&cn=900000',
96
+ 'referral': 'https://www.bitrue.com/affiliate/landing?cn=600000&inviteCode=EZWETQE',
97
97
  'doc': [
98
98
  'https://github.com/Bitrue-exchange/bitrue-official-api-docs',
99
99
  ],
@@ -32,6 +32,7 @@ class bybit extends bybit$1 {
32
32
  'swap': true,
33
33
  'future': true,
34
34
  'option': true,
35
+ 'borrowCrossMargin': true,
35
36
  'cancelAllOrders': true,
36
37
  'cancelOrder': true,
37
38
  'createOrder': true,
@@ -94,6 +95,7 @@ class bybit extends bybit$1 {
94
95
  'fetchUnderlyingAssets': false,
95
96
  'fetchVolatilityHistory': true,
96
97
  'fetchWithdrawals': true,
98
+ 'repayCrossMargin': true,
97
99
  'setLeverage': true,
98
100
  'setMarginMode': true,
99
101
  'setPositionMode': true,
@@ -3431,7 +3433,9 @@ class bybit extends bybit$1 {
3431
3433
  const result = await this.fetchOrders(symbol, undefined, undefined, this.extend(request, params));
3432
3434
  const length = result.length;
3433
3435
  if (length === 0) {
3434
- throw new errors.OrderNotFound('Order ' + id.toString() + ' does not exist.');
3436
+ const isTrigger = this.safeValueN(params, ['trigger', 'stop'], false);
3437
+ const extra = isTrigger ? '' : 'If you are trying to fetch SL/TP conditional order, you might try setting params["trigger"] = true';
3438
+ throw new errors.OrderNotFound('Order ' + id.toString() + ' was not found.' + extra);
3435
3439
  }
3436
3440
  if (length > 1) {
3437
3441
  throw new errors.InvalidOrder(this.id + ' returned more than one order');
@@ -3457,7 +3461,7 @@ class bybit extends bybit$1 {
3457
3461
  * @param {boolean} [params.isLeverage] *unified spot only* false then spot trading true then margin trading
3458
3462
  * @param {string} [params.tpslMode] *contract only* 'full' or 'partial'
3459
3463
  * @param {string} [params.mmp] *option only* market maker protection
3460
- * @param {string} [params.triggerDirection] *contract only* the direction for trigger orders, 'up' or 'down'
3464
+ * @param {string} [params.triggerDirection] *contract only* the direction for trigger orders, 'above' or 'below'
3461
3465
  * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
3462
3466
  * @param {float} [params.stopLossPrice] The price at which a stop loss order is triggered at
3463
3467
  * @param {float} [params.takeProfitPrice] The price at which a take profit order is triggered at
@@ -3589,21 +3593,30 @@ class bybit extends bybit$1 {
3589
3593
  const isStopLoss = stopLoss !== undefined;
3590
3594
  const isTakeProfit = takeProfit !== undefined;
3591
3595
  const isBuy = side === 'buy';
3592
- const setTriggerDirection = (stopLossTriggerPrice || triggerPrice) ? !isBuy : isBuy;
3593
- const defaultTriggerDirection = setTriggerDirection ? 2 : 1;
3594
- const triggerDirection = this.safeString(params, 'triggerDirection');
3595
- params = this.omit(params, 'triggerDirection');
3596
- let selectedDirection = defaultTriggerDirection;
3597
- if (triggerDirection !== undefined) {
3598
- const isAsending = ((triggerDirection === 'up') || (triggerDirection === '1'));
3599
- selectedDirection = isAsending ? 1 : 2;
3600
- }
3601
3596
  if (triggerPrice !== undefined) {
3602
- request['triggerDirection'] = selectedDirection;
3597
+ const triggerDirection = this.safeString(params, 'triggerDirection');
3598
+ params = this.omit(params, ['triggerPrice', 'stopPrice', 'triggerDirection']);
3599
+ if (market['spot']) {
3600
+ if (triggerDirection !== undefined) {
3601
+ throw new errors.NotSupported(this.id + ' createOrder() : trigger order does not support triggerDirection for spot markets yet');
3602
+ }
3603
+ }
3604
+ else {
3605
+ if (triggerDirection === undefined) {
3606
+ throw new errors.ArgumentsRequired(this.id + ' stop/trigger orders require a triggerDirection parameter, either "above" or "below" to determine the direction of the trigger.');
3607
+ }
3608
+ const isAsending = ((triggerDirection === 'above') || (triggerDirection === '1'));
3609
+ request['triggerDirection'] = isAsending ? 1 : 2;
3610
+ }
3603
3611
  request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
3604
3612
  }
3605
3613
  else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
3606
- request['triggerDirection'] = selectedDirection;
3614
+ if (isBuy) {
3615
+ request['triggerDirection'] = isStopLossTriggerOrder ? 1 : 2;
3616
+ }
3617
+ else {
3618
+ request['triggerDirection'] = isStopLossTriggerOrder ? 2 : 1;
3619
+ }
3607
3620
  triggerPrice = isStopLossTriggerOrder ? stopLossTriggerPrice : takeProfitTriggerPrice;
3608
3621
  request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
3609
3622
  request['reduceOnly'] = true;
@@ -4403,8 +4416,8 @@ class bybit extends bybit$1 {
4403
4416
  return await this.fetchUsdcOrders(symbol, since, limit, params);
4404
4417
  }
4405
4418
  request['category'] = type;
4406
- const isStop = this.safeValue(params, 'stop', false);
4407
- params = this.omit(params, ['stop']);
4419
+ const isStop = this.safeValueN(params, ['trigger', 'stop'], false);
4420
+ params = this.omit(params, ['trigger', 'stop']);
4408
4421
  if (isStop) {
4409
4422
  if (type === 'spot') {
4410
4423
  request['orderFilter'] = 'tpslOrder';
@@ -6607,29 +6620,24 @@ class bybit extends bybit$1 {
6607
6620
  const data = this.addPaginationCursorToResult(response);
6608
6621
  return this.parseTransfers(data, currency, since, limit);
6609
6622
  }
6610
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
6623
+ async borrowCrossMargin(code, amount, params = {}) {
6611
6624
  /**
6612
6625
  * @method
6613
- * @name bybit#borrowMargin
6626
+ * @name bybit#borrowCrossMargin
6614
6627
  * @description create a loan to borrow margin
6615
6628
  * @see https://bybit-exchange.github.io/docs/v5/spot-margin-normal/borrow
6616
6629
  * @param {string} code unified currency code of the currency to borrow
6617
6630
  * @param {float} amount the amount to borrow
6618
- * @param {string} symbol not used by bybit.borrowMargin ()
6619
6631
  * @param {object} [params] extra parameters specific to the bybit api endpoint
6620
6632
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6621
6633
  */
6622
6634
  await this.loadMarkets();
6623
6635
  const currency = this.currency(code);
6624
- const [marginMode, query] = this.handleMarginModeAndParams('borrowMargin', params);
6625
- if (marginMode === 'isolated') {
6626
- throw new errors.NotSupported(this.id + ' borrowMargin () cannot use isolated margin');
6627
- }
6628
6636
  const request = {
6629
6637
  'coin': currency['id'],
6630
6638
  'qty': this.currencyToPrecision(code, amount),
6631
6639
  };
6632
- const response = await this.privatePostV5SpotCrossMarginTradeLoan(this.extend(request, query));
6640
+ const response = await this.privatePostV5SpotCrossMarginTradeLoan(this.extend(request, params));
6633
6641
  //
6634
6642
  // {
6635
6643
  // "retCode": 0,
@@ -6644,33 +6652,28 @@ class bybit extends bybit$1 {
6644
6652
  const result = this.safeValue(response, 'result', {});
6645
6653
  const transaction = this.parseMarginLoan(result, currency);
6646
6654
  return this.extend(transaction, {
6647
- 'symbol': symbol,
6655
+ 'symbol': undefined,
6648
6656
  'amount': amount,
6649
6657
  });
6650
6658
  }
6651
- async repayMargin(code, amount, symbol = undefined, params = {}) {
6659
+ async repayCrossMargin(code, amount, params = {}) {
6652
6660
  /**
6653
6661
  * @method
6654
- * @name bybit#repayMargin
6662
+ * @name bybit#repayCrossMargin
6655
6663
  * @description repay borrowed margin and interest
6656
6664
  * @see https://bybit-exchange.github.io/docs/v5/spot-margin-normal/repay
6657
6665
  * @param {string} code unified currency code of the currency to repay
6658
6666
  * @param {float} amount the amount to repay
6659
- * @param {string} symbol not used by bybit.repayMargin ()
6660
6667
  * @param {object} [params] extra parameters specific to the bybit api endpoint
6661
6668
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
6662
6669
  */
6663
6670
  await this.loadMarkets();
6664
6671
  const currency = this.currency(code);
6665
- const [marginMode, query] = this.handleMarginModeAndParams('repayMargin', params);
6666
- if (marginMode === 'isolated') {
6667
- throw new errors.NotSupported(this.id + ' repayMargin () cannot use isolated margin');
6668
- }
6669
6672
  const request = {
6670
6673
  'coin': currency['id'],
6671
6674
  'qty': this.numberToString(amount),
6672
6675
  };
6673
- const response = await this.privatePostV5SpotCrossMarginTradeRepay(this.extend(request, query));
6676
+ const response = await this.privatePostV5SpotCrossMarginTradeRepay(this.extend(request, params));
6674
6677
  //
6675
6678
  // {
6676
6679
  // "retCode": 0,
@@ -6685,7 +6688,7 @@ class bybit extends bybit$1 {
6685
6688
  const result = this.safeValue(response, 'result', {});
6686
6689
  const transaction = this.parseMarginLoan(result, currency);
6687
6690
  return this.extend(transaction, {
6688
- 'symbol': symbol,
6691
+ 'symbol': undefined,
6689
6692
  'amount': amount,
6690
6693
  });
6691
6694
  }
@@ -231,6 +231,7 @@ class coinbasepro extends coinbasepro$1 {
231
231
  * @method
232
232
  * @name coinbasepro#fetchCurrencies
233
233
  * @description fetches all available currencies on an exchange
234
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getcurrencies
234
235
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
235
236
  * @returns {object} an associative dictionary of currencies
236
237
  */
@@ -301,6 +302,7 @@ class coinbasepro extends coinbasepro$1 {
301
302
  * @method
302
303
  * @name coinbasepro#fetchMarkets
303
304
  * @description retrieves data on all markets for coinbasepro
305
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproducts
304
306
  * @param {object} [params] extra parameters specific to the exchange api endpoint
305
307
  * @returns {object[]} an array of objects representing market data
306
308
  */
@@ -421,6 +423,7 @@ class coinbasepro extends coinbasepro$1 {
421
423
  * @method
422
424
  * @name coinbasepro#fetchAccounts
423
425
  * @description fetch all the accounts associated with a profile
426
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounts
424
427
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
425
428
  * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
426
429
  */
@@ -486,6 +489,7 @@ class coinbasepro extends coinbasepro$1 {
486
489
  * @method
487
490
  * @name coinbasepro#fetchBalance
488
491
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
492
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounts
489
493
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
490
494
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
491
495
  */
@@ -618,6 +622,7 @@ class coinbasepro extends coinbasepro$1 {
618
622
  * @method
619
623
  * @name coinbasepro#fetchTickers
620
624
  * @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
625
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproduct
621
626
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
622
627
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
623
628
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -853,6 +858,7 @@ class coinbasepro extends coinbasepro$1 {
853
858
  * @method
854
859
  * @name coinbasepro#fetchTradingFees
855
860
  * @description fetch the trading fees for multiple markets
861
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getfees
856
862
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
857
863
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
858
864
  */
@@ -1351,6 +1357,8 @@ class coinbasepro extends coinbasepro$1 {
1351
1357
  * @method
1352
1358
  * @name coinbasepro#deposit
1353
1359
  * @description Creates a new deposit address, as required by coinbasepro
1360
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postdepositpaymentmethod
1361
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postdepositcoinbaseaccount
1354
1362
  * @param {string} code Unified CCXT currency code (e.g. `"USDT"`)
1355
1363
  * @param {float} amount The amount of currency to send in the deposit (e.g. `20`)
1356
1364
  * @param {string} address Not used by coinbasepro
@@ -1392,6 +1400,8 @@ class coinbasepro extends coinbasepro$1 {
1392
1400
  * @method
1393
1401
  * @name coinbasepro#withdraw
1394
1402
  * @description make a withdrawal
1403
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postwithdrawpaymentmethod
1404
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postwithdrawcoinbaseaccount
1395
1405
  * @param {string} code unified currency code
1396
1406
  * @param {float} amount the amount to withdraw
1397
1407
  * @param {string} address the address to withdraw to
@@ -1675,6 +1685,8 @@ class coinbasepro extends coinbasepro$1 {
1675
1685
  * @method
1676
1686
  * @name coinbasepro#fetchDeposits
1677
1687
  * @description fetch all deposits made to an account
1688
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
1689
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounttransfers
1678
1690
  * @param {string} code unified currency code
1679
1691
  * @param {int} [since] the earliest time in ms to fetch deposits for
1680
1692
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -1688,6 +1700,8 @@ class coinbasepro extends coinbasepro$1 {
1688
1700
  * @method
1689
1701
  * @name coinbasepro#fetchWithdrawals
1690
1702
  * @description fetch all withdrawals made from an account
1703
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_gettransfers
1704
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getaccounttransfers
1691
1705
  * @param {string} code unified currency code
1692
1706
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
1693
1707
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -1798,6 +1812,7 @@ class coinbasepro extends coinbasepro$1 {
1798
1812
  * @method
1799
1813
  * @name coinbasepro#createDepositAddress
1800
1814
  * @description create a currency deposit address
1815
+ * @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postcoinbaseaccountaddresses
1801
1816
  * @param {string} code unified currency code of the currency for the deposit address
1802
1817
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
1803
1818
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
@@ -38,7 +38,8 @@ class coinex extends coinex$1 {
38
38
  'future': false,
39
39
  'option': false,
40
40
  'addMargin': true,
41
- 'borrowMargin': true,
41
+ 'borrowCrossMargin': false,
42
+ 'borrowIsolatedMargin': true,
42
43
  'cancelAllOrders': true,
43
44
  'cancelOrder': true,
44
45
  'createDepositAddress': true,
@@ -91,7 +92,8 @@ class coinex extends coinex$1 {
91
92
  'fetchWithdrawal': false,
92
93
  'fetchWithdrawals': true,
93
94
  'reduceMargin': true,
94
- 'repayMargin': true,
95
+ 'repayCrossMargin': false,
96
+ 'repayIsolatedMargin': true,
95
97
  'setLeverage': true,
96
98
  'setMarginMode': true,
97
99
  'setPositionMode': false,
@@ -3256,16 +3258,19 @@ class coinex extends coinex$1 {
3256
3258
  const maintenanceMargin = this.safeString(position, 'mainten_margin_amount');
3257
3259
  const maintenanceMarginPercentage = this.safeString(position, 'mainten_margin');
3258
3260
  const collateral = this.safeString(position, 'margin_amount');
3259
- const leverage = this.safeNumber(position, 'leverage');
3261
+ const leverage = this.safeString(position, 'leverage');
3262
+ const notional = this.safeString(position, 'open_val');
3263
+ const initialMargin = Precise["default"].stringDiv(notional, leverage);
3264
+ const initialMarginPercentage = Precise["default"].stringDiv('1', leverage);
3260
3265
  return this.safePosition({
3261
3266
  'info': position,
3262
3267
  'id': positionId,
3263
3268
  'symbol': symbol,
3264
- 'notional': undefined,
3269
+ 'notional': this.parseNumber(notional),
3265
3270
  'marginMode': marginMode,
3266
3271
  'liquidationPrice': liquidationPrice,
3267
- 'entryPrice': entryPrice,
3268
- 'unrealizedPnl': unrealizedPnl,
3272
+ 'entryPrice': this.parseNumber(entryPrice),
3273
+ 'unrealizedPnl': this.parseNumber(unrealizedPnl),
3269
3274
  'percentage': undefined,
3270
3275
  'contracts': contracts,
3271
3276
  'contractSize': this.safeNumber(market, 'contractSize'),
@@ -3276,15 +3281,15 @@ class coinex extends coinex$1 {
3276
3281
  'timestamp': timestamp,
3277
3282
  'datetime': this.iso8601(timestamp),
3278
3283
  'lastUpdateTimestamp': undefined,
3279
- 'maintenanceMargin': maintenanceMargin,
3280
- 'maintenanceMarginPercentage': maintenanceMarginPercentage,
3281
- 'collateral': collateral,
3282
- 'initialMargin': undefined,
3283
- 'initialMarginPercentage': undefined,
3284
- 'leverage': leverage,
3284
+ 'maintenanceMargin': this.parseNumber(maintenanceMargin),
3285
+ 'maintenanceMarginPercentage': this.parseNumber(maintenanceMarginPercentage),
3286
+ 'collateral': this.parseNumber(collateral),
3287
+ 'initialMargin': this.parseNumber(initialMargin),
3288
+ 'initialMarginPercentage': this.parseNumber(initialMarginPercentage),
3289
+ 'leverage': this.parseNumber(leverage),
3285
3290
  'marginRatio': undefined,
3286
- 'stopLossPrice': this.safeNumber(position, 'stop_loss_price'),
3287
- 'takeProfitPrice': this.safeNumber(position, 'take_profit_price'),
3291
+ 'stopLossPrice': this.omitZero(this.safeString(position, 'stop_loss_price')),
3292
+ 'takeProfitPrice': this.omitZero(this.safeString(position, 'take_profit_price')),
3288
3293
  });
3289
3294
  }
3290
3295
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
@@ -4603,21 +4608,18 @@ class coinex extends coinex$1 {
4603
4608
  'info': info,
4604
4609
  };
4605
4610
  }
4606
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
4611
+ async borrowIsolatedMargin(symbol, code, amount, params = {}) {
4607
4612
  /**
4608
4613
  * @method
4609
- * @name coinex#borrowMargin
4614
+ * @name coinex#borrowIsolatedMargin
4610
4615
  * @description create a loan to borrow margin
4611
4616
  * @see https://github.com/coinexcom/coinex_exchange_api/wiki/086margin_loan
4617
+ * @param {string} symbol unified market symbol, required for coinex
4612
4618
  * @param {string} code unified currency code of the currency to borrow
4613
4619
  * @param {float} amount the amount to borrow
4614
- * @param {string} symbol unified market symbol, required for coinex
4615
4620
  * @param {object} [params] extra parameters specific to the coinex api endpoint
4616
4621
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
4617
4622
  */
4618
- if (symbol === undefined) {
4619
- throw new errors.ArgumentsRequired(this.id + ' borrowMargin() requires a symbol argument');
4620
- }
4621
4623
  await this.loadMarkets();
4622
4624
  const market = this.market(symbol);
4623
4625
  const currency = this.currency(code);
@@ -4643,22 +4645,19 @@ class coinex extends coinex$1 {
4643
4645
  'symbol': symbol,
4644
4646
  });
4645
4647
  }
4646
- async repayMargin(code, amount, symbol = undefined, params = {}) {
4648
+ async repayIsolatedMargin(symbol, code, amount, params = {}) {
4647
4649
  /**
4648
4650
  * @method
4649
- * @name coinex#repayMargin
4651
+ * @name coinex#repayIsolatedMargin
4650
4652
  * @description repay borrowed margin and interest
4651
4653
  * @see https://github.com/coinexcom/coinex_exchange_api/wiki/087margin_flat
4654
+ * @param {string} symbol unified market symbol, required for coinex
4652
4655
  * @param {string} code unified currency code of the currency to repay
4653
4656
  * @param {float} amount the amount to repay
4654
- * @param {string} symbol unified market symbol, required for coinex
4655
4657
  * @param {object} [params] extra parameters specific to the coinex api endpoint
4656
4658
  * @param {string} [params.loan_id] extra parameter that is not required
4657
4659
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
4658
4660
  */
4659
- if (symbol === undefined) {
4660
- throw new errors.ArgumentsRequired(this.id + ' repayMargin() requires a symbol argument');
4661
- }
4662
4661
  await this.loadMarkets();
4663
4662
  const market = this.market(symbol);
4664
4663
  const currency = this.currency(code);
@@ -4667,10 +4666,6 @@ class coinex extends coinex$1 {
4667
4666
  'coin_type': currency['id'],
4668
4667
  'amount': this.currencyToPrecision(code, amount),
4669
4668
  };
4670
- const loanId = this.safeInteger(params, 'loan_id');
4671
- if (loanId !== undefined) {
4672
- request['loan_id'] = loanId;
4673
- }
4674
4669
  const response = await this.privatePostMarginFlat(this.extend(request, params));
4675
4670
  //
4676
4671
  // {