ccxt 4.1.61 → 4.1.63

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.
@@ -74,7 +74,6 @@ class gate extends gate$1 {
74
74
  'future': true,
75
75
  'option': true,
76
76
  'addMargin': true,
77
- 'borrowMargin': true,
78
77
  'cancelAllOrders': true,
79
78
  'cancelOrder': true,
80
79
  'createMarketOrder': true,
@@ -139,7 +138,6 @@ class gate extends gate$1 {
139
138
  'fetchVolatilityHistory': false,
140
139
  'fetchWithdrawals': true,
141
140
  'reduceMargin': true,
142
- 'repayMargin': true,
143
141
  'setLeverage': true,
144
142
  'setMarginMode': false,
145
143
  'setPositionMode': true,
@@ -5564,220 +5562,6 @@ class gate extends gate$1 {
5564
5562
  }
5565
5563
  return tiers;
5566
5564
  }
5567
- async repayMargin(code, amount, symbol = undefined, params = {}) {
5568
- /**
5569
- * @method
5570
- * @name gate#repayMargin
5571
- * @description repay borrowed margin and interest
5572
- * @see https://www.gate.io/docs/apiv4/en/#repay-cross-margin-loan
5573
- * @see https://www.gate.io/docs/apiv4/en/#repay-a-loan
5574
- * @param {string} code unified currency code of the currency to repay
5575
- * @param {float} amount the amount to repay
5576
- * @param {string} symbol unified market symbol, required for isolated margin
5577
- * @param {object} [params] extra parameters specific to the gate api endpoint
5578
- * @param {string} [params.mode] 'all' or 'partial' payment mode, extra parameter required for isolated margin
5579
- * @param {string} [params.id] '34267567' loan id, extra parameter required for isolated margin
5580
- * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
5581
- */
5582
- const marginMode = this.safeString(params, 'marginMode'); // cross or isolated
5583
- params = this.omit(params, 'marginMode');
5584
- this.checkRequiredMarginArgument('repayMargin', symbol, marginMode);
5585
- await this.loadMarkets();
5586
- const currency = this.currency(code);
5587
- const request = {
5588
- 'currency': currency['id'],
5589
- 'amount': this.currencyToPrecision(code, amount),
5590
- };
5591
- let response = undefined;
5592
- params = this.omit(params, ['marginMode']);
5593
- if (symbol === undefined) {
5594
- response = await this.privateMarginPostCrossRepayments(this.extend(request, params));
5595
- }
5596
- else {
5597
- const market = this.market(symbol);
5598
- request['currency_pair'] = market['id'];
5599
- request['mode'] = 'partial';
5600
- const loanId = this.safeString2(params, 'loan_id', 'id');
5601
- if (loanId === undefined) {
5602
- throw new errors.ArgumentsRequired(this.id + ' repayMargin() requires loan_id param for isolated margin');
5603
- }
5604
- request['loan_id'] = loanId;
5605
- params = this.omit(params, ['loan_id', 'id']);
5606
- response = await this.privateMarginPostLoansLoanIdRepayment(this.extend(request, params));
5607
- }
5608
- //
5609
- // Cross
5610
- //
5611
- // [
5612
- // {
5613
- // "id": "17",
5614
- // "create_time": 1620381696159,
5615
- // "update_time": 1620381696159,
5616
- // "currency": "EOS",
5617
- // "amount": "110.553635",
5618
- // "text": "web",
5619
- // "status": 2,
5620
- // "repaid": "110.506649705159",
5621
- // "repaid_interest": "0.046985294841",
5622
- // "unpaid_interest": "0.0000074393366667"
5623
- // }
5624
- // ]
5625
- //
5626
- // Isolated
5627
- //
5628
- // {
5629
- // "id": "34267567",
5630
- // "create_time": "1656394778",
5631
- // "expire_time": "1657258778",
5632
- // "status": "finished",
5633
- // "side": "borrow",
5634
- // "currency": "USDT",
5635
- // "rate": "0.0002",
5636
- // "amount": "100",
5637
- // "days": 10,
5638
- // "auto_renew": false,
5639
- // "currency_pair": "LTC_USDT",
5640
- // "left": "0",
5641
- // "repaid": "100",
5642
- // "paid_interest": "0.003333333333",
5643
- // "unpaid_interest": "0"
5644
- // }
5645
- //
5646
- if (marginMode === 'cross') {
5647
- response = response[0];
5648
- }
5649
- return this.parseMarginLoan(response, currency);
5650
- }
5651
- async borrowMargin(code, amount, symbol = undefined, params = {}) {
5652
- /**
5653
- * @method
5654
- * @name gate#borrowMargin
5655
- * @description create a loan to borrow margin
5656
- * @see https://www.gate.io/docs/apiv4/en/#create-a-cross-margin-borrow-loan
5657
- * @see https://www.gate.io/docs/apiv4/en/#lend-or-borrow
5658
- * @param {string} code unified currency code of the currency to borrow
5659
- * @param {float} amount the amount to borrow
5660
- * @param {string} symbol unified market symbol, required for isolated margin
5661
- * @param {object} [params] extra parameters specific to the gate api endpoint
5662
- * @param {string} [params.rate] '0.0002' or '0.002' extra parameter required for isolated margin
5663
- * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
5664
- */
5665
- const marginMode = this.safeString(params, 'marginMode'); // cross or isolated
5666
- params = this.omit(params, 'marginMode');
5667
- this.checkRequiredMarginArgument('borrowMargin', symbol, marginMode);
5668
- await this.loadMarkets();
5669
- const currency = this.currency(code);
5670
- const request = {
5671
- 'currency': currency['id'],
5672
- 'amount': this.currencyToPrecision(code, amount),
5673
- };
5674
- let response = undefined;
5675
- if (symbol === undefined) {
5676
- response = await this.privateMarginPostCrossLoans(this.extend(request, params));
5677
- }
5678
- else {
5679
- const market = this.market(symbol);
5680
- request['currency_pair'] = market['id'];
5681
- request['side'] = 'borrow';
5682
- // default it to 0.01% since this is a reasonable limit
5683
- // as it is the smallest tick size currently offered by gateio
5684
- request['rate'] = this.safeString(params, 'rate', '0.0001');
5685
- request['auto_renew'] = true;
5686
- params = this.omit(params, ['rate']);
5687
- response = await this.privateMarginPostLoans(this.extend(request, params));
5688
- }
5689
- //
5690
- // Cross
5691
- //
5692
- // {
5693
- // "id": "17",
5694
- // "create_time": 1620381696159,
5695
- // "update_time": 1620381696159,
5696
- // "currency": "EOS",
5697
- // "amount": "110.553635",
5698
- // "text": "web",
5699
- // "status": 2,
5700
- // "repaid": "110.506649705159",
5701
- // "repaid_interest": "0.046985294841",
5702
- // "unpaid_interest": "0.0000074393366667"
5703
- // }
5704
- //
5705
- // Isolated
5706
- //
5707
- // {
5708
- // "id": "34267567",
5709
- // "create_time": "1656394778",
5710
- // "expire_time": "1657258778",
5711
- // "status": "loaned",
5712
- // "side": "borrow",
5713
- // "currency": "USDT",
5714
- // "rate": "0.0002",
5715
- // "amount": "100",
5716
- // "days": 10,
5717
- // "auto_renew": false,
5718
- // "currency_pair": "LTC_USDT",
5719
- // "left": "0",
5720
- // "repaid": "0",
5721
- // "paid_interest": "0",
5722
- // "unpaid_interest": "0.003333333333"
5723
- // }
5724
- //
5725
- return this.parseMarginLoan(response, currency);
5726
- }
5727
- parseMarginLoan(info, currency = undefined) {
5728
- //
5729
- // Cross
5730
- //
5731
- // {
5732
- // "id": "17",
5733
- // "create_time": 1620381696159,
5734
- // "update_time": 1620381696159,
5735
- // "currency": "EOS",
5736
- // "amount": "110.553635",
5737
- // "text": "web",
5738
- // "status": 2,
5739
- // "repaid": "110.506649705159",
5740
- // "repaid_interest": "0.046985294841",
5741
- // "unpaid_interest": "0.0000074393366667"
5742
- // }
5743
- //
5744
- // Isolated
5745
- //
5746
- // {
5747
- // "id": "34267567",
5748
- // "create_time": "1656394778",
5749
- // "expire_time": "1657258778",
5750
- // "status": "loaned",
5751
- // "side": "borrow",
5752
- // "currency": "USDT",
5753
- // "rate": "0.0002",
5754
- // "amount": "100",
5755
- // "days": 10,
5756
- // "auto_renew": false,
5757
- // "currency_pair": "LTC_USDT",
5758
- // "left": "0",
5759
- // "repaid": "0",
5760
- // "paid_interest": "0",
5761
- // "unpaid_interest": "0.003333333333"
5762
- // }
5763
- //
5764
- const marginMode = this.safeString2(this.options, 'defaultMarginMode', 'marginMode', 'cross');
5765
- let timestamp = this.safeInteger(info, 'create_time');
5766
- if (marginMode === 'isolated') {
5767
- timestamp = this.safeTimestamp(info, 'create_time');
5768
- }
5769
- const currencyId = this.safeString(info, 'currency');
5770
- const marketId = this.safeString(info, 'currency_pair');
5771
- return {
5772
- 'id': this.safeInteger(info, 'id'),
5773
- 'currency': this.safeCurrencyCode(currencyId, currency),
5774
- 'amount': this.safeNumber(info, 'amount'),
5775
- 'symbol': this.safeSymbol(marketId, undefined, '_', 'margin'),
5776
- 'timestamp': timestamp,
5777
- 'datetime': this.iso8601(timestamp),
5778
- 'info': info,
5779
- };
5780
- }
5781
5565
  sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
5782
5566
  const authentication = api[0]; // public, private
5783
5567
  const type = api[1]; // spot, margin, future, delivery
@@ -96,12 +96,6 @@ class kucoinfutures extends kucoinfutures$1 {
96
96
  'futuresPublic': 'https://api-futures.kucoin.com',
97
97
  'webExchange': 'https://futures.kucoin.com/_api/web-front',
98
98
  },
99
- 'test': {
100
- 'public': 'https://openapi-sandbox.kucoin.com',
101
- 'private': 'https://openapi-sandbox.kucoin.com',
102
- 'futuresPrivate': 'https://api-sandbox-futures.kucoin.com',
103
- 'futuresPublic': 'https://api-sandbox-futures.kucoin.com',
104
- },
105
99
  },
