ccxt 4.4.22 → 4.4.24
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.
- package/README.md +6 -5
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +6 -1
- package/dist/cjs/src/abstract/coincatch.js +9 -0
- package/dist/cjs/src/base/Exchange.js +4 -3
- package/dist/cjs/src/binance.js +69 -44
- package/dist/cjs/src/bitfinex.js +4 -0
- package/dist/cjs/src/bitflyer.js +1 -0
- package/dist/cjs/src/bitrue.js +3 -0
- package/dist/cjs/src/bybit.js +43 -6
- package/dist/cjs/src/cex.js +4 -0
- package/dist/cjs/src/coinbase.js +1 -1
- package/dist/cjs/src/coinbaseexchange.js +3 -0
- package/dist/cjs/src/coincatch.js +5370 -0
- package/dist/cjs/src/coinex.js +63 -1
- package/dist/cjs/src/gate.js +195 -59
- package/dist/cjs/src/hyperliquid.js +1 -1
- package/dist/cjs/src/kucoin.js +18 -8
- package/dist/cjs/src/latoken.js +6 -0
- package/dist/cjs/src/mexc.js +1 -1
- package/dist/cjs/src/oceanex.js +2 -0
- package/dist/cjs/src/okcoin.js +1 -0
- package/dist/cjs/src/poloniex.js +5 -0
- package/dist/cjs/src/pro/coincatch.js +1554 -0
- package/dist/cjs/src/pro/kucoin.js +2 -1
- package/dist/cjs/src/pro/onetrading.js +2 -1
- package/dist/cjs/src/yobit.js +1 -1
- package/js/ccxt.d.ts +8 -2
- package/js/ccxt.js +6 -2
- package/js/src/abstract/binance.d.ts +21 -0
- package/js/src/abstract/binancecoinm.d.ts +21 -0
- package/js/src/abstract/binanceus.d.ts +21 -0
- package/js/src/abstract/binanceusdm.d.ts +21 -0
- package/js/src/abstract/coincatch.d.ts +97 -0
- package/js/src/abstract/coincatch.js +11 -0
- package/js/src/abstract/kucoin.d.ts +1 -0
- package/js/src/abstract/kucoinfutures.d.ts +1 -0
- package/js/src/base/Exchange.js +4 -3
- package/js/src/binance.js +69 -44
- package/js/src/bitfinex.js +4 -0
- package/js/src/bitflyer.js +1 -0
- package/js/src/bitrue.js +3 -0
- package/js/src/bybit.js +43 -6
- package/js/src/cex.js +4 -0
- package/js/src/coinbase.js +1 -1
- package/js/src/coinbaseexchange.js +3 -0
- package/js/src/coincatch.d.ts +130 -0
- package/js/src/coincatch.js +5371 -0
- package/js/src/coinex.d.ts +1 -0
- package/js/src/coinex.js +63 -1
- package/js/src/gate.d.ts +13 -1
- package/js/src/gate.js +195 -59
- package/js/src/hyperliquid.js +1 -1
- package/js/src/kucoin.js +18 -8
- package/js/src/latoken.js +6 -0
- package/js/src/mexc.js +1 -1
- package/js/src/oceanex.js +2 -0
- package/js/src/okcoin.js +1 -0
- package/js/src/poloniex.js +5 -0
- package/js/src/pro/coincatch.d.ts +57 -0
- package/js/src/pro/coincatch.js +1555 -0
- package/js/src/pro/kucoin.js +2 -1
- package/js/src/pro/onetrading.js +2 -1
- package/js/src/yobit.js +1 -1
- package/package.json +1 -1
package/dist/cjs/src/coinex.js
CHANGED
|
@@ -45,6 +45,8 @@ class coinex extends coinex$1 {
|
|
|
45
45
|
'cancelAllOrders': true,
|
|
46
46
|
'cancelOrder': true,
|
|
47
47
|
'cancelOrders': true,
|
|
48
|
+
'closeAllPositions': false,
|
|
49
|
+
'closePosition': true,
|
|
48
50
|
'createDepositAddress': true,
|
|
49
51
|
'createMarketBuyOrderWithCost': true,
|
|
50
52
|
'createMarketOrderWithCost': false,
|
|
@@ -1772,7 +1774,7 @@ class coinex extends coinex$1 {
|
|
|
1772
1774
|
// "stop_id": 117180138153
|
|
1773
1775
|
// }
|
|
1774
1776
|
//
|
|
1775
|
-
// Swap createOrder, createOrders, editOrder, cancelOrders, cancelOrder, fetchOpenOrders, fetchClosedOrders
|
|
1777
|
+
// Swap createOrder, createOrders, editOrder, cancelOrders, cancelOrder, fetchOpenOrders, fetchClosedOrders, closePosition
|
|
1776
1778
|
//
|
|
1777
1779
|
// {
|
|
1778
1780
|
// "amount": "0.0001",
|
|
@@ -5695,6 +5697,66 @@ class coinex extends coinex$1 {
|
|
|
5695
5697
|
const positions = this.parsePositions(records);
|
|
5696
5698
|
return this.filterBySymbolSinceLimit(positions, symbol, since, limit);
|
|
5697
5699
|
}
|
|
5700
|
+
async closePosition(symbol, side = undefined, params = {}) {
|
|
5701
|
+
/**
|
|
5702
|
+
* @method
|
|
5703
|
+
* @name coinex#closePosition
|
|
5704
|
+
* @description closes an open position for a market
|
|
5705
|
+
* @see https://docs.coinex.com/api/v2/futures/position/http/close-position
|
|
5706
|
+
* @param {string} symbol unified CCXT market symbol
|
|
5707
|
+
* @param {string} [side] buy or sell, not used by coinex
|
|
5708
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5709
|
+
* @param {string} params.type required by coinex, one of: limit, market, maker_only, ioc or fok, default is *market*
|
|
5710
|
+
* @param {string} [params.price] the price to fulfill the order, ignored in market orders
|
|
5711
|
+
* @param {string} [params.amount] the amount to trade in units of the base currency
|
|
5712
|
+
* @param {string} [params.clientOrderId] the client id of the order
|
|
5713
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5714
|
+
*/
|
|
5715
|
+
await this.loadMarkets();
|
|
5716
|
+
const market = this.market(symbol);
|
|
5717
|
+
const type = this.safeString(params, 'type', 'market');
|
|
5718
|
+
const request = {
|
|
5719
|
+
'market': market['id'],
|
|
5720
|
+
'market_type': 'FUTURES',
|
|
5721
|
+
'type': type,
|
|
5722
|
+
};
|
|
5723
|
+
const clientOrderId = this.safeString2(params, 'client_id', 'clientOrderId');
|
|
5724
|
+
if (clientOrderId !== undefined) {
|
|
5725
|
+
request['client_id'] = clientOrderId;
|
|
5726
|
+
}
|
|
5727
|
+
params = this.omit(params, 'clientOrderId');
|
|
5728
|
+
const response = await this.v2PrivatePostFuturesClosePosition(this.extend(request, params));
|
|
5729
|
+
//
|
|
5730
|
+
// {
|
|
5731
|
+
// "code": 0,
|
|
5732
|
+
// "data": {
|
|
5733
|
+
// "amount": "0.0001",
|
|
5734
|
+
// "client_id": "",
|
|
5735
|
+
// "created_at": 1729666043969,
|
|
5736
|
+
// "fee": "0.00335858",
|
|
5737
|
+
// "fee_ccy": "USDT",
|
|
5738
|
+
// "filled_amount": "0.0001",
|
|
5739
|
+
// "filled_value": "6.717179",
|
|
5740
|
+
// "last_filled_amount": "0.0001",
|
|
5741
|
+
// "last_filled_price": "67171.79",
|
|
5742
|
+
// "maker_fee_rate": "0",
|
|
5743
|
+
// "market": "BTCUSDT",
|
|
5744
|
+
// "market_type": "FUTURES",
|
|
5745
|
+
// "order_id": 155477479761,
|
|
5746
|
+
// "price": "0",
|
|
5747
|
+
// "realized_pnl": "-0.001823",
|
|
5748
|
+
// "side": "sell",
|
|
5749
|
+
// "taker_fee_rate": "0.0005",
|
|
5750
|
+
// "type": "market",
|
|
5751
|
+
// "unfilled_amount": "0",
|
|
5752
|
+
// "updated_at": 1729666043969
|
|
5753
|
+
// },
|
|
5754
|
+
// "message": "OK"
|
|
5755
|
+
// }
|
|
5756
|
+
//
|
|
5757
|
+
const data = this.safeDict(response, 'data', {});
|
|
5758
|
+
return this.parseOrder(data, market);
|
|
5759
|
+
}
|
|
5698
5760
|
handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
|
|
5699
5761
|
/**
|
|
5700
5762
|
* @ignore
|
package/dist/cjs/src/gate.js
CHANGED
|
@@ -99,6 +99,7 @@ class gate extends gate$1 {
|
|
|
99
99
|
'createTriggerOrder': true,
|
|
100
100
|
'editOrder': true,
|
|
101
101
|
'fetchBalance': true,
|
|
102
|
+
'fetchBorrowInterest': true,
|
|
102
103
|
'fetchBorrowRateHistories': false,
|
|
103
104
|
'fetchBorrowRateHistory': false,
|
|
104
105
|
'fetchClosedOrders': true,
|
|
@@ -1536,7 +1537,7 @@ class gate extends gate$1 {
|
|
|
1536
1537
|
}
|
|
1537
1538
|
return [request, query];
|
|
1538
1539
|
}
|
|
1539
|
-
multiOrderSpotPrepareRequest(market = undefined,
|
|
1540
|
+
multiOrderSpotPrepareRequest(market = undefined, trigger = false, params = {}) {
|
|
1540
1541
|
/**
|
|
1541
1542
|
* @ignore
|
|
1542
1543
|
* @method
|
|
@@ -1547,12 +1548,12 @@ class gate extends gate$1 {
|
|
|
1547
1548
|
* @param {object} [params] request parameters
|
|
1548
1549
|
* @returns the api request object, and the new params object with non-needed parameters removed
|
|
1549
1550
|
*/
|
|
1550
|
-
const [marginMode, query] = this.getMarginMode(
|
|
1551
|
+
const [marginMode, query] = this.getMarginMode(trigger, params);
|
|
1551
1552
|
const request = {
|
|
1552
1553
|
'account': marginMode,
|
|
1553
1554
|
};
|
|
1554
1555
|
if (market !== undefined) {
|
|
1555
|
-
if (
|
|
1556
|
+
if (trigger) {
|
|
1556
1557
|
// gate spot and margin stop orders use the term market instead of currency_pair, and normal instead of spot. Neither parameter is used when fetching/cancelling a single order. They are used for creating a single stop order, but createOrder does not call this method
|
|
1557
1558
|
request['market'] = market['id'];
|
|
1558
1559
|
}
|
|
@@ -1593,6 +1594,11 @@ class gate extends gate$1 {
|
|
|
1593
1594
|
throw new errors.BadRequest(this.id + ' getMarginMode() does not support stop orders for cross margin');
|
|
1594
1595
|
}
|
|
1595
1596
|
}
|
|
1597
|
+
let isUnifiedAccount = false;
|
|
1598
|
+
[isUnifiedAccount, params] = this.handleOptionAndParams(params, 'getMarginMode', 'unifiedAccount');
|
|
1599
|
+
if (isUnifiedAccount) {
|
|
1600
|
+
marginMode = 'unified';
|
|
1601
|
+
}
|
|
1596
1602
|
return [marginMode, params];
|
|
1597
1603
|
}
|
|
1598
1604
|
getSettlementCurrencies(type, method) {
|
|
@@ -3368,10 +3374,12 @@ class gate extends gate$1 {
|
|
|
3368
3374
|
* @param {int} [params.offset] *contract only* list offset, starting from 0
|
|
3369
3375
|
* @param {string} [params.last_id] *contract only* specify list staring point using the id of last record in previous list-query results
|
|
3370
3376
|
* @param {int} [params.count_total] *contract only* whether to return total number matched, default to 0(no return)
|
|
3371
|
-
* @param {
|
|
3377
|
+
* @param {bool} [params.unifiedAccount] set to true for fetching trades in a unified account
|
|
3378
|
+
* @param {bool} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
3372
3379
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
3373
3380
|
*/
|
|
3374
3381
|
await this.loadMarkets();
|
|
3382
|
+
await this.loadUnifiedStatus();
|
|
3375
3383
|
let paginate = false;
|
|
3376
3384
|
[paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
|
|
3377
3385
|
if (paginate) {
|
|
@@ -3929,9 +3937,11 @@ class gate extends gate$1 {
|
|
|
3929
3937
|
* @param {bool} [params.auto_size] *contract only* Set side to close dual-mode position, close_long closes the long side, while close_short the short one, size also needs to be set to 0
|
|
3930
3938
|
* @param {int} [params.price_type] *contract only* 0 latest deal price, 1 mark price, 2 index price
|
|
3931
3939
|
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
3940
|
+
* @param {bool} [params.unifiedAccount] set to true for creating an order in the unified account
|
|
3932
3941
|
* @returns {object|undefined} [An order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3933
3942
|
*/
|
|
3934
3943
|
await this.loadMarkets();
|
|
3944
|
+
await this.loadUnifiedStatus();
|
|
3935
3945
|
const market = this.market(symbol);
|
|
3936
3946
|
const trigger = this.safeValue(params, 'trigger');
|
|
3937
3947
|
const triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
|
|
@@ -4083,6 +4093,7 @@ class gate extends gate$1 {
|
|
|
4083
4093
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4084
4094
|
*/
|
|
4085
4095
|
await this.loadMarkets();
|
|
4096
|
+
await this.loadUnifiedStatus();
|
|
4086
4097
|
const ordersRequests = this.createOrdersRequest(orders, params);
|
|
4087
4098
|
const firstOrder = orders[0];
|
|
4088
4099
|
const market = this.market(firstOrder['symbol']);
|
|
@@ -4364,9 +4375,11 @@ class gate extends gate$1 {
|
|
|
4364
4375
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
4365
4376
|
* @param {float} cost how much you want to trade in units of the quote currency
|
|
4366
4377
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4378
|
+
* @param {bool} [params.unifiedAccount] set to true for creating a unified account order
|
|
4367
4379
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4368
4380
|
*/
|
|
4369
4381
|
await this.loadMarkets();
|
|
4382
|
+
await this.loadUnifiedStatus();
|
|
4370
4383
|
const market = this.market(symbol);
|
|
4371
4384
|
if (!market['spot']) {
|
|
4372
4385
|
throw new errors.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
@@ -4376,8 +4389,14 @@ class gate extends gate$1 {
|
|
|
4376
4389
|
}
|
|
4377
4390
|
editOrderRequest(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
4378
4391
|
const market = this.market(symbol);
|
|
4379
|
-
|
|
4380
|
-
|
|
4392
|
+
let marketType = undefined;
|
|
4393
|
+
[marketType, params] = this.handleMarketTypeAndParams('editOrder', market, params);
|
|
4394
|
+
let account = this.convertTypeToAccount(marketType);
|
|
4395
|
+
let isUnifiedAccount = false;
|
|
4396
|
+
[isUnifiedAccount, params] = this.handleOptionAndParams(params, 'editOrder', 'unifiedAccount');
|
|
4397
|
+
if (isUnifiedAccount) {
|
|
4398
|
+
account = 'unified';
|
|
4399
|
+
}
|
|
4381
4400
|
const isLimitOrder = (type === 'limit');
|
|
4382
4401
|
if (account === 'spot') {
|
|
4383
4402
|
if (!isLimitOrder) {
|
|
@@ -4409,7 +4428,7 @@ class gate extends gate$1 {
|
|
|
4409
4428
|
if (!market['spot']) {
|
|
4410
4429
|
request['settle'] = market['settleId'];
|
|
4411
4430
|
}
|
|
4412
|
-
return this.extend(request,
|
|
4431
|
+
return this.extend(request, params);
|
|
4413
4432
|
}
|
|
4414
4433
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
4415
4434
|
/**
|
|
@@ -4425,9 +4444,11 @@ class gate extends gate$1 {
|
|
|
4425
4444
|
* @param {float} amount how much of the currency you want to trade in units of the base currency
|
|
4426
4445
|
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
4427
4446
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4447
|
+
* @param {bool} [params.unifiedAccount] set to true for editing an order in a unified account
|
|
4428
4448
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4429
4449
|
*/
|
|
4430
4450
|
await this.loadMarkets();
|
|
4451
|
+
await this.loadUnifiedStatus();
|
|
4431
4452
|
const market = this.market(symbol);
|
|
4432
4453
|
const extendedRequest = this.editOrderRequest(id, symbol, type, side, amount, price, params);
|
|
4433
4454
|
let response = undefined;
|
|
@@ -4689,21 +4710,21 @@ class gate extends gate$1 {
|
|
|
4689
4710
|
// Everything below this(above return) is related to fees
|
|
4690
4711
|
const fees = [];
|
|
4691
4712
|
const gtFee = this.safeString(order, 'gt_fee');
|
|
4692
|
-
if (gtFee) {
|
|
4713
|
+
if (gtFee !== undefined) {
|
|
4693
4714
|
fees.push({
|
|
4694
4715
|
'currency': 'GT',
|
|
4695
4716
|
'cost': gtFee,
|
|
4696
4717
|
});
|
|
4697
4718
|
}
|
|
4698
4719
|
const fee = this.safeString(order, 'fee');
|
|
4699
|
-
if (fee) {
|
|
4720
|
+
if (fee !== undefined) {
|
|
4700
4721
|
fees.push({
|
|
4701
4722
|
'currency': this.safeCurrencyCode(this.safeString(order, 'fee_currency')),
|
|
4702
4723
|
'cost': fee,
|
|
4703
4724
|
});
|
|
4704
4725
|
}
|
|
4705
4726
|
const rebate = this.safeString(order, 'rebated_fee');
|
|
4706
|
-
if (rebate) {
|
|
4727
|
+
if (rebate !== undefined) {
|
|
4707
4728
|
fees.push({
|
|
4708
4729
|
'currency': this.safeCurrencyCode(this.safeString(order, 'rebated_fee_currency')),
|
|
4709
4730
|
'cost': Precise["default"].stringNeg(rebate),
|
|
@@ -4787,9 +4808,11 @@ class gate extends gate$1 {
|
|
|
4787
4808
|
* @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for margin trading if not provided this.options['defaultMarginMode'] is used
|
|
4788
4809
|
* @param {string} [params.type] 'spot', 'swap', or 'future', if not provided this.options['defaultMarginMode'] is used
|
|
4789
4810
|
* @param {string} [params.settle] 'btc' or 'usdt' - settle currency for perpetual swap and future - market settle currency is used if symbol !== undefined, default="usdt" for swap and "btc" for future
|
|
4811
|
+
* @param {bool} [params.unifiedAccount] set to true for fetching a unified account order
|
|
4790
4812
|
* @returns An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4791
4813
|
*/
|
|
4792
4814
|
await this.loadMarkets();
|
|
4815
|
+
await this.loadUnifiedStatus();
|
|
4793
4816
|
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
4794
4817
|
const result = this.handleMarketTypeAndParams('fetchOrder', market, params);
|
|
4795
4818
|
const type = this.safeString(result, 0);
|
|
@@ -4842,6 +4865,7 @@ class gate extends gate$1 {
|
|
|
4842
4865
|
* @param {bool} [params.stop] true for fetching stop orders
|
|
4843
4866
|
* @param {string} [params.type] spot, margin, swap or future, if not provided this.options['defaultType'] is used
|
|
4844
4867
|
* @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for type='margin', if not provided this.options['defaultMarginMode'] is used
|
|
4868
|
+
* @param {bool} [params.unifiedAccount] set to true for fetching unified account orders
|
|
4845
4869
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4846
4870
|
*/
|
|
4847
4871
|
return await this.fetchOrdersByStatus('open', symbol, since, limit, params);
|
|
@@ -4867,9 +4891,11 @@ class gate extends gate$1 {
|
|
|
4867
4891
|
* @param {string} [params.type] spot, swap or future, if not provided this.options['defaultType'] is used
|
|
4868
4892
|
* @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for margin trading if not provided this.options['defaultMarginMode'] is used
|
|
4869
4893
|
* @param {boolean} [params.historical] *swap only* true for using historical endpoint
|
|
4894
|
+
* @param {bool} [params.unifiedAccount] set to true for fetching unified account orders
|
|
4870
4895
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4871
4896
|
*/
|
|
4872
4897
|
await this.loadMarkets();
|
|
4898
|
+
await this.loadUnifiedStatus();
|
|
4873
4899
|
const until = this.safeInteger(params, 'until');
|
|
4874
4900
|
let market = undefined;
|
|
4875
4901
|
if (symbol !== undefined) {
|
|
@@ -4905,13 +4931,16 @@ class gate extends gate$1 {
|
|
|
4905
4931
|
market = this.market(symbol);
|
|
4906
4932
|
symbol = market['symbol'];
|
|
4907
4933
|
}
|
|
4908
|
-
|
|
4909
|
-
params = this.
|
|
4934
|
+
let trigger = undefined;
|
|
4935
|
+
[trigger, params] = this.handleParamBool2(params, 'trigger', 'stop');
|
|
4910
4936
|
let type = undefined;
|
|
4911
4937
|
[type, params] = this.handleMarketTypeAndParams('fetchOrdersByStatus', market, params);
|
|
4912
4938
|
const spot = (type === 'spot') || (type === 'margin');
|
|
4913
4939
|
let request = {};
|
|
4914
|
-
[request, params] = spot ? this.multiOrderSpotPrepareRequest(market,
|
|
4940
|
+
[request, params] = spot ? this.multiOrderSpotPrepareRequest(market, trigger, params) : this.prepareRequest(market, type, params);
|
|
4941
|
+
if (spot && trigger) {
|
|
4942
|
+
request = this.omit(request, 'account');
|
|
4943
|
+
}
|
|
4915
4944
|
if (status === 'closed') {
|
|
4916
4945
|
status = 'finished';
|
|
4917
4946
|
}
|
|
@@ -4937,33 +4966,36 @@ class gate extends gate$1 {
|
|
|
4937
4966
|
}
|
|
4938
4967
|
async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
4939
4968
|
await this.loadMarkets();
|
|
4969
|
+
await this.loadUnifiedStatus();
|
|
4940
4970
|
let market = undefined;
|
|
4941
4971
|
if (symbol !== undefined) {
|
|
4942
4972
|
market = this.market(symbol);
|
|
4943
4973
|
symbol = market['symbol'];
|
|
4944
4974
|
}
|
|
4945
|
-
|
|
4946
|
-
|
|
4975
|
+
// don't omit here, omits done in prepareOrdersByStatusRequest
|
|
4976
|
+
const trigger = this.safeBool2(params, 'trigger', 'stop');
|
|
4947
4977
|
const res = this.handleMarketTypeAndParams('fetchOrdersByStatus', market, params);
|
|
4948
4978
|
const type = this.safeString(res, 0);
|
|
4949
|
-
params['type'] = type;
|
|
4950
4979
|
const [request, requestParams] = this.prepareOrdersByStatusRequest(status, symbol, since, limit, params);
|
|
4951
4980
|
const spot = (type === 'spot') || (type === 'margin');
|
|
4952
|
-
const
|
|
4981
|
+
const openStatus = (status === 'open');
|
|
4982
|
+
const openSpotOrders = spot && openStatus && !trigger;
|
|
4953
4983
|
let response = undefined;
|
|
4954
|
-
if (
|
|
4955
|
-
if (
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4984
|
+
if (spot) {
|
|
4985
|
+
if (!trigger) {
|
|
4986
|
+
if (openStatus) {
|
|
4987
|
+
response = await this.privateSpotGetOpenOrders(this.extend(request, requestParams));
|
|
4988
|
+
}
|
|
4989
|
+
else {
|
|
4990
|
+
response = await this.privateSpotGetOrders(this.extend(request, requestParams));
|
|
4991
|
+
}
|
|
4960
4992
|
}
|
|
4961
4993
|
else {
|
|
4962
|
-
response = await this.
|
|
4994
|
+
response = await this.privateSpotGetPriceOrders(this.extend(request, requestParams));
|
|
4963
4995
|
}
|
|
4964
4996
|
}
|
|
4965
4997
|
else if (type === 'swap') {
|
|
4966
|
-
if (
|
|
4998
|
+
if (trigger) {
|
|
4967
4999
|
response = await this.privateFuturesGetSettlePriceOrders(this.extend(request, requestParams));
|
|
4968
5000
|
}
|
|
4969
5001
|
else {
|
|
@@ -4971,7 +5003,7 @@ class gate extends gate$1 {
|
|
|
4971
5003
|
}
|
|
4972
5004
|
}
|
|
4973
5005
|
else if (type === 'future') {
|
|
4974
|
-
if (
|
|
5006
|
+
if (trigger) {
|
|
4975
5007
|
response = await this.privateDeliveryGetSettlePriceOrders(this.extend(request, requestParams));
|
|
4976
5008
|
}
|
|
4977
5009
|
else {
|
|
@@ -5154,9 +5186,11 @@ class gate extends gate$1 {
|
|
|
5154
5186
|
* @param {string} symbol Unified market symbol
|
|
5155
5187
|
* @param {object} [params] Parameters specified by the exchange api
|
|
5156
5188
|
* @param {bool} [params.stop] True if the order to be cancelled is a trigger order
|
|
5189
|
+
* @param {bool} [params.unifiedAccount] set to true for canceling unified account orders
|
|
5157
5190
|
* @returns An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5158
5191
|
*/
|
|
5159
5192
|
await this.loadMarkets();
|
|
5193
|
+
await this.loadUnifiedStatus();
|
|
5160
5194
|
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
5161
5195
|
const stop = this.safeBoolN(params, ['is_stop_order', 'stop', 'trigger'], false);
|
|
5162
5196
|
params = this.omit(params, ['is_stop_order', 'stop', 'trigger']);
|
|
@@ -5287,9 +5321,11 @@ class gate extends gate$1 {
|
|
|
5287
5321
|
* @param {string[]} ids order ids
|
|
5288
5322
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
5289
5323
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5324
|
+
* @param {bool} [params.unifiedAccount] set to true for canceling unified account orders
|
|
5290
5325
|
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5291
5326
|
*/
|
|
5292
5327
|
await this.loadMarkets();
|
|
5328
|
+
await this.loadUnifiedStatus();
|
|
5293
5329
|
let market = undefined;
|
|
5294
5330
|
if (symbol !== undefined) {
|
|
5295
5331
|
market = this.market(symbol);
|
|
@@ -5333,9 +5369,11 @@ class gate extends gate$1 {
|
|
|
5333
5369
|
* @param {CancellationRequest[]} orders list of order ids with symbol, example [{"id": "a", "symbol": "BTC/USDT"}, {"id": "b", "symbol": "ETH/USDT"}]
|
|
5334
5370
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5335
5371
|
* @param {string[]} [params.clientOrderIds] client order ids
|
|
5372
|
+
* @param {bool} [params.unifiedAccount] set to true for canceling unified account orders
|
|
5336
5373
|
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5337
5374
|
*/
|
|
5338
5375
|
await this.loadMarkets();
|
|
5376
|
+
await this.loadUnifiedStatus();
|
|
5339
5377
|
const ordersRequests = [];
|
|
5340
5378
|
for (let i = 0; i < orders.length; i++) {
|
|
5341
5379
|
const order = orders[i];
|
|
@@ -5373,9 +5411,11 @@ class gate extends gate$1 {
|
|
|
5373
5411
|
* @see https://www.gate.io/docs/developers/apiv4/en/#cancel-all-open-orders-matched-3
|
|
5374
5412
|
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
5375
5413
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5414
|
+
* @param {bool} [params.unifiedAccount] set to true for canceling unified account orders
|
|
5376
5415
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5377
5416
|
*/
|
|
5378
5417
|
await this.loadMarkets();
|
|
5418
|
+
await this.loadUnifiedStatus();
|
|
5379
5419
|
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
5380
5420
|
const stop = this.safeBool2(params, 'stop', 'trigger');
|
|
5381
5421
|
params = this.omit(params, ['stop', 'trigger']);
|
|
@@ -6193,38 +6233,50 @@ class gate extends gate$1 {
|
|
|
6193
6233
|
* @name gate#repayCrossMargin
|
|
6194
6234
|
* @description repay cross margin borrowed margin and interest
|
|
6195
6235
|
* @see https://www.gate.io/docs/developers/apiv4/en/#cross-margin-repayments
|
|
6236
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#borrow-or-repay
|
|
6196
6237
|
* @param {string} code unified currency code of the currency to repay
|
|
6197
6238
|
* @param {float} amount the amount to repay
|
|
6198
6239
|
* @param {string} symbol unified market symbol, required for isolated margin
|
|
6199
6240
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
6200
6241
|
* @param {string} [params.mode] 'all' or 'partial' payment mode, extra parameter required for isolated margin
|
|
6201
6242
|
* @param {string} [params.id] '34267567' loan id, extra parameter required for isolated margin
|
|
6243
|
+
* @param {boolean} [params.unifiedAccount] set to true for repaying in the unified account
|
|
6202
6244
|
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
6203
6245
|
*/
|
|
6204
6246
|
await this.loadMarkets();
|
|
6247
|
+
await this.loadUnifiedStatus();
|
|
6205
6248
|
const currency = this.currency(code);
|
|
6206
6249
|
const request = {
|
|
6207
6250
|
'currency': currency['id'].toUpperCase(),
|
|
6208
6251
|
'amount': this.currencyToPrecision(code, amount),
|
|
6209
6252
|
};
|
|
6210
|
-
let
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6253
|
+
let isUnifiedAccount = false;
|
|
6254
|
+
[isUnifiedAccount, params] = this.handleOptionAndParams(params, 'repayCrossMargin', 'unifiedAccount');
|
|
6255
|
+
let response = undefined;
|
|
6256
|
+
if (isUnifiedAccount) {
|
|
6257
|
+
request['type'] = 'repay';
|
|
6258
|
+
response = await this.privateUnifiedPostLoans(this.extend(request, params));
|
|
6259
|
+
}
|
|
6260
|
+
else {
|
|
6261
|
+
response = await this.privateMarginPostCrossRepayments(this.extend(request, params));
|
|
6262
|
+
response = this.safeDict(response, 0);
|
|
6263
|
+
//
|
|
6264
|
+
// [
|
|
6265
|
+
// {
|
|
6266
|
+
// "id": "17",
|
|
6267
|
+
// "create_time": 1620381696159,
|
|
6268
|
+
// "update_time": 1620381696159,
|
|
6269
|
+
// "currency": "EOS",
|
|
6270
|
+
// "amount": "110.553635",
|
|
6271
|
+
// "text": "web",
|
|
6272
|
+
// "status": 2,
|
|
6273
|
+
// "repaid": "110.506649705159",
|
|
6274
|
+
// "repaid_interest": "0.046985294841",
|
|
6275
|
+
// "unpaid_interest": "0.0000074393366667"
|
|
6276
|
+
// }
|
|
6277
|
+
// ]
|
|
6278
|
+
//
|
|
6279
|
+
}
|
|
6228
6280
|
return this.parseMarginLoan(response, currency);
|
|
6229
6281
|
}
|
|
6230
6282
|
async borrowIsolatedMargin(symbol, code, amount, params = {}) {
|
|
@@ -6278,34 +6330,46 @@ class gate extends gate$1 {
|
|
|
6278
6330
|
* @name gate#borrowMargin
|
|
6279
6331
|
* @description create a loan to borrow margin
|
|
6280
6332
|
* @see https://www.gate.io/docs/apiv4/en/#create-a-cross-margin-borrow-loan
|
|
6333
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#borrow-or-repay
|
|
6281
6334
|
* @param {string} code unified currency code of the currency to borrow
|
|
6282
6335
|
* @param {float} amount the amount to borrow
|
|
6283
6336
|
* @param {string} symbol unified market symbol, required for isolated margin
|
|
6284
6337
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
6285
6338
|
* @param {string} [params.rate] '0.0002' or '0.002' extra parameter required for isolated margin
|
|
6339
|
+
* @param {boolean} [params.unifiedAccount] set to true for borrowing in the unified account
|
|
6286
6340
|
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
6287
6341
|
*/
|
|
6288
6342
|
await this.loadMarkets();
|
|
6343
|
+
await this.loadUnifiedStatus();
|
|
6289
6344
|
const currency = this.currency(code);
|
|
6290
6345
|
const request = {
|
|
6291
6346
|
'currency': currency['id'].toUpperCase(),
|
|
6292
6347
|
'amount': this.currencyToPrecision(code, amount),
|
|
6293
6348
|
};
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6349
|
+
let isUnifiedAccount = false;
|
|
6350
|
+
[isUnifiedAccount, params] = this.handleOptionAndParams(params, 'borrowCrossMargin', 'unifiedAccount');
|
|
6351
|
+
let response = undefined;
|
|
6352
|
+
if (isUnifiedAccount) {
|
|
6353
|
+
request['type'] = 'borrow';
|
|
6354
|
+
response = await this.privateUnifiedPostLoans(this.extend(request, params));
|
|
6355
|
+
}
|
|
6356
|
+
else {
|
|
6357
|
+
response = await this.privateMarginPostCrossLoans(this.extend(request, params));
|
|
6358
|
+
//
|
|
6359
|
+
// {
|
|
6360
|
+
// "id": "17",
|
|
6361
|
+
// "create_time": 1620381696159,
|
|
6362
|
+
// "update_time": 1620381696159,
|
|
6363
|
+
// "currency": "EOS",
|
|
6364
|
+
// "amount": "110.553635",
|
|
6365
|
+
// "text": "web",
|
|
6366
|
+
// "status": 2,
|
|
6367
|
+
// "repaid": "110.506649705159",
|
|
6368
|
+
// "repaid_interest": "0.046985294841",
|
|
6369
|
+
// "unpaid_interest": "0.0000074393366667"
|
|
6370
|
+
// }
|
|
6371
|
+
//
|
|
6372
|
+
}
|
|
6309
6373
|
return this.parseMarginLoan(response, currency);
|
|
6310
6374
|
}
|
|
6311
6375
|
parseMarginLoan(info, currency = undefined) {
|
|
@@ -6362,6 +6426,78 @@ class gate extends gate$1 {
|
|
|
6362
6426
|
'info': info,
|
|
6363
6427
|
};
|
|
6364
6428
|
}
|
|
6429
|
+
async fetchBorrowInterest(code = undefined, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
6430
|
+
/**
|
|
6431
|
+
* @method
|
|
6432
|
+
* @name gate#fetchBorrowInterest
|
|
6433
|
+
* @description fetch the interest owed by the user for borrowing currency for margin trading
|
|
6434
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#list-interest-records
|
|
6435
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#interest-records-for-the-cross-margin-account
|
|
6436
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#list-interest-records-2
|
|
6437
|
+
* @param {string} [code] unified currency code
|
|
6438
|
+
* @param {string} [symbol] unified market symbol when fetching interest in isolated markets
|
|
6439
|
+
* @param {int} [since] the earliest time in ms to fetch borrow interest for
|
|
6440
|
+
* @param {int} [limit] the maximum number of structures to retrieve
|
|
6441
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
6442
|
+
* @param {boolean} [params.unifiedAccount] set to true for fetching borrow interest in the unified account
|
|
6443
|
+
* @returns {object[]} a list of [borrow interest structures]{@link https://docs.ccxt.com/#/?id=borrow-interest-structure}
|
|
6444
|
+
*/
|
|
6445
|
+
await this.loadMarkets();
|
|
6446
|
+
await this.loadUnifiedStatus();
|
|
6447
|
+
let isUnifiedAccount = false;
|
|
6448
|
+
[isUnifiedAccount, params] = this.handleOptionAndParams(params, 'fetchBorrowInterest', 'unifiedAccount');
|
|
6449
|
+
let request = {};
|
|
6450
|
+
[request, params] = this.handleUntilOption('to', request, params);
|
|
6451
|
+
let currency = undefined;
|
|
6452
|
+
if (code !== undefined) {
|
|
6453
|
+
currency = this.currency(code);
|
|
6454
|
+
request['currency'] = currency['id'];
|
|
6455
|
+
}
|
|
6456
|
+
let market = undefined;
|
|
6457
|
+
if (symbol !== undefined) {
|
|
6458
|
+
market = this.market(symbol);
|
|
6459
|
+
}
|
|
6460
|
+
if (since !== undefined) {
|
|
6461
|
+
request['from'] = since;
|
|
6462
|
+
}
|
|
6463
|
+
if (limit !== undefined) {
|
|
6464
|
+
request['limit'] = limit;
|
|
6465
|
+
}
|
|
6466
|
+
let response = undefined;
|
|
6467
|
+
let marginMode = undefined;
|
|
6468
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchBorrowInterest', params, 'cross');
|
|
6469
|
+
if (isUnifiedAccount) {
|
|
6470
|
+
response = await this.privateUnifiedGetInterestRecords(this.extend(request, params));
|
|
6471
|
+
}
|
|
6472
|
+
else if (marginMode === 'isolated') {
|
|
6473
|
+
if (market !== undefined) {
|
|
6474
|
+
request['currency_pair'] = market['id'];
|
|
6475
|
+
}
|
|
6476
|
+
response = await this.privateMarginGetUniInterestRecords(this.extend(request, params));
|
|
6477
|
+
}
|
|
6478
|
+
else if (marginMode === 'cross') {
|
|
6479
|
+
response = await this.privateMarginGetCrossInterestRecords(this.extend(request, params));
|
|
6480
|
+
}
|
|
6481
|
+
const interest = this.parseBorrowInterests(response, market);
|
|
6482
|
+
return this.filterByCurrencySinceLimit(interest, code, since, limit);
|
|
6483
|
+
}
|
|
6484
|
+
parseBorrowInterest(info, market = undefined) {
|
|
6485
|
+
const marketId = this.safeString(info, 'currency_pair');
|
|
6486
|
+
market = this.safeMarket(marketId, market);
|
|
6487
|
+
const marginMode = (marketId !== undefined) ? 'isolated' : 'cross';
|
|
6488
|
+
const timestamp = this.safeInteger(info, 'create_time');
|
|
6489
|
+
return {
|
|
6490
|
+
'info': info,
|
|
6491
|
+
'timestamp': timestamp,
|
|
6492
|
+
'datetime': this.iso8601(timestamp),
|
|
6493
|
+
'symbol': this.safeString(market, 'symbol'),
|
|
6494
|
+
'currency': this.safeCurrencyCode(this.safeString(info, 'currency')),
|
|
6495
|
+
'marginMode': marginMode,
|
|
6496
|
+
'interest': this.safeNumber(info, 'interest'),
|
|
6497
|
+
'interestRate': this.safeNumber(info, 'actual_rate'),
|
|
6498
|
+
'amountBorrowed': undefined,
|
|
6499
|
+
};
|
|
6500
|
+
}
|
|
6365
6501
|
sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
6366
6502
|
const authentication = api[0]; // public, private
|
|
6367
6503
|
const type = api[1]; // spot, margin, future, delivery
|
|
@@ -2254,7 +2254,7 @@ class hyperliquid extends hyperliquid$1 {
|
|
|
2254
2254
|
'notional': this.safeNumber(entry, 'positionValue'),
|
|
2255
2255
|
'leverage': this.safeNumber(leverage, 'value'),
|
|
2256
2256
|
'collateral': this.safeNumber(entry, 'marginUsed'),
|
|
2257
|
-
'initialMargin': initialMargin,
|
|
2257
|
+
'initialMargin': this.parseNumber(initialMargin),
|
|
2258
2258
|
'maintenanceMargin': undefined,
|
|
2259
2259
|
'initialMarginPercentage': undefined,
|
|
2260
2260
|
'maintenanceMarginPercentage': undefined,
|