ccxt 4.1.97 → 4.1.99
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 +3 -3
- package/build.sh +1 -1
- package/dist/ccxt.browser.js +524 -230
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +29 -0
- package/dist/cjs/src/binance.js +113 -91
- package/dist/cjs/src/bingx.js +58 -9
- package/dist/cjs/src/bitget.js +108 -51
- package/dist/cjs/src/bitmart.js +71 -17
- package/dist/cjs/src/bitvavo.js +52 -14
- package/dist/cjs/src/coinex.js +58 -21
- package/dist/cjs/src/kraken.js +21 -16
- package/dist/cjs/src/phemex.js +3 -3
- package/dist/cjs/src/pro/binance.js +1 -1
- package/dist/cjs/src/pro/bingx.js +6 -3
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bitmart.js +1 -1
- package/dist/cjs/src/pro/bybit.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +16 -0
- package/js/src/abstract/binancecoinm.d.ts +16 -0
- package/js/src/abstract/binanceus.d.ts +16 -0
- package/js/src/abstract/binanceusdm.d.ts +16 -0
- package/js/src/abstract/coinex.d.ts +14 -1
- package/js/src/base/Exchange.d.ts +4 -0
- package/js/src/base/Exchange.js +29 -0
- package/js/src/binance.js +113 -91
- package/js/src/bingx.d.ts +1 -0
- package/js/src/bingx.js +58 -9
- package/js/src/bitget.js +108 -51
- package/js/src/bitmart.js +71 -17
- package/js/src/bitvavo.js +52 -14
- package/js/src/coinex.js +58 -21
- package/js/src/kraken.js +21 -16
- package/js/src/phemex.js +3 -3
- package/js/src/pro/binance.js +1 -1
- package/js/src/pro/bingx.js +6 -3
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bitmart.js +1 -1
- package/js/src/pro/bybit.js +1 -1
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
- package/package.json +13 -13
- package/skip-tests.json +119 -71
- package/run-tests-ws.js +0 -290
package/dist/cjs/src/bingx.js
CHANGED
|
@@ -30,7 +30,7 @@ class bingx extends bingx$1 {
|
|
|
30
30
|
'cancelOrder': true,
|
|
31
31
|
'cancelOrders': true,
|
|
32
32
|
'closeAllPositions': true,
|
|
33
|
-
'closePosition':
|
|
33
|
+
'closePosition': true,
|
|
34
34
|
'createMarketBuyOrderWithCost': true,
|
|
35
35
|
'createMarketOrderWithCost': true,
|
|
36
36
|
'createMarketSellOrderWithCost': true,
|
|
@@ -1697,15 +1697,20 @@ class bingx extends bingx$1 {
|
|
|
1697
1697
|
else if (timeInForce === 'FOK') {
|
|
1698
1698
|
request['timeInForce'] = 'FOK';
|
|
1699
1699
|
}
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
const
|
|
1704
|
-
const
|
|
1705
|
-
const takeProfitPrice = this.safeNumber(params, 'takeProfitPrice');
|
|
1700
|
+
const triggerPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
|
|
1701
|
+
const stopLossPrice = this.safeString(params, 'stopLossPrice');
|
|
1702
|
+
const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
|
|
1703
|
+
const trailingAmount = this.safeString(params, 'trailingAmount');
|
|
1704
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'priceRate');
|
|
1706
1705
|
const isTriggerOrder = triggerPrice !== undefined;
|
|
1707
1706
|
const isStopLossPriceOrder = stopLossPrice !== undefined;
|
|
1708
1707
|
const isTakeProfitPriceOrder = takeProfitPrice !== undefined;
|
|
1708
|
+
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
1709
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
1710
|
+
const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
|
|
1711
|
+
if (((type === 'LIMIT') || (type === 'TRIGGER_LIMIT') || (type === 'STOP') || (type === 'TAKE_PROFIT')) && !isTrailing) {
|
|
1712
|
+
request['price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
|
|
1713
|
+
}
|
|
1709
1714
|
let reduceOnly = this.safeValue(params, 'reduceOnly', false);
|
|
1710
1715
|
if (isTriggerOrder) {
|
|
1711
1716
|
request['stopPrice'] = this.parseToNumeric(this.priceToPrecision(symbol, triggerPrice));
|
|
@@ -1738,6 +1743,16 @@ class bingx extends bingx$1 {
|
|
|
1738
1743
|
}
|
|
1739
1744
|
}
|
|
1740
1745
|
}
|
|
1746
|
+
else if (isTrailing) {
|
|
1747
|
+
request['type'] = 'TRAILING_STOP_MARKET';
|
|
1748
|
+
if (isTrailingAmountOrder) {
|
|
1749
|
+
request['price'] = this.parseToNumeric(trailingAmount);
|
|
1750
|
+
}
|
|
1751
|
+
else if (isTrailingPercentOrder) {
|
|
1752
|
+
const requestTrailingPercent = Precise["default"].stringDiv(trailingPercent, '100');
|
|
1753
|
+
request['priceRate'] = this.parseToNumeric(requestTrailingPercent);
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1741
1756
|
let positionSide = undefined;
|
|
1742
1757
|
if (reduceOnly) {
|
|
1743
1758
|
positionSide = (side === 'buy') ? 'SHORT' : 'LONG';
|
|
@@ -1747,7 +1762,7 @@ class bingx extends bingx$1 {
|
|
|
1747
1762
|
}
|
|
1748
1763
|
request['positionSide'] = positionSide;
|
|
1749
1764
|
request['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, amount));
|
|
1750
|
-
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']);
|
|
1765
|
+
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent']);
|
|
1751
1766
|
}
|
|
1752
1767
|
return this.extend(request, params);
|
|
1753
1768
|
}
|
|
@@ -1770,6 +1785,8 @@ class bingx extends bingx$1 {
|
|
|
1770
1785
|
* @param {float} [params.stopLossPrice] *swap only* stop loss trigger price
|
|
1771
1786
|
* @param {float} [params.takeProfitPrice] *swap only* take profit trigger price
|
|
1772
1787
|
* @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount
|
|
1788
|
+
* @param {float} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
|
|
1789
|
+
* @param {float} [params.trailingPercent] *swap only* the percent to trail away from the current market price
|
|
1773
1790
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1774
1791
|
*/
|
|
1775
1792
|
await this.loadMarkets();
|
|
@@ -3379,12 +3396,44 @@ class bingx extends bingx$1 {
|
|
|
3379
3396
|
'datetime': this.iso8601(timestamp),
|
|
3380
3397
|
});
|
|
3381
3398
|
}
|
|
3399
|
+
async closePosition(symbol, side = undefined, params = {}) {
|
|
3400
|
+
/**
|
|
3401
|
+
* @method
|
|
3402
|
+
* @name bingx#closePosition
|
|
3403
|
+
* @description closes open positions for a market
|
|
3404
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#One-Click%20Close%20All%20Positions
|
|
3405
|
+
* @param {string} symbol Unified CCXT market symbol
|
|
3406
|
+
* @param {string} [side] not used by bingx
|
|
3407
|
+
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
3408
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3409
|
+
*/
|
|
3410
|
+
await this.loadMarkets();
|
|
3411
|
+
const market = this.market(symbol);
|
|
3412
|
+
const request = {
|
|
3413
|
+
'symbol': market['id'],
|
|
3414
|
+
};
|
|
3415
|
+
const response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
|
|
3416
|
+
//
|
|
3417
|
+
// {
|
|
3418
|
+
// "code": 0,
|
|
3419
|
+
// "msg": "",
|
|
3420
|
+
// "data": {
|
|
3421
|
+
// "success": [
|
|
3422
|
+
// 1727686766700486656,
|
|
3423
|
+
// ],
|
|
3424
|
+
// "failed": null
|
|
3425
|
+
// }
|
|
3426
|
+
// }
|
|
3427
|
+
//
|
|
3428
|
+
const data = this.safeValue(response, 'data');
|
|
3429
|
+
return this.parseOrder(data);
|
|
3430
|
+
}
|
|
3382
3431
|
async closeAllPositions(params = {}) {
|
|
3383
3432
|
/**
|
|
3384
3433
|
* @method
|
|
3385
3434
|
* @name bitget#closePositions
|
|
3386
3435
|
* @description closes open positions for a market
|
|
3387
|
-
* @see https://
|
|
3436
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#One-Click%20Close%20All%20Positions
|
|
3388
3437
|
* @param {object} [params] extra parameters specific to the okx api endpoint
|
|
3389
3438
|
* @param {string} [params.recvWindow] request valid time window value
|
|
3390
3439
|
* @returns {object[]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
package/dist/cjs/src/bitget.js
CHANGED
|
@@ -1278,12 +1278,12 @@ class bitget extends bitget$1 {
|
|
|
1278
1278
|
'30m': '30min',
|
|
1279
1279
|
'1h': '1h',
|
|
1280
1280
|
'4h': '4h',
|
|
1281
|
-
'6h': '
|
|
1282
|
-
'12h': '
|
|
1283
|
-
'1d': '
|
|
1284
|
-
'3d': '
|
|
1285
|
-
'1w': '
|
|
1286
|
-
'1M': '
|
|
1281
|
+
'6h': '6Hutc',
|
|
1282
|
+
'12h': '12Hutc',
|
|
1283
|
+
'1d': '1Dutc',
|
|
1284
|
+
'3d': '3Dutc',
|
|
1285
|
+
'1w': '1Wutc',
|
|
1286
|
+
'1M': '1Mutc',
|
|
1287
1287
|
},
|
|
1288
1288
|
'swap': {
|
|
1289
1289
|
'1m': '1m',
|
|
@@ -1294,12 +1294,12 @@ class bitget extends bitget$1 {
|
|
|
1294
1294
|
'1h': '1H',
|
|
1295
1295
|
'2h': '2H',
|
|
1296
1296
|
'4h': '4H',
|
|
1297
|
-
'6h': '
|
|
1298
|
-
'12h': '
|
|
1299
|
-
'1d': '
|
|
1300
|
-
'3d': '
|
|
1301
|
-
'1w': '
|
|
1302
|
-
'1M': '
|
|
1297
|
+
'6h': '6Hutc',
|
|
1298
|
+
'12h': '12Hutc',
|
|
1299
|
+
'1d': '1Dutc',
|
|
1300
|
+
'3d': '3Dutc',
|
|
1301
|
+
'1w': '1Wutc',
|
|
1302
|
+
'1M': '1Mutc',
|
|
1303
1303
|
},
|
|
1304
1304
|
},
|
|
1305
1305
|
'fetchMarkets': [
|
|
@@ -2901,7 +2901,7 @@ class bitget extends bitget$1 {
|
|
|
2901
2901
|
const currencyCode = this.safeCurrencyCode(this.safeString(feeStructure, 'feeCoin'));
|
|
2902
2902
|
fee = {
|
|
2903
2903
|
'currency': currencyCode,
|
|
2904
|
-
'cost': Precise["default"].
|
|
2904
|
+
'cost': Precise["default"].stringAbs(this.safeString(feeStructure, 'totalFee')),
|
|
2905
2905
|
};
|
|
2906
2906
|
}
|
|
2907
2907
|
return this.safeTrade({
|
|
@@ -4000,6 +4000,9 @@ class bitget extends bitget$1 {
|
|
|
4000
4000
|
* @param {float} [params.takeProfit.price] *swap only* the execution price for a take profit attached to a trigger order
|
|
4001
4001
|
* @param {string} [params.stopLoss.type] *swap only* the type for a stop loss attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
|
|
4002
4002
|
* @param {string} [params.takeProfit.type] *swap only* the type for a take profit attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
|
|
4003
|
+
* @param {string} [params.trailingPercent] *swap and future only* the percent to trail away from the current market price, rate can not be greater than 10
|
|
4004
|
+
* @param {string} [params.trailingTriggerPrice] *swap and future only* the price to trigger a trailing stop order, default uses the price argument
|
|
4005
|
+
* @param {string} [params.triggerType] *swap and future only* 'fill_price', 'mark_price' or 'index_price'
|
|
4003
4006
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4004
4007
|
*/
|
|
4005
4008
|
await this.loadMarkets();
|
|
@@ -4009,6 +4012,8 @@ class bitget extends bitget$1 {
|
|
|
4009
4012
|
const triggerPrice = this.safeValue2(params, 'stopPrice', 'triggerPrice');
|
|
4010
4013
|
const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice');
|
|
4011
4014
|
const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
|
|
4015
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRatio');
|
|
4016
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
4012
4017
|
const isTriggerOrder = triggerPrice !== undefined;
|
|
4013
4018
|
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
4014
4019
|
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
@@ -4030,7 +4035,7 @@ class bitget extends bitget$1 {
|
|
|
4030
4035
|
}
|
|
4031
4036
|
}
|
|
4032
4037
|
else {
|
|
4033
|
-
if (isTriggerOrder) {
|
|
4038
|
+
if (isTriggerOrder || isTrailingPercentOrder) {
|
|
4034
4039
|
response = await this.privateMixPostV2MixOrderPlacePlanOrder(request);
|
|
4035
4040
|
}
|
|
4036
4041
|
else if (isStopLossOrTakeProfitTrigger) {
|
|
@@ -4085,8 +4090,11 @@ class bitget extends bitget$1 {
|
|
|
4085
4090
|
const isTakeProfit = takeProfit !== undefined;
|
|
4086
4091
|
const isStopLossOrTakeProfitTrigger = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
|
|
4087
4092
|
const isStopLossOrTakeProfit = isStopLoss || isTakeProfit;
|
|
4088
|
-
|
|
4089
|
-
|
|
4093
|
+
const trailingTriggerPrice = this.safeString(params, 'trailingTriggerPrice', price);
|
|
4094
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRatio');
|
|
4095
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
4096
|
+
if (this.sum(isTriggerOrder, isStopLossTriggerOrder, isTakeProfitTriggerOrder, isTrailingPercentOrder) > 1) {
|
|
4097
|
+
throw new errors.ExchangeError(this.id + ' createOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent');
|
|
4090
4098
|
}
|
|
4091
4099
|
if (type === 'limit') {
|
|
4092
4100
|
request['price'] = this.priceToPrecision(symbol, price);
|
|
@@ -4111,7 +4119,7 @@ class bitget extends bitget$1 {
|
|
|
4111
4119
|
else if (timeInForce === 'IOC') {
|
|
4112
4120
|
request['force'] = 'IOC';
|
|
4113
4121
|
}
|
|
4114
|
-
params = this.omit(params, ['stopPrice', 'triggerType', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit', 'postOnly', 'reduceOnly', 'clientOrderId']);
|
|
4122
|
+
params = this.omit(params, ['stopPrice', 'triggerType', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit', 'postOnly', 'reduceOnly', 'clientOrderId', 'trailingPercent', 'trailingTriggerPrice']);
|
|
4115
4123
|
if ((marketType === 'swap') || (marketType === 'future')) {
|
|
4116
4124
|
request['marginCoin'] = market['settleId'];
|
|
4117
4125
|
request['size'] = this.amountToPrecision(symbol, amount);
|
|
@@ -4121,34 +4129,21 @@ class bitget extends bitget$1 {
|
|
|
4121
4129
|
if (clientOrderId !== undefined) {
|
|
4122
4130
|
request['clientOid'] = clientOrderId;
|
|
4123
4131
|
}
|
|
4124
|
-
if (isTriggerOrder || isStopLossOrTakeProfitTrigger) {
|
|
4132
|
+
if (isTriggerOrder || isStopLossOrTakeProfitTrigger || isTrailingPercentOrder) {
|
|
4125
4133
|
request['triggerType'] = triggerType;
|
|
4126
4134
|
}
|
|
4127
|
-
if (
|
|
4135
|
+
if (isTrailingPercentOrder) {
|
|
4128
4136
|
if (!isMarketOrder) {
|
|
4129
|
-
throw new errors.
|
|
4137
|
+
throw new errors.BadRequest(this.id + ' createOrder() bitget trailing orders must be market orders');
|
|
4130
4138
|
}
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
else {
|
|
4134
|
-
if (marginMode === undefined) {
|
|
4135
|
-
marginMode = 'cross';
|
|
4139
|
+
if (trailingTriggerPrice === undefined) {
|
|
4140
|
+
throw new errors.ArgumentsRequired(this.id + ' createOrder() bitget trailing orders must have a trailingTriggerPrice param');
|
|
4136
4141
|
}
|
|
4137
|
-
|
|
4138
|
-
request['
|
|
4139
|
-
|
|
4140
|
-
if (reduceOnly) {
|
|
4141
|
-
request['reduceOnly'] = 'YES';
|
|
4142
|
-
request['tradeSide'] = 'Close';
|
|
4143
|
-
// on bitget if the position is long the side is always buy, and if the position is short the side is always sell
|
|
4144
|
-
requestSide = (side === 'buy') ? 'sell' : 'buy';
|
|
4145
|
-
}
|
|
4146
|
-
else {
|
|
4147
|
-
request['tradeSide'] = 'Open';
|
|
4148
|
-
}
|
|
4149
|
-
request['side'] = requestSide;
|
|
4142
|
+
request['planType'] = 'track_plan';
|
|
4143
|
+
request['triggerPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
|
|
4144
|
+
request['callbackRatio'] = trailingPercent;
|
|
4150
4145
|
}
|
|
4151
|
-
if (isTriggerOrder) {
|
|
4146
|
+
else if (isTriggerOrder) {
|
|
4152
4147
|
request['planType'] = 'normal_plan';
|
|
4153
4148
|
request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
|
|
4154
4149
|
if (price !== undefined) {
|
|
@@ -4172,6 +4167,10 @@ class bitget extends bitget$1 {
|
|
|
4172
4167
|
}
|
|
4173
4168
|
}
|
|
4174
4169
|
else if (isStopLossOrTakeProfitTrigger) {
|
|
4170
|
+
if (!isMarketOrder) {
|
|
4171
|
+
throw new errors.ExchangeError(this.id + ' createOrder() bitget stopLoss or takeProfit orders must be market orders');
|
|
4172
|
+
}
|
|
4173
|
+
request['holdSide'] = (side === 'buy') ? 'long' : 'short';
|
|
4175
4174
|
if (isStopLossTriggerOrder) {
|
|
4176
4175
|
request['triggerPrice'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
|
|
4177
4176
|
request['planType'] = 'pos_loss';
|
|
@@ -4191,6 +4190,24 @@ class bitget extends bitget$1 {
|
|
|
4191
4190
|
request['presetStopSurplusPrice'] = this.priceToPrecision(symbol, tpTriggerPrice);
|
|
4192
4191
|
}
|
|
4193
4192
|
}
|
|
4193
|
+
if (!isStopLossOrTakeProfitTrigger) {
|
|
4194
|
+
if (marginMode === undefined) {
|
|
4195
|
+
marginMode = 'cross';
|
|
4196
|
+
}
|
|
4197
|
+
const marginModeRequest = (marginMode === 'cross') ? 'crossed' : 'isolated';
|
|
4198
|
+
request['marginMode'] = marginModeRequest;
|
|
4199
|
+
let requestSide = side;
|
|
4200
|
+
if (reduceOnly) {
|
|
4201
|
+
request['reduceOnly'] = 'YES';
|
|
4202
|
+
request['tradeSide'] = 'Close';
|
|
4203
|
+
// on bitget if the position is long the side is always buy, and if the position is short the side is always sell
|
|
4204
|
+
requestSide = (side === 'buy') ? 'sell' : 'buy';
|
|
4205
|
+
}
|
|
4206
|
+
else {
|
|
4207
|
+
request['tradeSide'] = 'Open';
|
|
4208
|
+
}
|
|
4209
|
+
request['side'] = requestSide;
|
|
4210
|
+
}
|
|
4194
4211
|
}
|
|
4195
4212
|
else if (marketType === 'spot') {
|
|
4196
4213
|
if (isStopLossOrTakeProfitTrigger || isStopLossOrTakeProfit) {
|
|
@@ -4397,6 +4414,9 @@ class bitget extends bitget$1 {
|
|
|
4397
4414
|
* @param {float} [params.takeProfit.price] *swap only* the execution price for a take profit attached to a trigger order
|
|
4398
4415
|
* @param {string} [params.stopLoss.type] *swap only* the type for a stop loss attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
|
|
4399
4416
|
* @param {string} [params.takeProfit.type] *swap only* the type for a take profit attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
|
|
4417
|
+
* @param {string} [params.trailingPercent] *swap and future only* the percent to trail away from the current market price, rate can not be greater than 10
|
|
4418
|
+
* @param {string} [params.trailingTriggerPrice] *swap and future only* the price to trigger a trailing stop order, default uses the price argument
|
|
4419
|
+
* @param {string} [params.newTriggerType] *swap and future only* 'fill_price', 'mark_price' or 'index_price'
|
|
4400
4420
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4401
4421
|
*/
|
|
4402
4422
|
await this.loadMarkets();
|
|
@@ -4423,14 +4443,17 @@ class bitget extends bitget$1 {
|
|
|
4423
4443
|
const takeProfit = this.safeValue(params, 'takeProfit');
|
|
4424
4444
|
const isStopLoss = stopLoss !== undefined;
|
|
4425
4445
|
const isTakeProfit = takeProfit !== undefined;
|
|
4426
|
-
|
|
4427
|
-
|
|
4446
|
+
const trailingTriggerPrice = this.safeString(params, 'trailingTriggerPrice', price);
|
|
4447
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'newCallbackRatio');
|
|
4448
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
4449
|
+
if (this.sum(isTriggerOrder, isStopLossOrder, isTakeProfitOrder, isTrailingPercentOrder) > 1) {
|
|
4450
|
+
throw new errors.ExchangeError(this.id + ' editOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent');
|
|
4428
4451
|
}
|
|
4429
4452
|
const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
|
|
4430
4453
|
if (clientOrderId !== undefined) {
|
|
4431
4454
|
request['clientOid'] = clientOrderId;
|
|
4432
4455
|
}
|
|
4433
|
-
params = this.omit(params, ['stopPrice', 'triggerType', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit', 'clientOrderId']);
|
|
4456
|
+
params = this.omit(params, ['stopPrice', 'triggerType', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit', 'clientOrderId', 'trailingTriggerPrice', 'trailingPercent']);
|
|
4434
4457
|
let response = undefined;
|
|
4435
4458
|
if (market['spot']) {
|
|
4436
4459
|
const editMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'editMarketBuyOrderRequiresPrice', true);
|
|
@@ -4463,11 +4486,21 @@ class bitget extends bitget$1 {
|
|
|
4463
4486
|
request['productType'] = productType;
|
|
4464
4487
|
if (!isTakeProfitOrder && !isStopLossOrder) {
|
|
4465
4488
|
request['newSize'] = this.amountToPrecision(symbol, amount);
|
|
4466
|
-
if (price !== undefined) {
|
|
4489
|
+
if ((price !== undefined) && !isTrailingPercentOrder) {
|
|
4467
4490
|
request['newPrice'] = this.priceToPrecision(symbol, price);
|
|
4468
4491
|
}
|
|
4469
4492
|
}
|
|
4470
|
-
if (
|
|
4493
|
+
if (isTrailingPercentOrder) {
|
|
4494
|
+
if (!isMarketOrder) {
|
|
4495
|
+
throw new errors.BadRequest(this.id + ' editOrder() bitget trailing orders must be market orders');
|
|
4496
|
+
}
|
|
4497
|
+
if (trailingTriggerPrice !== undefined) {
|
|
4498
|
+
request['newTriggerPrice'] = this.priceToPrecision(symbol, trailingTriggerPrice);
|
|
4499
|
+
}
|
|
4500
|
+
request['newCallbackRatio'] = trailingPercent;
|
|
4501
|
+
response = await this.privateMixPostV2MixOrderModifyPlanOrder(this.extend(request, params));
|
|
4502
|
+
}
|
|
4503
|
+
else if (isTakeProfitOrder || isStopLossOrder) {
|
|
4471
4504
|
request['marginCoin'] = market['settleId'];
|
|
4472
4505
|
request['size'] = this.amountToPrecision(symbol, amount);
|
|
4473
4506
|
request['executePrice'] = this.priceToPrecision(symbol, price);
|
|
@@ -4546,6 +4579,7 @@ class bitget extends bitget$1 {
|
|
|
4546
4579
|
* @param {string} [params.marginMode] 'isolated' or 'cross' for spot margin trading
|
|
4547
4580
|
* @param {boolean} [params.stop] set to true for canceling trigger orders
|
|
4548
4581
|
* @param {string} [params.planType] *swap only* either profit_plan, loss_plan, normal_plan, pos_profit, pos_loss, moving_plan or track_plan
|
|
4582
|
+
* @param {boolean} [params.trailing] set to true if you want to cancel a trailing order
|
|
4549
4583
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4550
4584
|
*/
|
|
4551
4585
|
if (symbol === undefined) {
|
|
@@ -4565,8 +4599,9 @@ class bitget extends bitget$1 {
|
|
|
4565
4599
|
let response = undefined;
|
|
4566
4600
|
[marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
|
|
4567
4601
|
const request = {};
|
|
4568
|
-
const
|
|
4569
|
-
|
|
4602
|
+
const trailing = this.safeValue(params, 'trailing');
|
|
4603
|
+
const stop = this.safeValue2(params, 'stop', 'trigger');
|
|
4604
|
+
params = this.omit(params, ['stop', 'trigger', 'trailing']);
|
|
4570
4605
|
if (!(market['spot'] && stop)) {
|
|
4571
4606
|
request['symbol'] = market['id'];
|
|
4572
4607
|
}
|
|
@@ -4577,13 +4612,20 @@ class bitget extends bitget$1 {
|
|
|
4577
4612
|
let productType = undefined;
|
|
4578
4613
|
[productType, params] = this.handleProductTypeAndParams(market, params);
|
|
4579
4614
|
request['productType'] = productType;
|
|
4580
|
-
if (stop) {
|
|
4615
|
+
if (stop || trailing) {
|
|
4581
4616
|
const orderIdList = [];
|
|
4582
4617
|
const orderId = {
|
|
4583
4618
|
'orderId': id,
|
|
4584
4619
|
};
|
|
4585
4620
|
orderIdList.push(orderId);
|
|
4586
4621
|
request['orderIdList'] = orderIdList;
|
|
4622
|
+
}
|
|
4623
|
+
if (trailing) {
|
|
4624
|
+
const planType = this.safeString(params, 'planType', 'track_plan');
|
|
4625
|
+
request['planType'] = planType;
|
|
4626
|
+
response = await this.privateMixPostV2MixOrderCancelPlanOrder(this.extend(request, params));
|
|
4627
|
+
}
|
|
4628
|
+
else if (stop) {
|
|
4587
4629
|
response = await this.privateMixPostV2MixOrderCancelPlanOrder(this.extend(request, params));
|
|
4588
4630
|
}
|
|
4589
4631
|
else {
|
|
@@ -4999,6 +5041,7 @@ class bitget extends bitget$1 {
|
|
|
4999
5041
|
* @param {boolean} [params.stop] set to true for fetching trigger orders
|
|
5000
5042
|
* @param {boolean} [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)
|
|
5001
5043
|
* @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
|
|
5044
|
+
* @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
|
|
5002
5045
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5003
5046
|
*/
|
|
5004
5047
|
await this.loadMarkets();
|
|
@@ -5040,8 +5083,9 @@ class bitget extends bitget$1 {
|
|
|
5040
5083
|
return await this.fetchPaginatedCallCursor('fetchOpenOrders', symbol, since, limit, params, cursorReceived, 'idLessThan');
|
|
5041
5084
|
}
|
|
5042
5085
|
let response = undefined;
|
|
5086
|
+
const trailing = this.safeValue(params, 'trailing');
|
|
5043
5087
|
const stop = this.safeValue2(params, 'stop', 'trigger');
|
|
5044
|
-
params = this.omit(params, ['stop', 'trigger']);
|
|
5088
|
+
params = this.omit(params, ['stop', 'trigger', 'trailing']);
|
|
5045
5089
|
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
5046
5090
|
if (since !== undefined) {
|
|
5047
5091
|
request['startTime'] = since;
|
|
@@ -5084,7 +5128,12 @@ class bitget extends bitget$1 {
|
|
|
5084
5128
|
let productType = undefined;
|
|
5085
5129
|
[productType, query] = this.handleProductTypeAndParams(market, query);
|
|
5086
5130
|
request['productType'] = productType;
|
|
5087
|
-
if (
|
|
5131
|
+
if (trailing) {
|
|
5132
|
+
const planType = this.safeString(params, 'planType', 'track_plan');
|
|
5133
|
+
request['planType'] = planType;
|
|
5134
|
+
response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, query));
|
|
5135
|
+
}
|
|
5136
|
+
else if (stop) {
|
|
5088
5137
|
const planType = this.safeString(query, 'planType', 'normal_plan');
|
|
5089
5138
|
request['planType'] = planType;
|
|
5090
5139
|
response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, query));
|
|
@@ -5300,6 +5349,7 @@ class bitget extends bitget$1 {
|
|
|
5300
5349
|
* @param {boolean} [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)
|
|
5301
5350
|
* @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
|
|
5302
5351
|
* @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
|
5352
|
+
* @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
|
|
5303
5353
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5304
5354
|
*/
|
|
5305
5355
|
await this.loadMarkets();
|
|
@@ -5337,6 +5387,7 @@ class bitget extends bitget$1 {
|
|
|
5337
5387
|
* @param {boolean} [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)
|
|
5338
5388
|
* @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
|
|
5339
5389
|
* @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
|
5390
|
+
* @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
|
|
5340
5391
|
* @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5341
5392
|
*/
|
|
5342
5393
|
await this.loadMarkets();
|
|
@@ -5389,8 +5440,9 @@ class bitget extends bitget$1 {
|
|
|
5389
5440
|
return await this.fetchPaginatedCallCursor('fetchCanceledAndClosedOrders', symbol, since, limit, params, cursorReceived, 'idLessThan');
|
|
5390
5441
|
}
|
|
5391
5442
|
let response = undefined;
|
|
5443
|
+
const trailing = this.safeValue(params, 'trailing');
|
|
5392
5444
|
const stop = this.safeValue2(params, 'stop', 'trigger');
|
|
5393
|
-
params = this.omit(params, ['stop', 'trigger']);
|
|
5445
|
+
params = this.omit(params, ['stop', 'trigger', 'trailing']);
|
|
5394
5446
|
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
5395
5447
|
if (since !== undefined) {
|
|
5396
5448
|
request['startTime'] = since;
|
|
@@ -5444,7 +5496,12 @@ class bitget extends bitget$1 {
|
|
|
5444
5496
|
let productType = undefined;
|
|
5445
5497
|
[productType, params] = this.handleProductTypeAndParams(market, params);
|
|
5446
5498
|
request['productType'] = productType;
|
|
5447
|
-
if (
|
|
5499
|
+
if (trailing) {
|
|
5500
|
+
const planType = this.safeString(params, 'planType', 'track_plan');
|
|
5501
|
+
request['planType'] = planType;
|
|
5502
|
+
response = await this.privateMixGetV2MixOrderOrdersPlanHistory(this.extend(request, params));
|
|
5503
|
+
}
|
|
5504
|
+
else if (stop) {
|
|
5448
5505
|
const planType = this.safeString(params, 'planType', 'normal_plan');
|
|
5449
5506
|
request['planType'] = planType;
|
|
5450
5507
|
response = await this.privateMixGetV2MixOrderOrdersPlanHistory(this.extend(request, params));
|