106
100
  'requiredCredentials': {
107
101
  'apiKey': true,
@@ -326,6 +320,7 @@ class kucoinfutures extends kucoinfutures$1 {
326
320
  * @method
327
321
  * @name kucoinfutures#fetchStatus
328
322
  * @description the latest known information on the availability of the exchange API
323
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-service-status
329
324
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
330
325
  * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
331
326
  */
@@ -354,6 +349,7 @@ class kucoinfutures extends kucoinfutures$1 {
354
349
  * @method
355
350
  * @name kucoinfutures#fetchMarkets
356
351
  * @description retrieves data on all markets for kucoinfutures
352
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-symbols-list
357
353
  * @param {object} [params] extra parameters specific to the exchange api endpoint
358
354
  * @returns {object[]} an array of objects representing market data
359
355
  */
@@ -518,6 +514,7 @@ class kucoinfutures extends kucoinfutures$1 {
518
514
  * @method
519
515
  * @name kucoinfutures#fetchTime
520
516
  * @description fetches the current integer timestamp in milliseconds from the exchange server
517
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-server-time
521
518
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
522
519
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
523
520
  */
@@ -535,6 +532,7 @@ class kucoinfutures extends kucoinfutures$1 {
535
532
  * @method
536
533
  * @name kucoinfutures#fetchOHLCV
537
534
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
535
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-klines
538
536
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
539
537
  * @param {string} timeframe the length of time each candle represents
540
538
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -615,6 +613,7 @@ class kucoinfutures extends kucoinfutures$1 {
615
613
  * @method
616
614
  * @name kucoinfutures#fetchDepositAddress
617
615
  * @description fetch the deposit address for a currency associated with this account
616
+ * @see https://www.kucoin.com/docs/rest/funding/deposit/get-deposit-address
618
617
  * @param {string} code unified currency code
619
618
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
620
619
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
@@ -654,6 +653,7 @@ class kucoinfutures extends kucoinfutures$1 {
654
653
  * @method
655
654
  * @name kucoinfutures#fetchOrderBook
656
655
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
656
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-part-order-book-level-2
657
657
  * @param {string} symbol unified symbol of the market to fetch the order book for
658
658
  * @param {int} [limit] the maximum amount of order book entries to return
659
659
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
@@ -712,6 +712,7 @@ class kucoinfutures extends kucoinfutures$1 {
712
712
  * @method
713
713
  * @name kucoinfutures#fetchTicker
714
714
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
715
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-ticker
715
716
  * @param {string} symbol unified symbol of the market to fetch the ticker for
716
717
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
717
718
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -793,6 +794,7 @@ class kucoinfutures extends kucoinfutures$1 {
793
794
  * @method
794
795
  * @name kucoinfutures#fetchFundingHistory
795
796
  * @description fetch the history of funding payments paid and received on this account
797
+ * @see https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-funding-history
796
798
  * @param {string} symbol unified market symbol
797
799
  * @param {int} [since] the earliest time in ms to fetch funding history for
798
800
  * @param {int} [limit] the maximum number of funding history structures to retrieve
@@ -1229,6 +1231,7 @@ class kucoinfutures extends kucoinfutures$1 {
1229
1231
  * @method
1230
1232
  * @name kucoinfutures#cancelOrder
1231
1233
  * @description cancels an open order
1234
+ * @see https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-futures-order-by-orderid
1232
1235
  * @param {string} id order id
1233
1236
  * @param {string} symbol unified symbol of the market the order was made in
1234
1237
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
@@ -1256,6 +1259,8 @@ class kucoinfutures extends kucoinfutures$1 {
1256
1259
  * @method
1257
1260
  * @name kucoinfutures#cancelAllOrders
1258
1261
  * @description cancel all open orders
1262
+ * @see https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-multiple-futures-limit-orders
1263
+ * @see https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-multiple-futures-stop-orders
1259
1264
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
1260
1265
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
1261
1266
  * @param {object} [params.stop] When true, all the trigger orders will be cancelled
@@ -1267,8 +1272,14 @@ class kucoinfutures extends kucoinfutures$1 {
1267
1272
  request['symbol'] = this.marketId(symbol);
1268
1273
  }
1269
1274
  const stop = this.safeValue(params, 'stop');
1270
- const method = stop ? 'futuresPrivateDeleteStopOrders' : 'futuresPrivateDeleteOrders';
1271
- const response = await this[method](this.extend(request, params));
1275
+ params = this.omit(params, 'stop');
1276
+ let response = undefined;
1277
+ if (stop) {
1278
+ response = await this.futuresPrivateDeleteStopOrders(this.extend(request, params));
1279
+ }
1280
+ else {
1281
+ response = await this.futuresPrivateDeleteOrders(this.extend(request, params));
1282
+ }
1272
1283
  //
1273
1284
  // {
1274
1285
  // "code": "200000",
@@ -1286,6 +1297,7 @@ class kucoinfutures extends kucoinfutures$1 {
1286
1297
  * @method
1287
1298
  * @name kucoinfutures#addMargin
1288
1299
  * @description add margin
1300
+ * @see https://www.kucoin.com/docs/rest/futures-trading/positions/add-margin-manually
1289
1301
  * @param {string} symbol unified market symbol
1290
1302
  * @param {float} amount amount of margin to add
1291
1303
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
@@ -1469,8 +1481,13 @@ class kucoinfutures extends kucoinfutures$1 {
1469
1481
  if (until !== undefined) {
1470
1482
  request['endAt'] = until;
1471
1483
  }
1472
- const method = stop ? 'futuresPrivateGetStopOrders' : 'futuresPrivateGetOrders';
1473
- const response = await this[method](this.extend(request, params));
1484
+ let response = undefined;
1485
+ if (stop) {
1486
+ response = await this.futuresPrivateGetStopOrders(this.extend(request, params));
1487
+ }
1488
+ else {
1489
+ response = await this.futuresPrivateGetOrders(this.extend(request, params));
1490
+ }
1474
1491
  //
1475
1492
  // {
1476
1493
  // "code": "200000",
@@ -1562,20 +1579,20 @@ class kucoinfutures extends kucoinfutures$1 {
1562
1579
  */
1563
1580
  await this.loadMarkets();
1564
1581
  const request = {};
1565
- let method = 'futuresPrivateGetOrdersOrderId';
1582
+ let response = undefined;
1566
1583
  if (id === undefined) {
1567
1584
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
1568
1585
  if (clientOrderId === undefined) {
1569
1586
  throw new errors.InvalidOrder(this.id + ' fetchOrder() requires parameter id or params.clientOid');
1570
1587
  }
1571
1588
  request['clientOid'] = clientOrderId;
1572
- method = 'futuresPrivateGetOrdersByClientOid';
1573
1589
  params = this.omit(params, ['clientOid', 'clientOrderId']);
1590
+ response = await this.futuresPrivateGetOrdersByClientOid(this.extend(request, params));
1574
1591
  }
1575
1592
  else {
1576
1593
  request['orderId'] = id;
1594
+ response = await this.futuresPrivateGetOrdersOrderId(this.extend(request, params));
1577
1595
  }
1578
- const response = await this[method](this.extend(request, params));
1579
1596
  //
1580
1597
  // {
1581
1598
  // "code": "200000",
@@ -1740,6 +1757,7 @@ class kucoinfutures extends kucoinfutures$1 {
1740
1757
  * @method
1741
1758
  * @name kucoinfutures#fetchFundingRate
1742
1759
  * @description fetch the current funding rate
1760
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-current-funding-rate
1743
1761
  * @param {string} symbol unified market symbol
1744
1762
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
1745
1763
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
@@ -1805,6 +1823,7 @@ class kucoinfutures extends kucoinfutures$1 {
1805
1823
  * @method
1806
1824
  * @name kucoinfutures#fetchBalance
1807
1825
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
1826
+ * @see https://www.kucoin.com/docs/rest/funding/funding-overview/get-account-detail-futures
1808
1827
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
1809
1828
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1810
1829
  */
@@ -1982,6 +2001,7 @@ class kucoinfutures extends kucoinfutures$1 {
1982
2001
  * @method
1983
2002
  * @name kucoinfutures#fetchTrades
1984
2003
  * @description get the list of most recent trades for a particular symbol
2004
+ * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-transaction-history
1985
2005
  * @param {string} symbol unified symbol of the market to fetch trades for
1986
2006
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
1987
2007
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -2264,6 +2284,7 @@ class kucoinfutures extends kucoinfutures$1 {
2264
2284
  * @method
2265
2285
  * @name kucoinfutures#fetchMarketLeverageTiers
2266
2286
  * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes for a single market
2287
+ * @see https://www.kucoin.com/docs/rest/futures-trading/risk-limit/get-futures-risk-limit-level
2267
2288
  * @param {string} symbol unified market symbol
2268
2289
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
2269
2290
  * @returns {object} a [leverage tiers structure]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}