ccxt 4.4.34 → 4.4.35
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/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/bingx.js +339 -144
- package/dist/cjs/src/bitmex.js +1 -1
- package/dist/cjs/src/bitrue.js +2 -2
- package/dist/cjs/src/btcmarkets.js +3 -3
- package/dist/cjs/src/btcturk.js +19 -19
- package/dist/cjs/src/gate.js +143 -40
- package/dist/cjs/src/hyperliquid.js +73 -11
- package/dist/cjs/src/idex.js +3 -3
- package/dist/cjs/src/kraken.js +71 -54
- package/dist/cjs/src/kucoin.js +1 -1
- package/dist/cjs/src/okx.js +1 -0
- package/dist/cjs/src/onetrading.js +20 -395
- package/dist/cjs/src/pro/bitrue.js +13 -11
- package/dist/cjs/src/pro/probit.js +58 -66
- package/dist/cjs/src/xt.js +5 -5
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bingx.d.ts +1 -0
- package/js/src/abstract/bitpanda.d.ts +0 -12
- package/js/src/abstract/bitrue.d.ts +3 -3
- package/js/src/abstract/okx.d.ts +1 -0
- package/js/src/abstract/onetrading.d.ts +0 -12
- package/js/src/bingx.d.ts +8 -0
- package/js/src/bingx.js +339 -144
- package/js/src/bitmex.js +1 -1
- package/js/src/bitrue.js +2 -2
- package/js/src/btcmarkets.js +3 -3
- package/js/src/btcturk.js +19 -19
- package/js/src/gate.d.ts +5 -5
- package/js/src/gate.js +143 -40
- package/js/src/hyperliquid.d.ts +10 -0
- package/js/src/hyperliquid.js +75 -13
- package/js/src/idex.js +4 -4
- package/js/src/kraken.d.ts +11 -8
- package/js/src/kraken.js +71 -54
- package/js/src/kucoin.js +1 -1
- package/js/src/okx.js +1 -0
- package/js/src/onetrading.d.ts +15 -67
- package/js/src/onetrading.js +20 -395
- package/js/src/pro/bitrue.js +13 -11
- package/js/src/pro/probit.d.ts +2 -1
- package/js/src/pro/probit.js +58 -66
- package/js/src/xt.js +5 -5
- package/package.json +2 -1
package/dist/cjs/src/bingx.js
CHANGED
|
@@ -365,6 +365,7 @@ class bingx extends bingx$1 {
|
|
|
365
365
|
'get': {
|
|
366
366
|
'list': 10,
|
|
367
367
|
'assets': 2,
|
|
368
|
+
'allAccountBalance': 2,
|
|
368
369
|
},
|
|
369
370
|
'post': {
|
|
370
371
|
'create': 10,
|
|
@@ -2685,6 +2686,10 @@ class bingx extends bingx$1 {
|
|
|
2685
2686
|
};
|
|
2686
2687
|
const isMarketOrder = type === 'MARKET';
|
|
2687
2688
|
const isSpot = marketType === 'spot';
|
|
2689
|
+
const isTwapOrder = type === 'TWAP';
|
|
2690
|
+
if (isTwapOrder && isSpot) {
|
|
2691
|
+
throw new errors.BadSymbol(this.id + ' createOrder() twap order supports swap contracts only');
|
|
2692
|
+
}
|
|
2688
2693
|
const stopLossPrice = this.safeString(params, 'stopLossPrice');
|
|
2689
2694
|
const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
|
|
2690
2695
|
const triggerPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
|
|
@@ -2750,6 +2755,27 @@ class bingx extends bingx$1 {
|
|
|
2750
2755
|
}
|
|
2751
2756
|
}
|
|
2752
2757
|
else {
|
|
2758
|
+
if (isTwapOrder) {
|
|
2759
|
+
const twapRequest = {
|
|
2760
|
+
'symbol': request['symbol'],
|
|
2761
|
+
'side': request['side'],
|
|
2762
|
+
'positionSide': (side === 'buy') ? 'LONG' : 'SHORT',
|
|
2763
|
+
'triggerPrice': this.parseToNumeric(this.priceToPrecision(symbol, triggerPrice)),
|
|
2764
|
+
'totalAmount': this.parseToNumeric(this.amountToPrecision(symbol, amount)),
|
|
2765
|
+
};
|
|
2766
|
+
// {
|
|
2767
|
+
// "symbol": "LTC-USDT",
|
|
2768
|
+
// "side": "BUY",
|
|
2769
|
+
// "positionSide": "LONG",
|
|
2770
|
+
// "priceType": "constant",
|
|
2771
|
+
// "priceVariance": "10",
|
|
2772
|
+
// "triggerPrice": "120",
|
|
2773
|
+
// "interval": 8,
|
|
2774
|
+
// "amountPerOrder": "0.5",
|
|
2775
|
+
// "totalAmount": "1"
|
|
2776
|
+
// }
|
|
2777
|
+
return this.extend(twapRequest, params);
|
|
2778
|
+
}
|
|
2753
2779
|
if (timeInForce === 'FOK') {
|
|
2754
2780
|
request['timeInForce'] = 'FOK';
|
|
2755
2781
|
}
|
|
@@ -2872,6 +2898,7 @@ class bingx extends bingx$1 {
|
|
|
2872
2898
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Trade%20order
|
|
2873
2899
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Create%20an%20Order
|
|
2874
2900
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Trade%20order
|
|
2901
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Place%20TWAP%20Order
|
|
2875
2902
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
2876
2903
|
* @param {string} type 'market' or 'limit'
|
|
2877
2904
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -2911,6 +2938,9 @@ class bingx extends bingx$1 {
|
|
|
2911
2938
|
else if (market['inverse']) {
|
|
2912
2939
|
response = await this.cswapV1PrivatePostTradeOrder(request);
|
|
2913
2940
|
}
|
|
2941
|
+
else if (type === 'twap') {
|
|
2942
|
+
response = await this.swapV1PrivatePostTwapOrder(request);
|
|
2943
|
+
}
|
|
2914
2944
|
else {
|
|
2915
2945
|
response = await this.swapV2PrivatePostTradeOrder(request);
|
|
2916
2946
|
}
|
|
@@ -2971,6 +3001,17 @@ class bingx extends bingx$1 {
|
|
|
2971
3001
|
// "timeInForce": ""
|
|
2972
3002
|
// }
|
|
2973
3003
|
//
|
|
3004
|
+
// twap order
|
|
3005
|
+
//
|
|
3006
|
+
// {
|
|
3007
|
+
// "code": 0,
|
|
3008
|
+
// "msg": "",
|
|
3009
|
+
// "timestamp": 1732693774386,
|
|
3010
|
+
// "data": {
|
|
3011
|
+
// "mainOrderId": "4633860139993029715"
|
|
3012
|
+
// }
|
|
3013
|
+
// }
|
|
3014
|
+
//
|
|
2974
3015
|
if (typeof response === 'string') {
|
|
2975
3016
|
// broken api engine : order-ids are too long numbers (i.e. 1742930526912864656)
|
|
2976
3017
|
// and JSON.parse can not handle them in JS, so we have to use .parseJson
|
|
@@ -2985,7 +3026,7 @@ class bingx extends bingx$1 {
|
|
|
2985
3026
|
result = response;
|
|
2986
3027
|
}
|
|
2987
3028
|
else {
|
|
2988
|
-
result = this.safeDict(data, 'order',
|
|
3029
|
+
result = this.safeDict(data, 'order', data);
|
|
2989
3030
|
}
|
|
2990
3031
|
}
|
|
2991
3032
|
else {
|
|
@@ -3413,9 +3454,9 @@ class bingx extends bingx$1 {
|
|
|
3413
3454
|
market = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
3414
3455
|
}
|
|
3415
3456
|
const side = this.safeStringLower2(order, 'side', 'S');
|
|
3416
|
-
const timestamp = this.safeIntegerN(order, ['time', 'transactTime', 'E']);
|
|
3457
|
+
const timestamp = this.safeIntegerN(order, ['time', 'transactTime', 'E', 'createdTime']);
|
|
3417
3458
|
const lastTradeTimestamp = this.safeInteger2(order, 'updateTime', 'T');
|
|
3418
|
-
const statusId = this.
|
|
3459
|
+
const statusId = this.safeStringUpperN(order, ['status', 'X', 'orderStatus']);
|
|
3419
3460
|
let feeCurrencyCode = this.safeString2(order, 'feeAsset', 'N');
|
|
3420
3461
|
const feeCost = this.safeStringN(order, ['fee', 'commission', 'n']);
|
|
3421
3462
|
if ((feeCurrencyCode === undefined)) {
|
|
@@ -3470,7 +3511,7 @@ class bingx extends bingx$1 {
|
|
|
3470
3511
|
}
|
|
3471
3512
|
return this.safeOrder({
|
|
3472
3513
|
'info': info,
|
|
3473
|
-
'id': this.
|
|
3514
|
+
'id': this.safeStringN(order, ['orderId', 'i', 'mainOrderId']),
|
|
3474
3515
|
'clientOrderId': this.safeStringN(order, ['clientOrderID', 'clientOrderId', 'origClientOrderId', 'c']),
|
|
3475
3516
|
'symbol': this.safeSymbol(marketId, market, '-', marketType),
|
|
3476
3517
|
'timestamp': timestamp,
|
|
@@ -3488,7 +3529,7 @@ class bingx extends bingx$1 {
|
|
|
3488
3529
|
'takeProfitPrice': takeProfitPrice,
|
|
3489
3530
|
'average': this.safeString2(order, 'avgPrice', 'ap'),
|
|
3490
3531
|
'cost': this.safeString(order, 'cummulativeQuoteQty'),
|
|
3491
|
-
'amount': this.safeStringN(order, ['origQty', 'q', 'quantity']),
|
|
3532
|
+
'amount': this.safeStringN(order, ['origQty', 'q', 'quantity', 'totalAmount']),
|
|
3492
3533
|
'filled': this.safeString2(order, 'executedQty', 'z'),
|
|
3493
3534
|
'remaining': undefined,
|
|
3494
3535
|
'status': this.parseOrderStatus(statusId),
|
|
@@ -3505,6 +3546,7 @@ class bingx extends bingx$1 {
|
|
|
3505
3546
|
'NEW': 'open',
|
|
3506
3547
|
'PENDING': 'open',
|
|
3507
3548
|
'PARTIALLY_FILLED': 'open',
|
|
3549
|
+
'RUNNING': 'open',
|
|
3508
3550
|
'FILLED': 'closed',
|
|
3509
3551
|
'CANCELED': 'canceled',
|
|
3510
3552
|
'CANCELLED': 'canceled',
|
|
@@ -3519,6 +3561,7 @@ class bingx extends bingx$1 {
|
|
|
3519
3561
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20Order
|
|
3520
3562
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20Order
|
|
3521
3563
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Cancel%20an%20Order
|
|
3564
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20TWAP%20Order
|
|
3522
3565
|
* @param {string} id order id
|
|
3523
3566
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
3524
3567
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -3526,36 +3569,71 @@ class bingx extends bingx$1 {
|
|
|
3526
3569
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3527
3570
|
*/
|
|
3528
3571
|
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
3529
|
-
if (symbol === undefined) {
|
|
3530
|
-
throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
|
|
3531
|
-
}
|
|
3532
3572
|
await this.loadMarkets();
|
|
3533
|
-
const
|
|
3534
|
-
|
|
3535
|
-
'symbol': market['id'],
|
|
3536
|
-
};
|
|
3537
|
-
const clientOrderId = this.safeString2(params, 'clientOrderId', 'clientOrderID');
|
|
3538
|
-
params = this.omit(params, ['clientOrderId']);
|
|
3539
|
-
if (clientOrderId !== undefined) {
|
|
3540
|
-
request['clientOrderID'] = clientOrderId;
|
|
3541
|
-
}
|
|
3542
|
-
else {
|
|
3543
|
-
request['orderId'] = id;
|
|
3544
|
-
}
|
|
3573
|
+
const isTwapOrder = this.safeBool(params, 'twap', false);
|
|
3574
|
+
params = this.omit(params, 'twap');
|
|
3545
3575
|
let response = undefined;
|
|
3546
|
-
let
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
response = await this.
|
|
3576
|
+
let market = undefined;
|
|
3577
|
+
if (isTwapOrder) {
|
|
3578
|
+
const twapRequest = {
|
|
3579
|
+
'mainOrderId': id,
|
|
3580
|
+
};
|
|
3581
|
+
response = await this.swapV1PrivatePostTwapCancelOrder(this.extend(twapRequest, params));
|
|
3582
|
+
//
|
|
3583
|
+
// {
|
|
3584
|
+
// "code": 0,
|
|
3585
|
+
// "msg": "",
|
|
3586
|
+
// "timestamp": 1702731661854,
|
|
3587
|
+
// "data": {
|
|
3588
|
+
// "symbol": "BNB-USDT",
|
|
3589
|
+
// "side": "BUY",
|
|
3590
|
+
// "positionSide": "LONG",
|
|
3591
|
+
// "priceType": "constant",
|
|
3592
|
+
// "priceVariance": "2000",
|
|
3593
|
+
// "triggerPrice": "68000",
|
|
3594
|
+
// "interval": 8,
|
|
3595
|
+
// "amountPerOrder": "0.111",
|
|
3596
|
+
// "totalAmount": "0.511",
|
|
3597
|
+
// "orderStatus": "Running",
|
|
3598
|
+
// "executedQty": "0.1",
|
|
3599
|
+
// "duration": 800,
|
|
3600
|
+
// "maxDuration": 9000,
|
|
3601
|
+
// "createdTime": 1702731661854,
|
|
3602
|
+
// "updateTime": 1702731661854
|
|
3603
|
+
// }
|
|
3604
|
+
// }
|
|
3605
|
+
//
|
|
3552
3606
|
}
|
|
3553
3607
|
else {
|
|
3554
|
-
if (
|
|
3555
|
-
|
|
3608
|
+
if (symbol === undefined) {
|
|
3609
|
+
throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
|
|
3610
|
+
}
|
|
3611
|
+
market = this.market(symbol);
|
|
3612
|
+
const request = {
|
|
3613
|
+
'symbol': market['id'],
|
|
3614
|
+
};
|
|
3615
|
+
const clientOrderId = this.safeString2(params, 'clientOrderId', 'clientOrderID');
|
|
3616
|
+
params = this.omit(params, ['clientOrderId']);
|
|
3617
|
+
if (clientOrderId !== undefined) {
|
|
3618
|
+
request['clientOrderID'] = clientOrderId;
|
|
3619
|
+
}
|
|
3620
|
+
else {
|
|
3621
|
+
request['orderId'] = id;
|
|
3622
|
+
}
|
|
3623
|
+
let type = undefined;
|
|
3624
|
+
let subType = undefined;
|
|
3625
|
+
[type, params] = this.handleMarketTypeAndParams('cancelOrder', market, params);
|
|
3626
|
+
[subType, params] = this.handleSubTypeAndParams('cancelOrder', market, params);
|
|
3627
|
+
if (type === 'spot') {
|
|
3628
|
+
response = await this.spotV1PrivatePostTradeCancel(this.extend(request, params));
|
|
3556
3629
|
}
|
|
3557
3630
|
else {
|
|
3558
|
-
|
|
3631
|
+
if (subType === 'inverse') {
|
|
3632
|
+
response = await this.cswapV1PrivateDeleteTradeCancelOrder(this.extend(request, params));
|
|
3633
|
+
}
|
|
3634
|
+
else {
|
|
3635
|
+
response = await this.swapV2PrivateDeleteTradeOrder(this.extend(request, params));
|
|
3636
|
+
}
|
|
3559
3637
|
}
|
|
3560
3638
|
}
|
|
3561
3639
|
//
|
|
@@ -3963,134 +4041,172 @@ class bingx extends bingx$1 {
|
|
|
3963
4041
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20details
|
|
3964
4042
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20details
|
|
3965
4043
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Order
|
|
4044
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#TWAP%20Order%20Details
|
|
3966
4045
|
* @param {string} id the order id
|
|
3967
4046
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
3968
4047
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4048
|
+
* @param {boolean} [params.twap] if fetching twap order
|
|
3969
4049
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3970
4050
|
*/
|
|
3971
4051
|
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
3972
|
-
if (symbol === undefined) {
|
|
3973
|
-
throw new errors.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
|
|
3974
|
-
}
|
|
3975
4052
|
await this.loadMarkets();
|
|
3976
|
-
const
|
|
3977
|
-
|
|
3978
|
-
'symbol': market['id'],
|
|
3979
|
-
'orderId': id,
|
|
3980
|
-
};
|
|
3981
|
-
let type = undefined;
|
|
3982
|
-
let subType = undefined;
|
|
4053
|
+
const isTwapOrder = this.safeBool(params, 'twap', false);
|
|
4054
|
+
params = this.omit(params, 'twap');
|
|
3983
4055
|
let response = undefined;
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
4056
|
+
let market = undefined;
|
|
4057
|
+
if (isTwapOrder) {
|
|
4058
|
+
const twapRequest = {
|
|
4059
|
+
'mainOrderId': id,
|
|
4060
|
+
};
|
|
4061
|
+
response = await this.swapV1PrivateGetTwapOrderDetail(this.extend(twapRequest, params));
|
|
3988
4062
|
//
|
|
3989
4063
|
// {
|
|
3990
4064
|
// "code": 0,
|
|
3991
|
-
// "msg": "",
|
|
4065
|
+
// "msg": "success cancel order",
|
|
4066
|
+
// "timestamp": 1732760856617,
|
|
3992
4067
|
// "data": {
|
|
3993
|
-
// "symbol": "
|
|
3994
|
-
// "
|
|
3995
|
-
// "price": "0.5",
|
|
3996
|
-
// "origQty": "10",
|
|
3997
|
-
// "executedQty": "0",
|
|
3998
|
-
// "cummulativeQuoteQty": "0",
|
|
3999
|
-
// "status": "CANCELED",
|
|
4000
|
-
// "type": "LIMIT",
|
|
4068
|
+
// "symbol": "LTC-USDT",
|
|
4069
|
+
// "mainOrderId": "5596903086063901779",
|
|
4001
4070
|
// "side": "BUY",
|
|
4002
|
-
// "
|
|
4003
|
-
// "
|
|
4004
|
-
// "
|
|
4005
|
-
// "
|
|
4006
|
-
// "
|
|
4071
|
+
// "positionSide": "LONG",
|
|
4072
|
+
// "priceType": "constant",
|
|
4073
|
+
// "priceVariance": "10.00",
|
|
4074
|
+
// "triggerPrice": "120.00",
|
|
4075
|
+
// "interval": 8,
|
|
4076
|
+
// "amountPerOrder": "0.5",
|
|
4077
|
+
// "totalAmount": "1.0",
|
|
4078
|
+
// "orderStatus": "Filled",
|
|
4079
|
+
// "executedQty": "1.0",
|
|
4080
|
+
// "duration": 16,
|
|
4081
|
+
// "maxDuration": 86400,
|
|
4082
|
+
// "createdTime": 1732693017000,
|
|
4083
|
+
// "updateTime": 1732693033000
|
|
4007
4084
|
// }
|
|
4008
4085
|
// }
|
|
4009
4086
|
//
|
|
4010
4087
|
}
|
|
4011
4088
|
else {
|
|
4012
|
-
if (
|
|
4013
|
-
|
|
4089
|
+
if (symbol === undefined) {
|
|
4090
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
|
|
4091
|
+
}
|
|
4092
|
+
market = this.market(symbol);
|
|
4093
|
+
const request = {
|
|
4094
|
+
'symbol': market['id'],
|
|
4095
|
+
'orderId': id,
|
|
4096
|
+
};
|
|
4097
|
+
let type = undefined;
|
|
4098
|
+
let subType = undefined;
|
|
4099
|
+
[type, params] = this.handleMarketTypeAndParams('fetchOrder', market, params);
|
|
4100
|
+
[subType, params] = this.handleSubTypeAndParams('fetchOrder', market, params);
|
|
4101
|
+
if (type === 'spot') {
|
|
4102
|
+
response = await this.spotV1PrivateGetTradeQuery(this.extend(request, params));
|
|
4014
4103
|
//
|
|
4015
4104
|
// {
|
|
4016
4105
|
// "code": 0,
|
|
4017
4106
|
// "msg": "",
|
|
4018
4107
|
// "data": {
|
|
4019
|
-
// "
|
|
4020
|
-
//
|
|
4021
|
-
//
|
|
4022
|
-
//
|
|
4023
|
-
//
|
|
4024
|
-
//
|
|
4025
|
-
//
|
|
4026
|
-
//
|
|
4027
|
-
//
|
|
4028
|
-
//
|
|
4029
|
-
//
|
|
4030
|
-
//
|
|
4031
|
-
//
|
|
4032
|
-
//
|
|
4033
|
-
// "commission": "0.0000",
|
|
4034
|
-
// "status": "Pending",
|
|
4035
|
-
// "time": 1721884753767,
|
|
4036
|
-
// "updateTime": 1721884753786,
|
|
4037
|
-
// "clientOrderId": "",
|
|
4038
|
-
// "leverage": "",
|
|
4039
|
-
// "takeProfit": {
|
|
4040
|
-
// "type": "TAKE_PROFIT",
|
|
4041
|
-
// "quantity": 0,
|
|
4042
|
-
// "stopPrice": 0,
|
|
4043
|
-
// "price": 0,
|
|
4044
|
-
// "workingType": "MARK_PRICE",
|
|
4045
|
-
// "stopGuaranteed": ""
|
|
4046
|
-
// },
|
|
4047
|
-
// "stopLoss": {
|
|
4048
|
-
// "type": "STOP",
|
|
4049
|
-
// "quantity": 0,
|
|
4050
|
-
// "stopPrice": 0,
|
|
4051
|
-
// "price": 0,
|
|
4052
|
-
// "workingType": "MARK_PRICE",
|
|
4053
|
-
// "stopGuaranteed": ""
|
|
4054
|
-
// },
|
|
4055
|
-
// "advanceAttr": 0,
|
|
4056
|
-
// "positionID": 0,
|
|
4057
|
-
// "takeProfitEntrustPrice": 0,
|
|
4058
|
-
// "stopLossEntrustPrice": 0,
|
|
4059
|
-
// "orderType": "",
|
|
4060
|
-
// "workingType": "MARK_PRICE"
|
|
4061
|
-
// }
|
|
4108
|
+
// "symbol": "XRP-USDT",
|
|
4109
|
+
// "orderId": 1514087361158316032,
|
|
4110
|
+
// "price": "0.5",
|
|
4111
|
+
// "origQty": "10",
|
|
4112
|
+
// "executedQty": "0",
|
|
4113
|
+
// "cummulativeQuoteQty": "0",
|
|
4114
|
+
// "status": "CANCELED",
|
|
4115
|
+
// "type": "LIMIT",
|
|
4116
|
+
// "side": "BUY",
|
|
4117
|
+
// "time": 1649821532000,
|
|
4118
|
+
// "updateTime": 1649821543000,
|
|
4119
|
+
// "origQuoteOrderQty": "0",
|
|
4120
|
+
// "fee": "0",
|
|
4121
|
+
// "feeAsset": "XRP"
|
|
4062
4122
|
// }
|
|
4063
4123
|
// }
|
|
4064
4124
|
//
|
|
4065
4125
|
}
|
|
4066
4126
|
else {
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4127
|
+
if (subType === 'inverse') {
|
|
4128
|
+
response = await this.cswapV1PrivateGetTradeOrderDetail(this.extend(request, params));
|
|
4129
|
+
//
|
|
4130
|
+
// {
|
|
4131
|
+
// "code": 0,
|
|
4132
|
+
// "msg": "",
|
|
4133
|
+
// "data": {
|
|
4134
|
+
// "order": {
|
|
4135
|
+
// "symbol": "SOL-USD",
|
|
4136
|
+
// "orderId": "1816342420721254400",
|
|
4137
|
+
// "side": "BUY",
|
|
4138
|
+
// "positionSide": "Long",
|
|
4139
|
+
// "type": "LIMIT",
|
|
4140
|
+
// "quantity": 1,
|
|
4141
|
+
// "origQty": "",
|
|
4142
|
+
// "price": "150",
|
|
4143
|
+
// "executedQty": "0",
|
|
4144
|
+
// "avgPrice": "0.000",
|
|
4145
|
+
// "cumQuote": "",
|
|
4146
|
+
// "stopPrice": "",
|
|
4147
|
+
// "profit": "0.0000",
|
|
4148
|
+
// "commission": "0.0000",
|
|
4149
|
+
// "status": "Pending",
|
|
4150
|
+
// "time": 1721884753767,
|
|
4151
|
+
// "updateTime": 1721884753786,
|
|
4152
|
+
// "clientOrderId": "",
|
|
4153
|
+
// "leverage": "",
|
|
4154
|
+
// "takeProfit": {
|
|
4155
|
+
// "type": "TAKE_PROFIT",
|
|
4156
|
+
// "quantity": 0,
|
|
4157
|
+
// "stopPrice": 0,
|
|
4158
|
+
// "price": 0,
|
|
4159
|
+
// "workingType": "MARK_PRICE",
|
|
4160
|
+
// "stopGuaranteed": ""
|
|
4161
|
+
// },
|
|
4162
|
+
// "stopLoss": {
|
|
4163
|
+
// "type": "STOP",
|
|
4164
|
+
// "quantity": 0,
|
|
4165
|
+
// "stopPrice": 0,
|
|
4166
|
+
// "price": 0,
|
|
4167
|
+
// "workingType": "MARK_PRICE",
|
|
4168
|
+
// "stopGuaranteed": ""
|
|
4169
|
+
// },
|
|
4170
|
+
// "advanceAttr": 0,
|
|
4171
|
+
// "positionID": 0,
|
|
4172
|
+
// "takeProfitEntrustPrice": 0,
|
|
4173
|
+
// "stopLossEntrustPrice": 0,
|
|
4174
|
+
// "orderType": "",
|
|
4175
|
+
// "workingType": "MARK_PRICE"
|
|
4176
|
+
// }
|
|
4177
|
+
// }
|
|
4178
|
+
// }
|
|
4179
|
+
//
|
|
4180
|
+
}
|
|
4181
|
+
else {
|
|
4182
|
+
response = await this.swapV2PrivateGetTradeOrder(this.extend(request, params));
|
|
4183
|
+
//
|
|
4184
|
+
// {
|
|
4185
|
+
// "code": 0,
|
|
4186
|
+
// "msg": "",
|
|
4187
|
+
// "data": {
|
|
4188
|
+
// "order": {
|
|
4189
|
+
// "symbol": "BTC-USDT",
|
|
4190
|
+
// "orderId": 1597597642269917184,
|
|
4191
|
+
// "side": "SELL",
|
|
4192
|
+
// "positionSide": "LONG",
|
|
4193
|
+
// "type": "TAKE_PROFIT_MARKET",
|
|
4194
|
+
// "origQty": "1.0000",
|
|
4195
|
+
// "price": "0.0",
|
|
4196
|
+
// "executedQty": "0.0000",
|
|
4197
|
+
// "avgPrice": "0.0",
|
|
4198
|
+
// "cumQuote": "",
|
|
4199
|
+
// "stopPrice": "16494.0",
|
|
4200
|
+
// "profit": "",
|
|
4201
|
+
// "commission": "",
|
|
4202
|
+
// "status": "FILLED",
|
|
4203
|
+
// "time": 1669731935000,
|
|
4204
|
+
// "updateTime": 1669752524000
|
|
4205
|
+
// }
|
|
4206
|
+
// }
|
|
4207
|
+
// }
|
|
4208
|
+
//
|
|
4209
|
+
}
|
|
4094
4210
|
}
|
|
4095
4211
|
}
|
|
4096
4212
|
const data = this.safeDict(response, 'data', {});
|
|
@@ -4195,10 +4311,12 @@ class bingx extends bingx$1 {
|
|
|
4195
4311
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Current%20Open%20Orders
|
|
4196
4312
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Current%20All%20Open%20Orders
|
|
4197
4313
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20all%20current%20pending%20orders
|
|
4314
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20TWAP%20Entrusted%20Order
|
|
4198
4315
|
* @param {string} symbol unified market symbol
|
|
4199
4316
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
4200
4317
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
4201
4318
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4319
|
+
* @param {boolean} [params.twap] if fetching twap open orders
|
|
4202
4320
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4203
4321
|
*/
|
|
4204
4322
|
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -4218,7 +4336,12 @@ class bingx extends bingx$1 {
|
|
|
4218
4336
|
response = await this.spotV1PrivateGetTradeOpenOrders(this.extend(request, params));
|
|
4219
4337
|
}
|
|
4220
4338
|
else {
|
|
4221
|
-
|
|
4339
|
+
const isTwapOrder = this.safeBool(params, 'twap', false);
|
|
4340
|
+
params = this.omit(params, 'twap');
|
|
4341
|
+
if (isTwapOrder) {
|
|
4342
|
+
response = await this.swapV1PrivateGetTwapOpenOrders(this.extend(request, params));
|
|
4343
|
+
}
|
|
4344
|
+
else if (subType === 'inverse') {
|
|
4222
4345
|
response = await this.cswapV1PrivateGetTradeOpenOrders(this.extend(request, params));
|
|
4223
4346
|
}
|
|
4224
4347
|
else {
|
|
@@ -4334,8 +4457,38 @@ class bingx extends bingx$1 {
|
|
|
4334
4457
|
// }
|
|
4335
4458
|
// }
|
|
4336
4459
|
//
|
|
4460
|
+
// twap
|
|
4461
|
+
//
|
|
4462
|
+
// {
|
|
4463
|
+
// "code": 0,
|
|
4464
|
+
// "msg": "",
|
|
4465
|
+
// "timestamp": 1702731661854,
|
|
4466
|
+
// "data": {
|
|
4467
|
+
// "list": [
|
|
4468
|
+
// {
|
|
4469
|
+
// "symbol": "BNB-USDT",
|
|
4470
|
+
// "side": "BUY",
|
|
4471
|
+
// "positionSide": "LONG",
|
|
4472
|
+
// "priceType": "constant",
|
|
4473
|
+
// "priceVariance": "2000",
|
|
4474
|
+
// "triggerPrice": "68000",
|
|
4475
|
+
// "interval": 8,
|
|
4476
|
+
// "amountPerOrder": "0.111",
|
|
4477
|
+
// "totalAmount": "0.511",
|
|
4478
|
+
// "orderStatus": "Running",
|
|
4479
|
+
// "executedQty": "0.1",
|
|
4480
|
+
// "duration": 800,
|
|
4481
|
+
// "maxDuration": 9000,
|
|
4482
|
+
// "createdTime": 1702731661854,
|
|
4483
|
+
// "updateTime": 1702731661854
|
|
4484
|
+
// }
|
|
4485
|
+
// ],
|
|
4486
|
+
// "total": 1
|
|
4487
|
+
// }
|
|
4488
|
+
// }
|
|
4489
|
+
//
|
|
4337
4490
|
const data = this.safeDict(response, 'data', {});
|
|
4338
|
-
const orders = this.
|
|
4491
|
+
const orders = this.safeList2(data, 'orders', 'list', []);
|
|
4339
4492
|
return this.parseOrders(orders, market, since, limit);
|
|
4340
4493
|
}
|
|
4341
4494
|
/**
|
|
@@ -4388,12 +4541,14 @@ class bingx extends bingx$1 {
|
|
|
4388
4541
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history
|
|
4389
4542
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#User's%20History%20Orders
|
|
4390
4543
|
* @see https://bingx-api.github.io/docs/#/standard/contract-interface.html#Historical%20order
|
|
4544
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20TWAP%20Historical%20Orders
|
|
4391
4545
|
* @param {string} [symbol] unified market symbol of the market orders were made in
|
|
4392
4546
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
4393
4547
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
4394
4548
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4395
4549
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
|
4396
4550
|
* @param {boolean} [params.standard] whether to fetch standard contract orders
|
|
4551
|
+
* @param {boolean} [params.twap] if fetching twap orders
|
|
4397
4552
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4398
4553
|
*/
|
|
4399
4554
|
async fetchCanceledAndClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -4446,7 +4601,47 @@ class bingx extends bingx$1 {
|
|
|
4446
4601
|
//
|
|
4447
4602
|
}
|
|
4448
4603
|
else {
|
|
4449
|
-
|
|
4604
|
+
const isTwapOrder = this.safeBool(params, 'twap', false);
|
|
4605
|
+
params = this.omit(params, 'twap');
|
|
4606
|
+
if (isTwapOrder) {
|
|
4607
|
+
request['pageIndex'] = 1;
|
|
4608
|
+
request['pageSize'] = (limit === undefined) ? 100 : limit;
|
|
4609
|
+
request['startTime'] = (since === undefined) ? 1 : since;
|
|
4610
|
+
const until = this.safeInteger(params, 'until', this.milliseconds());
|
|
4611
|
+
params = this.omit(params, 'until');
|
|
4612
|
+
request['endTime'] = until;
|
|
4613
|
+
response = await this.swapV1PrivateGetTwapHistoryOrders(this.extend(request, params));
|
|
4614
|
+
//
|
|
4615
|
+
// {
|
|
4616
|
+
// "code": 0,
|
|
4617
|
+
// "msg": "",
|
|
4618
|
+
// "timestamp": 1702731661854,
|
|
4619
|
+
// "data": {
|
|
4620
|
+
// "list": [
|
|
4621
|
+
// {
|
|
4622
|
+
// "symbol": "BNB-USDT",
|
|
4623
|
+
// "side": "BUY",
|
|
4624
|
+
// "positionSide": "LONG",
|
|
4625
|
+
// "priceType": "constant",
|
|
4626
|
+
// "priceVariance": "2000",
|
|
4627
|
+
// "triggerPrice": "68000",
|
|
4628
|
+
// "interval": 8,
|
|
4629
|
+
// "amountPerOrder": "0.111",
|
|
4630
|
+
// "totalAmount": "0.511",
|
|
4631
|
+
// "orderStatus": "Running",
|
|
4632
|
+
// "executedQty": "0.1",
|
|
4633
|
+
// "duration": 800,
|
|
4634
|
+
// "maxDuration": 9000,
|
|
4635
|
+
// "createdTime": 1702731661854,
|
|
4636
|
+
// "updateTime": 1702731661854
|
|
4637
|
+
// }
|
|
4638
|
+
// ],
|
|
4639
|
+
// "total": 1
|
|
4640
|
+
// }
|
|
4641
|
+
// }
|
|
4642
|
+
//
|
|
4643
|
+
}
|
|
4644
|
+
else if (subType === 'inverse') {
|
|
4450
4645
|
response = await this.cswapV1PrivateGetTradeOrderHistory(this.extend(request, params));
|
|
4451
4646
|
//
|
|
4452
4647
|
// {
|
|
@@ -4535,7 +4730,7 @@ class bingx extends bingx$1 {
|
|
|
4535
4730
|
}
|
|
4536
4731
|
}
|
|
4537
4732
|
const data = this.safeDict(response, 'data', {});
|
|
4538
|
-
const orders = this.
|
|
4733
|
+
const orders = this.safeList2(data, 'orders', 'list', []);
|
|
4539
4734
|
return this.parseOrders(orders, market, since, limit);
|
|
4540
4735
|
}
|
|
4541
4736
|
/**
|
|
@@ -6163,31 +6358,31 @@ class bingx extends bingx$1 {
|
|
|
6163
6358
|
path = this.implodeParams(path, params);
|
|
6164
6359
|
url += path;
|
|
6165
6360
|
params = this.omit(params, this.extractParams(path));
|
|
6361
|
+
params['timestamp'] = this.nonce();
|
|
6166
6362
|
params = this.keysort(params);
|
|
6167
6363
|
if (access === 'public') {
|
|
6168
|
-
params['timestamp'] = this.nonce();
|
|
6169
6364
|
if (Object.keys(params).length) {
|
|
6170
6365
|
url += '?' + this.urlencode(params);
|
|
6171
6366
|
}
|
|
6172
6367
|
}
|
|
6173
6368
|
else if (access === 'private') {
|
|
6174
6369
|
this.checkRequiredCredentials();
|
|
6175
|
-
|
|
6370
|
+
const isJsonContentType = ((type === 'subAccount') && (method === 'POST'));
|
|
6176
6371
|
const parsedParams = this.parseParams(params);
|
|
6177
|
-
let query = this.urlencode(parsedParams);
|
|
6178
6372
|
const signature = this.hmac(this.encode(this.rawencode(parsedParams)), this.encode(this.secret), sha256.sha256);
|
|
6179
|
-
if (Object.keys(params).length) {
|
|
6180
|
-
query = '?' + query + '&';
|
|
6181
|
-
}
|
|
6182
|
-
else {
|
|
6183
|
-
query += '?';
|
|
6184
|
-
}
|
|
6185
|
-
query += 'signature=' + signature;
|
|
6186
6373
|
headers = {
|
|
6187
6374
|
'X-BX-APIKEY': this.apiKey,
|
|
6188
6375
|
'X-SOURCE-KEY': this.safeString(this.options, 'broker', 'CCXT'),
|
|
6189
6376
|
};
|
|
6190
|
-
|
|
6377
|
+
if (isJsonContentType) {
|
|
6378
|
+
headers['Content-Type'] = 'application/json';
|
|
6379
|
+
parsedParams['signature'] = signature;
|
|
6380
|
+
body = this.json(parsedParams);
|
|
6381
|
+
}
|
|
6382
|
+
else {
|
|
6383
|
+
const query = this.urlencode(parsedParams);
|
|
6384
|
+
url += '?' + query + '&signature=' + signature;
|
|
6385
|
+
}
|
|
6191
6386
|
}
|
|
6192
6387
|
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
6193
6388
|
}
|