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