ccxt 4.4.33 → 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 +8 -7
- package/dist/ccxt.browser.min.js +6 -6
- package/dist/cjs/ccxt.js +4 -1
- package/dist/cjs/src/abstract/ellipx.js +9 -0
- package/dist/cjs/src/alpaca.js +2 -0
- package/dist/cjs/src/base/Exchange.js +32 -6
- package/dist/cjs/src/binance.js +19 -14
- package/dist/cjs/src/bingx.js +495 -153
- package/dist/cjs/src/bitbank.js +5 -0
- package/dist/cjs/src/bitbns.js +2 -0
- package/dist/cjs/src/bitfinex2.js +2 -1
- package/dist/cjs/src/bitget.js +177 -44
- package/dist/cjs/src/bitmex.js +3 -1
- package/dist/cjs/src/bitopro.js +3 -0
- package/dist/cjs/src/bitrue.js +3 -2
- package/dist/cjs/src/btcmarkets.js +5 -3
- package/dist/cjs/src/btcturk.js +19 -19
- package/dist/cjs/src/bybit.js +14 -11
- package/dist/cjs/src/cex.js +13 -4
- package/dist/cjs/src/coinbase.js +3 -2
- package/dist/cjs/src/coinex.js +1 -0
- package/dist/cjs/src/coinone.js +7 -7
- package/dist/cjs/src/coinsph.js +7 -7
- package/dist/cjs/src/coinspot.js +39 -39
- package/dist/cjs/src/cryptocom.js +36 -34
- package/dist/cjs/src/ellipx.js +1871 -0
- package/dist/cjs/src/gate.js +145 -41
- package/dist/cjs/src/hyperliquid.js +75 -11
- package/dist/cjs/src/idex.js +3 -3
- package/dist/cjs/src/kraken.js +71 -54
- package/dist/cjs/src/krakenfutures.js +3 -1
- package/dist/cjs/src/kucoin.js +1 -1
- package/dist/cjs/src/okcoin.js +2 -0
- package/dist/cjs/src/okx.js +16 -11
- package/dist/cjs/src/onetrading.js +34 -396
- package/dist/cjs/src/paradex.js +2 -0
- package/dist/cjs/src/phemex.js +23 -0
- package/dist/cjs/src/poloniex.js +3 -1
- package/dist/cjs/src/poloniexfutures.js +3 -1
- package/dist/cjs/src/pro/bitrue.js +13 -11
- package/dist/cjs/src/pro/idex.js +5 -0
- package/dist/cjs/src/pro/probit.js +62 -68
- package/dist/cjs/src/pro/woo.js +15 -15
- package/dist/cjs/src/vertex.js +2 -0
- package/dist/cjs/src/woo.js +69 -69
- package/dist/cjs/src/xt.js +5 -5
- package/examples/js/cli.js +1 -1
- package/js/ccxt.d.ts +5 -2
- package/js/ccxt.js +4 -2
- package/js/src/abstract/bingx.d.ts +17 -0
- package/js/src/abstract/bitbank.d.ts +5 -0
- package/js/src/abstract/bitfinex2.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/ellipx.d.ts +28 -0
- package/js/src/abstract/ellipx.js +11 -0
- package/js/src/abstract/okx.d.ts +1 -0
- package/js/src/abstract/onetrading.d.ts +0 -12
- package/js/src/alpaca.js +2 -0
- package/js/src/base/Exchange.d.ts +8 -0
- package/js/src/base/Exchange.js +32 -6
- package/js/src/binance.js +19 -14
- package/js/src/bingx.d.ts +11 -1
- package/js/src/bingx.js +495 -153
- package/js/src/bitbank.js +5 -0
- package/js/src/bitbns.js +2 -0
- package/js/src/bitfinex2.js +2 -1
- package/js/src/bitget.d.ts +4 -4
- package/js/src/bitget.js +177 -44
- package/js/src/bitmex.js +3 -1
- package/js/src/bitopro.d.ts +1 -0
- package/js/src/bitopro.js +3 -0
- package/js/src/bitrue.js +3 -2
- package/js/src/btcmarkets.d.ts +1 -0
- package/js/src/btcmarkets.js +5 -3
- package/js/src/btcturk.js +19 -19
- package/js/src/bybit.d.ts +3 -2
- package/js/src/bybit.js +14 -11
- package/js/src/cex.d.ts +1 -0
- package/js/src/cex.js +13 -4
- package/js/src/coinbase.d.ts +2 -1
- package/js/src/coinbase.js +3 -2
- package/js/src/coinex.js +1 -0
- package/js/src/coinone.js +7 -7
- package/js/src/coinsph.js +7 -7
- package/js/src/coinspot.js +39 -39
- package/js/src/cryptocom.d.ts +1 -1
- package/js/src/cryptocom.js +36 -34
- package/js/src/ellipx.d.ts +236 -0
- package/js/src/ellipx.js +1874 -0
- package/js/src/gate.d.ts +7 -7
- package/js/src/gate.js +145 -41
- package/js/src/hyperliquid.d.ts +10 -0
- package/js/src/hyperliquid.js +77 -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/krakenfutures.js +3 -1
- package/js/src/kucoin.js +1 -1
- package/js/src/okcoin.js +2 -0
- package/js/src/okx.d.ts +1 -1
- package/js/src/okx.js +16 -11
- package/js/src/onetrading.d.ts +20 -67
- package/js/src/onetrading.js +35 -397
- package/js/src/paradex.js +2 -0
- package/js/src/phemex.js +23 -0
- package/js/src/poloniex.d.ts +1 -1
- package/js/src/poloniex.js +3 -1
- package/js/src/poloniexfutures.d.ts +1 -1
- package/js/src/poloniexfutures.js +3 -1
- package/js/src/pro/bitrue.js +13 -11
- package/js/src/pro/idex.d.ts +5 -0
- package/js/src/pro/idex.js +5 -0
- package/js/src/pro/probit.d.ts +2 -1
- package/js/src/pro/probit.js +62 -68
- package/js/src/pro/woo.d.ts +11 -11
- package/js/src/pro/woo.js +15 -15
- package/js/src/vertex.js +2 -0
- package/js/src/woo.d.ts +60 -60
- package/js/src/woo.js +69 -69
- package/js/src/xt.js +5 -5
- package/package.json +4 -3
package/js/src/bingx.js
CHANGED
|
@@ -46,6 +46,7 @@ export default class bingx extends Exchange {
|
|
|
46
46
|
'createOrders': true,
|
|
47
47
|
'createOrderWithTakeProfitAndStopLoss': true,
|
|
48
48
|
'createStopLossOrder': true,
|
|
49
|
+
'createStopOrder': true,
|
|
49
50
|
'createTakeProfitOrder': true,
|
|
50
51
|
'createTrailingAmountOrder': true,
|
|
51
52
|
'createTrailingPercentOrder': true,
|
|
@@ -199,6 +200,8 @@ export default class bingx extends Exchange {
|
|
|
199
200
|
'get': {
|
|
200
201
|
'ticker/price': 1,
|
|
201
202
|
'market/historicalTrades': 1,
|
|
203
|
+
'market/markPriceKlines': 1,
|
|
204
|
+
'trade/multiAssetsRules': 1,
|
|
202
205
|
},
|
|
203
206
|
},
|
|
204
207
|
'private': {
|
|
@@ -207,12 +210,24 @@ export default class bingx extends Exchange {
|
|
|
207
210
|
'market/markPriceKlines': 1,
|
|
208
211
|
'trade/batchCancelReplace': 5,
|
|
209
212
|
'trade/fullOrder': 2,
|
|
213
|
+
'maintMarginRatio': 2,
|
|
214
|
+
'trade/positionHistory': 2,
|
|
210
215
|
'positionMargin/history': 2,
|
|
216
|
+
'twap/openOrders': 5,
|
|
217
|
+
'twap/historyOrders': 5,
|
|
218
|
+
'twap/orderDetail': 5,
|
|
219
|
+
'trade/assetMode': 5,
|
|
220
|
+
'user/marginAssets': 5,
|
|
211
221
|
},
|
|
212
222
|
'post': {
|
|
213
223
|
'trade/cancelReplace': 2,
|
|
214
224
|
'positionSide/dual': 5,
|
|
225
|
+
'trade/batchCancelReplace': 5,
|
|
215
226
|
'trade/closePosition': 2,
|
|
227
|
+
'trade/getVst': 5,
|
|
228
|
+
'twap/order': 5,
|
|
229
|
+
'twap/cancelOrder': 5,
|
|
230
|
+
'trade/assetMode': 5,
|
|
216
231
|
},
|
|
217
232
|
},
|
|
218
233
|
},
|
|
@@ -245,6 +260,7 @@ export default class bingx extends Exchange {
|
|
|
245
260
|
'trade/forceOrders': 1,
|
|
246
261
|
'trade/allOrders': 2,
|
|
247
262
|
'trade/allFillOrders': 2,
|
|
263
|
+
'trade/fillHistory': 2,
|
|
248
264
|
'user/income/export': 2,
|
|
249
265
|
'user/commissionRate': 2,
|
|
250
266
|
'quote/bookTicker': 1,
|
|
@@ -302,6 +318,7 @@ export default class bingx extends Exchange {
|
|
|
302
318
|
'post': {
|
|
303
319
|
'trade/order': 2,
|
|
304
320
|
'trade/leverage': 2,
|
|
321
|
+
'trade/allOpenOrders': 2,
|
|
305
322
|
'trade/closeAllPositions': 2,
|
|
306
323
|
'trade/marginType': 2,
|
|
307
324
|
'trade/positionMargin': 2,
|
|
@@ -351,6 +368,7 @@ export default class bingx extends Exchange {
|
|
|
351
368
|
'get': {
|
|
352
369
|
'list': 10,
|
|
353
370
|
'assets': 2,
|
|
371
|
+
'allAccountBalance': 2,
|
|
354
372
|
},
|
|
355
373
|
'post': {
|
|
356
374
|
'create': 10,
|
|
@@ -500,6 +518,136 @@ export default class bingx extends Exchange {
|
|
|
500
518
|
'MATIC': 'POLYGON',
|
|
501
519
|
},
|
|
502
520
|
},
|
|
521
|
+
'features': {
|
|
522
|
+
'defaultForLinear': {
|
|
523
|
+
'sandbox': true,
|
|
524
|
+
'createOrder': {
|
|
525
|
+
'marginMode': false,
|
|
526
|
+
'triggerPrice': true,
|
|
527
|
+
'triggerPriceType': {
|
|
528
|
+
'last': true,
|
|
529
|
+
'mark': true,
|
|
530
|
+
'index': true,
|
|
531
|
+
},
|
|
532
|
+
'triggerDirection': false,
|
|
533
|
+
'stopLossPrice': true,
|
|
534
|
+
'takeProfitPrice': true,
|
|
535
|
+
'attachedStopLossTakeProfit': {
|
|
536
|
+
'triggerPriceType': {
|
|
537
|
+
'last': true,
|
|
538
|
+
'mark': true,
|
|
539
|
+
'index': true,
|
|
540
|
+
},
|
|
541
|
+
'limitPrice': true,
|
|
542
|
+
},
|
|
543
|
+
'timeInForce': {
|
|
544
|
+
'GTC': true,
|
|
545
|
+
'IOC': true,
|
|
546
|
+
'FOK': true,
|
|
547
|
+
'PO': true,
|
|
548
|
+
'GTD': false,
|
|
549
|
+
},
|
|
550
|
+
'hedged': true,
|
|
551
|
+
'trailing': true,
|
|
552
|
+
},
|
|
553
|
+
'createOrders': {
|
|
554
|
+
'max': 5,
|
|
555
|
+
},
|
|
556
|
+
'fetchMyTrades': {
|
|
557
|
+
'marginMode': false,
|
|
558
|
+
'limit': 512,
|
|
559
|
+
'daysBack': 30,
|
|
560
|
+
'untilDays': 30, // 30 for 'allFillOrders', 7 for 'fillHistory'
|
|
561
|
+
},
|
|
562
|
+
'fetchOrder': {
|
|
563
|
+
'marginMode': false,
|
|
564
|
+
'trigger': false,
|
|
565
|
+
'trailing': false,
|
|
566
|
+
},
|
|
567
|
+
'fetchOpenOrders': {
|
|
568
|
+
'marginMode': false,
|
|
569
|
+
'limit': undefined,
|
|
570
|
+
'trigger': false,
|
|
571
|
+
'trailing': false,
|
|
572
|
+
},
|
|
573
|
+
'fetchOrders': {
|
|
574
|
+
'marginMode': false,
|
|
575
|
+
'limit': 1000,
|
|
576
|
+
'daysBack': 20000,
|
|
577
|
+
'untilDays': 7,
|
|
578
|
+
'trigger': false,
|
|
579
|
+
'trailing': false,
|
|
580
|
+
},
|
|
581
|
+
'fetchClosedOrders': {
|
|
582
|
+
'marginMode': false,
|
|
583
|
+
'limit': 1000,
|
|
584
|
+
'daysBackClosed': undefined,
|
|
585
|
+
'daysBackCanceled': undefined,
|
|
586
|
+
'untilDays': 7,
|
|
587
|
+
'trigger': false,
|
|
588
|
+
'trailing': false,
|
|
589
|
+
},
|
|
590
|
+
'fetchOHLCV': {
|
|
591
|
+
'limit': 1440,
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
'defaultForInverse': {
|
|
595
|
+
'extends': 'defaultForLinear',
|
|
596
|
+
'fetchMyTrades': {
|
|
597
|
+
'limit': 1000,
|
|
598
|
+
'daysBack': undefined,
|
|
599
|
+
'untilDays': undefined,
|
|
600
|
+
},
|
|
601
|
+
'fetchOHLCV': {
|
|
602
|
+
'limit': 1440,
|
|
603
|
+
},
|
|
604
|
+
'fetchOrders': undefined,
|
|
605
|
+
'fetchClosedOrders': {
|
|
606
|
+
'marginMode': false,
|
|
607
|
+
'limit': 1000,
|
|
608
|
+
'daysBackClosed': undefined,
|
|
609
|
+
'daysBackCanceled': undefined,
|
|
610
|
+
'untilDays': 7,
|
|
611
|
+
'trigger': false,
|
|
612
|
+
'trailing': false,
|
|
613
|
+
},
|
|
614
|
+
},
|
|
615
|
+
//
|
|
616
|
+
'spot': {
|
|
617
|
+
'extends': 'defaultForLinear',
|
|
618
|
+
'createOrder': {
|
|
619
|
+
'triggerPriceType': undefined,
|
|
620
|
+
'attachedStopLossTakeProfit': undefined,
|
|
621
|
+
'trailing': false,
|
|
622
|
+
},
|
|
623
|
+
'fetchMyTrades': {
|
|
624
|
+
'limit': 1000,
|
|
625
|
+
'daysBack': 1,
|
|
626
|
+
'untilDays': 1,
|
|
627
|
+
},
|
|
628
|
+
'fetchOrders': undefined,
|
|
629
|
+
'fetchClosedOrders': {
|
|
630
|
+
'limit': 100,
|
|
631
|
+
'untilDays': undefined,
|
|
632
|
+
},
|
|
633
|
+
},
|
|
634
|
+
'swap': {
|
|
635
|
+
'linear': {
|
|
636
|
+
'extends': 'defaultForLinear',
|
|
637
|
+
},
|
|
638
|
+
'inverse': {
|
|
639
|
+
'extends': 'defaultForInverse',
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
'future': {
|
|
643
|
+
'linear': {
|
|
644
|
+
'extends': 'defaultForLinear',
|
|
645
|
+
},
|
|
646
|
+
'inverse': {
|
|
647
|
+
'extends': 'defaultForInverse',
|
|
648
|
+
},
|
|
649
|
+
},
|
|
650
|
+
},
|
|
503
651
|
});
|
|
504
652
|
}
|
|
505
653
|
/**
|
|
@@ -2541,6 +2689,10 @@ export default class bingx extends Exchange {
|
|
|
2541
2689
|
};
|
|
2542
2690
|
const isMarketOrder = type === 'MARKET';
|
|
2543
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
|
+
}
|
|
2544
2696
|
const stopLossPrice = this.safeString(params, 'stopLossPrice');
|
|
2545
2697
|
const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
|
|
2546
2698
|
const triggerPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
|
|
@@ -2606,6 +2758,27 @@ export default class bingx extends Exchange {
|
|
|
2606
2758
|
}
|
|
2607
2759
|
}
|
|
2608
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
|
+
}
|
|
2609
2782
|
if (timeInForce === 'FOK') {
|
|
2610
2783
|
request['timeInForce'] = 'FOK';
|
|
2611
2784
|
}
|
|
@@ -2728,6 +2901,7 @@ export default class bingx extends Exchange {
|
|
|
2728
2901
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Trade%20order
|
|
2729
2902
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Create%20an%20Order
|
|
2730
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
|
|
2731
2905
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
2732
2906
|
* @param {string} type 'market' or 'limit'
|
|
2733
2907
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -2767,6 +2941,9 @@ export default class bingx extends Exchange {
|
|
|
2767
2941
|
else if (market['inverse']) {
|
|
2768
2942
|
response = await this.cswapV1PrivatePostTradeOrder(request);
|
|
2769
2943
|
}
|
|
2944
|
+
else if (type === 'twap') {
|
|
2945
|
+
response = await this.swapV1PrivatePostTwapOrder(request);
|
|
2946
|
+
}
|
|
2770
2947
|
else {
|
|
2771
2948
|
response = await this.swapV2PrivatePostTradeOrder(request);
|
|
2772
2949
|
}
|
|
@@ -2827,6 +3004,17 @@ export default class bingx extends Exchange {
|
|
|
2827
3004
|
// "timeInForce": ""
|
|
2828
3005
|
// }
|
|
2829
3006
|
//
|
|
3007
|
+
// twap order
|
|
3008
|
+
//
|
|
3009
|
+
// {
|
|
3010
|
+
// "code": 0,
|
|
3011
|
+
// "msg": "",
|
|
3012
|
+
// "timestamp": 1732693774386,
|
|
3013
|
+
// "data": {
|
|
3014
|
+
// "mainOrderId": "4633860139993029715"
|
|
3015
|
+
// }
|
|
3016
|
+
// }
|
|
3017
|
+
//
|
|
2830
3018
|
if (typeof response === 'string') {
|
|
2831
3019
|
// broken api engine : order-ids are too long numbers (i.e. 1742930526912864656)
|
|
2832
3020
|
// and JSON.parse can not handle them in JS, so we have to use .parseJson
|
|
@@ -2841,7 +3029,7 @@ export default class bingx extends Exchange {
|
|
|
2841
3029
|
result = response;
|
|
2842
3030
|
}
|
|
2843
3031
|
else {
|
|
2844
|
-
result = this.safeDict(data, 'order',
|
|
3032
|
+
result = this.safeDict(data, 'order', data);
|
|
2845
3033
|
}
|
|
2846
3034
|
}
|
|
2847
3035
|
else {
|
|
@@ -3269,9 +3457,9 @@ export default class bingx extends Exchange {
|
|
|
3269
3457
|
market = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
3270
3458
|
}
|
|
3271
3459
|
const side = this.safeStringLower2(order, 'side', 'S');
|
|
3272
|
-
const timestamp = this.safeIntegerN(order, ['time', 'transactTime', 'E']);
|
|
3460
|
+
const timestamp = this.safeIntegerN(order, ['time', 'transactTime', 'E', 'createdTime']);
|
|
3273
3461
|
const lastTradeTimestamp = this.safeInteger2(order, 'updateTime', 'T');
|
|
3274
|
-
const statusId = this.
|
|
3462
|
+
const statusId = this.safeStringUpperN(order, ['status', 'X', 'orderStatus']);
|
|
3275
3463
|
let feeCurrencyCode = this.safeString2(order, 'feeAsset', 'N');
|
|
3276
3464
|
const feeCost = this.safeStringN(order, ['fee', 'commission', 'n']);
|
|
3277
3465
|
if ((feeCurrencyCode === undefined)) {
|
|
@@ -3326,7 +3514,7 @@ export default class bingx extends Exchange {
|
|
|
3326
3514
|
}
|
|
3327
3515
|
return this.safeOrder({
|
|
3328
3516
|
'info': info,
|
|
3329
|
-
'id': this.
|
|
3517
|
+
'id': this.safeStringN(order, ['orderId', 'i', 'mainOrderId']),
|
|
3330
3518
|
'clientOrderId': this.safeStringN(order, ['clientOrderID', 'clientOrderId', 'origClientOrderId', 'c']),
|
|
3331
3519
|
'symbol': this.safeSymbol(marketId, market, '-', marketType),
|
|
3332
3520
|
'timestamp': timestamp,
|
|
@@ -3344,7 +3532,7 @@ export default class bingx extends Exchange {
|
|
|
3344
3532
|
'takeProfitPrice': takeProfitPrice,
|
|
3345
3533
|
'average': this.safeString2(order, 'avgPrice', 'ap'),
|
|
3346
3534
|
'cost': this.safeString(order, 'cummulativeQuoteQty'),
|
|
3347
|
-
'amount': this.safeStringN(order, ['origQty', 'q', 'quantity']),
|
|
3535
|
+
'amount': this.safeStringN(order, ['origQty', 'q', 'quantity', 'totalAmount']),
|
|
3348
3536
|
'filled': this.safeString2(order, 'executedQty', 'z'),
|
|
3349
3537
|
'remaining': undefined,
|
|
3350
3538
|
'status': this.parseOrderStatus(statusId),
|
|
@@ -3361,6 +3549,7 @@ export default class bingx extends Exchange {
|
|
|
3361
3549
|
'NEW': 'open',
|
|
3362
3550
|
'PENDING': 'open',
|
|
3363
3551
|
'PARTIALLY_FILLED': 'open',
|
|
3552
|
+
'RUNNING': 'open',
|
|
3364
3553
|
'FILLED': 'closed',
|
|
3365
3554
|
'CANCELED': 'canceled',
|
|
3366
3555
|
'CANCELLED': 'canceled',
|
|
@@ -3375,6 +3564,7 @@ export default class bingx extends Exchange {
|
|
|
3375
3564
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20Order
|
|
3376
3565
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20Order
|
|
3377
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
|
|
3378
3568
|
* @param {string} id order id
|
|
3379
3569
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
3380
3570
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -3382,36 +3572,71 @@ export default class bingx extends Exchange {
|
|
|
3382
3572
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3383
3573
|
*/
|
|
3384
3574
|
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
3385
|
-
if (symbol === undefined) {
|
|
3386
|
-
throw new ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
|
|
3387
|
-
}
|
|
3388
3575
|
await this.loadMarkets();
|
|
3389
|
-
const
|
|
3390
|
-
|
|
3391
|
-
'symbol': market['id'],
|
|
3392
|
-
};
|
|
3393
|
-
const clientOrderId = this.safeString2(params, 'clientOrderId', 'clientOrderID');
|
|
3394
|
-
params = this.omit(params, ['clientOrderId']);
|
|
3395
|
-
if (clientOrderId !== undefined) {
|
|
3396
|
-
request['clientOrderID'] = clientOrderId;
|
|
3397
|
-
}
|
|
3398
|
-
else {
|
|
3399
|
-
request['orderId'] = id;
|
|
3400
|
-
}
|
|
3576
|
+
const isTwapOrder = this.safeBool(params, 'twap', false);
|
|
3577
|
+
params = this.omit(params, 'twap');
|
|
3401
3578
|
let response = undefined;
|
|
3402
|
-
let
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
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
|
+
//
|
|
3408
3609
|
}
|
|
3409
3610
|
else {
|
|
3410
|
-
if (
|
|
3411
|
-
|
|
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));
|
|
3412
3632
|
}
|
|
3413
3633
|
else {
|
|
3414
|
-
|
|
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
|
+
}
|
|
3415
3640
|
}
|
|
3416
3641
|
}
|
|
3417
3642
|
//
|
|
@@ -3819,134 +4044,172 @@ export default class bingx extends Exchange {
|
|
|
3819
4044
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20details
|
|
3820
4045
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20details
|
|
3821
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
|
|
3822
4048
|
* @param {string} id the order id
|
|
3823
4049
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
3824
4050
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4051
|
+
* @param {boolean} [params.twap] if fetching twap order
|
|
3825
4052
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3826
4053
|
*/
|
|
3827
4054
|
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
3828
|
-
if (symbol === undefined) {
|
|
3829
|
-
throw new ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
|
|
3830
|
-
}
|
|
3831
4055
|
await this.loadMarkets();
|
|
3832
|
-
const
|
|
3833
|
-
|
|
3834
|
-
'symbol': market['id'],
|
|
3835
|
-
'orderId': id,
|
|
3836
|
-
};
|
|
3837
|
-
let type = undefined;
|
|
3838
|
-
let subType = undefined;
|
|
4056
|
+
const isTwapOrder = this.safeBool(params, 'twap', false);
|
|
4057
|
+
params = this.omit(params, 'twap');
|
|
3839
4058
|
let response = undefined;
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
4059
|
+
let market = undefined;
|
|
4060
|
+
if (isTwapOrder) {
|
|
4061
|
+
const twapRequest = {
|
|
4062
|
+
'mainOrderId': id,
|
|
4063
|
+
};
|
|
4064
|
+
response = await this.swapV1PrivateGetTwapOrderDetail(this.extend(twapRequest, params));
|
|
3844
4065
|
//
|
|
3845
4066
|
// {
|
|
3846
4067
|
// "code": 0,
|
|
3847
|
-
// "msg": "",
|
|
4068
|
+
// "msg": "success cancel order",
|
|
4069
|
+
// "timestamp": 1732760856617,
|
|
3848
4070
|
// "data": {
|
|
3849
|
-
// "symbol": "
|
|
3850
|
-
// "
|
|
3851
|
-
// "price": "0.5",
|
|
3852
|
-
// "origQty": "10",
|
|
3853
|
-
// "executedQty": "0",
|
|
3854
|
-
// "cummulativeQuoteQty": "0",
|
|
3855
|
-
// "status": "CANCELED",
|
|
3856
|
-
// "type": "LIMIT",
|
|
4071
|
+
// "symbol": "LTC-USDT",
|
|
4072
|
+
// "mainOrderId": "5596903086063901779",
|
|
3857
4073
|
// "side": "BUY",
|
|
3858
|
-
// "
|
|
3859
|
-
// "
|
|
3860
|
-
// "
|
|
3861
|
-
// "
|
|
3862
|
-
// "
|
|
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
|
|
3863
4087
|
// }
|
|
3864
4088
|
// }
|
|
3865
4089
|
//
|
|
3866
4090
|
}
|
|
3867
4091
|
else {
|
|
3868
|
-
if (
|
|
3869
|
-
|
|
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));
|
|
3870
4106
|
//
|
|
3871
4107
|
// {
|
|
3872
4108
|
// "code": 0,
|
|
3873
4109
|
// "msg": "",
|
|
3874
4110
|
// "data": {
|
|
3875
|
-
// "
|
|
3876
|
-
//
|
|
3877
|
-
//
|
|
3878
|
-
//
|
|
3879
|
-
//
|
|
3880
|
-
//
|
|
3881
|
-
//
|
|
3882
|
-
//
|
|
3883
|
-
//
|
|
3884
|
-
//
|
|
3885
|
-
//
|
|
3886
|
-
//
|
|
3887
|
-
//
|
|
3888
|
-
//
|
|
3889
|
-
// "commission": "0.0000",
|
|
3890
|
-
// "status": "Pending",
|
|
3891
|
-
// "time": 1721884753767,
|
|
3892
|
-
// "updateTime": 1721884753786,
|
|
3893
|
-
// "clientOrderId": "",
|
|
3894
|
-
// "leverage": "",
|
|
3895
|
-
// "takeProfit": {
|
|
3896
|
-
// "type": "TAKE_PROFIT",
|
|
3897
|
-
// "quantity": 0,
|
|
3898
|
-
// "stopPrice": 0,
|
|
3899
|
-
// "price": 0,
|
|
3900
|
-
// "workingType": "MARK_PRICE",
|
|
3901
|
-
// "stopGuaranteed": ""
|
|
3902
|
-
// },
|
|
3903
|
-
// "stopLoss": {
|
|
3904
|
-
// "type": "STOP",
|
|
3905
|
-
// "quantity": 0,
|
|
3906
|
-
// "stopPrice": 0,
|
|
3907
|
-
// "price": 0,
|
|
3908
|
-
// "workingType": "MARK_PRICE",
|
|
3909
|
-
// "stopGuaranteed": ""
|
|
3910
|
-
// },
|
|
3911
|
-
// "advanceAttr": 0,
|
|
3912
|
-
// "positionID": 0,
|
|
3913
|
-
// "takeProfitEntrustPrice": 0,
|
|
3914
|
-
// "stopLossEntrustPrice": 0,
|
|
3915
|
-
// "orderType": "",
|
|
3916
|
-
// "workingType": "MARK_PRICE"
|
|
3917
|
-
// }
|
|
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"
|
|
3918
4125
|
// }
|
|
3919
4126
|
// }
|
|
3920
4127
|
//
|
|
3921
4128
|
}
|
|
3922
4129
|
else {
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
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
|
+
}
|
|
3950
4213
|
}
|
|
3951
4214
|
}
|
|
3952
4215
|
const data = this.safeDict(response, 'data', {});
|
|
@@ -3957,7 +4220,8 @@ export default class bingx extends Exchange {
|
|
|
3957
4220
|
* @method
|
|
3958
4221
|
* @name bingx#fetchOrders
|
|
3959
4222
|
* @description fetches information on multiple orders made by the user
|
|
3960
|
-
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#
|
|
4223
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#All%20Orders
|
|
4224
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history (returns less fields than above)
|
|
3961
4225
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
3962
4226
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
3963
4227
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -3968,7 +4232,7 @@ export default class bingx extends Exchange {
|
|
|
3968
4232
|
*/
|
|
3969
4233
|
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3970
4234
|
await this.loadMarkets();
|
|
3971
|
-
|
|
4235
|
+
let request = {};
|
|
3972
4236
|
let market = undefined;
|
|
3973
4237
|
if (symbol !== undefined) {
|
|
3974
4238
|
market = this.market(symbol);
|
|
@@ -3985,12 +4249,7 @@ export default class bingx extends Exchange {
|
|
|
3985
4249
|
if (since !== undefined) {
|
|
3986
4250
|
request['startTime'] = since;
|
|
3987
4251
|
}
|
|
3988
|
-
|
|
3989
|
-
const endTime = this.safeInteger(params, 'endTime', until); // exchange-specific in milliseconds
|
|
3990
|
-
params = this.omit(params, ['endTime', 'until']);
|
|
3991
|
-
if (endTime !== undefined) {
|
|
3992
|
-
request['endTime'] = endTime;
|
|
3993
|
-
}
|
|
4252
|
+
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
3994
4253
|
const response = await this.swapV1PrivateGetTradeFullOrder(this.extend(request, params));
|
|
3995
4254
|
//
|
|
3996
4255
|
// {
|
|
@@ -4055,10 +4314,12 @@ export default class bingx extends Exchange {
|
|
|
4055
4314
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Current%20Open%20Orders
|
|
4056
4315
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Current%20All%20Open%20Orders
|
|
4057
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
|
|
4058
4318
|
* @param {string} symbol unified market symbol
|
|
4059
4319
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
4060
4320
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
4061
4321
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4322
|
+
* @param {boolean} [params.twap] if fetching twap open orders
|
|
4062
4323
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4063
4324
|
*/
|
|
4064
4325
|
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -4078,7 +4339,12 @@ export default class bingx extends Exchange {
|
|
|
4078
4339
|
response = await this.spotV1PrivateGetTradeOpenOrders(this.extend(request, params));
|
|
4079
4340
|
}
|
|
4080
4341
|
else {
|
|
4081
|
-
|
|
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') {
|
|
4082
4348
|
response = await this.cswapV1PrivateGetTradeOpenOrders(this.extend(request, params));
|
|
4083
4349
|
}
|
|
4084
4350
|
else {
|
|
@@ -4194,8 +4460,38 @@ export default class bingx extends Exchange {
|
|
|
4194
4460
|
// }
|
|
4195
4461
|
// }
|
|
4196
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
|
+
//
|
|
4197
4493
|
const data = this.safeDict(response, 'data', {});
|
|
4198
|
-
const orders = this.
|
|
4494
|
+
const orders = this.safeList2(data, 'orders', 'list', []);
|
|
4199
4495
|
return this.parseOrders(orders, market, since, limit);
|
|
4200
4496
|
}
|
|
4201
4497
|
/**
|
|
@@ -4248,12 +4544,14 @@ export default class bingx extends Exchange {
|
|
|
4248
4544
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history
|
|
4249
4545
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#User's%20History%20Orders
|
|
4250
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
|
|
4251
4548
|
* @param {string} [symbol] unified market symbol of the market orders were made in
|
|
4252
4549
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
4253
4550
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
4254
4551
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4255
4552
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
|
4256
4553
|
* @param {boolean} [params.standard] whether to fetch standard contract orders
|
|
4554
|
+
* @param {boolean} [params.twap] if fetching twap orders
|
|
4257
4555
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4258
4556
|
*/
|
|
4259
4557
|
async fetchCanceledAndClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -4276,6 +4574,9 @@ export default class bingx extends Exchange {
|
|
|
4276
4574
|
response = await this.contractV1PrivateGetAllOrders(this.extend(request, params));
|
|
4277
4575
|
}
|
|
4278
4576
|
else if (type === 'spot') {
|
|
4577
|
+
if (limit !== undefined) {
|
|
4578
|
+
request['limit'] = limit;
|
|
4579
|
+
}
|
|
4279
4580
|
response = await this.spotV1PrivateGetTradeHistoryOrders(this.extend(request, params));
|
|
4280
4581
|
//
|
|
4281
4582
|
// {
|
|
@@ -4303,7 +4604,47 @@ export default class bingx extends Exchange {
|
|
|
4303
4604
|
//
|
|
4304
4605
|
}
|
|
4305
4606
|
else {
|
|
4306
|
-
|
|
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') {
|
|
4307
4648
|
response = await this.cswapV1PrivateGetTradeOrderHistory(this.extend(request, params));
|
|
4308
4649
|
//
|
|
4309
4650
|
// {
|
|
@@ -4392,7 +4733,7 @@ export default class bingx extends Exchange {
|
|
|
4392
4733
|
}
|
|
4393
4734
|
}
|
|
4394
4735
|
const data = this.safeDict(response, 'data', {});
|
|
4395
|
-
const orders = this.
|
|
4736
|
+
const orders = this.safeList2(data, 'orders', 'list', []);
|
|
4396
4737
|
return this.parseOrders(orders, market, since, limit);
|
|
4397
4738
|
}
|
|
4398
4739
|
/**
|
|
@@ -5098,6 +5439,7 @@ export default class bingx extends Exchange {
|
|
|
5098
5439
|
* @description fetch all trades made by the user
|
|
5099
5440
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20transaction%20details
|
|
5100
5441
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20historical%20transaction%20orders
|
|
5442
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20historical%20transaction%20details
|
|
5101
5443
|
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Order%20Trade%20Detail
|
|
5102
5444
|
* @param {string} [symbol] unified market symbol
|
|
5103
5445
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
@@ -5161,7 +5503,7 @@ export default class bingx extends Exchange {
|
|
|
5161
5503
|
request[startTimeReq] = since;
|
|
5162
5504
|
}
|
|
5163
5505
|
else if (market['swap']) {
|
|
5164
|
-
request['startTs'] = now -
|
|
5506
|
+
request['startTs'] = now - 30 * 24 * 60 * 60 * 1000; // 30 days for swap
|
|
5165
5507
|
}
|
|
5166
5508
|
const until = this.safeInteger(params, 'until');
|
|
5167
5509
|
params = this.omit(params, 'until');
|
|
@@ -6019,31 +6361,31 @@ export default class bingx extends Exchange {
|
|
|
6019
6361
|
path = this.implodeParams(path, params);
|
|
6020
6362
|
url += path;
|
|
6021
6363
|
params = this.omit(params, this.extractParams(path));
|
|
6364
|
+
params['timestamp'] = this.nonce();
|
|
6022
6365
|
params = this.keysort(params);
|
|
6023
6366
|
if (access === 'public') {
|
|
6024
|
-
params['timestamp'] = this.nonce();
|
|
6025
6367
|
if (Object.keys(params).length) {
|
|
6026
6368
|
url += '?' + this.urlencode(params);
|
|
6027
6369
|
}
|
|
6028
6370
|
}
|
|
6029
6371
|
else if (access === 'private') {
|
|
6030
6372
|
this.checkRequiredCredentials();
|
|
6031
|
-
|
|
6373
|
+
const isJsonContentType = ((type === 'subAccount') && (method === 'POST'));
|
|
6032
6374
|
const parsedParams = this.parseParams(params);
|
|
6033
|
-
let query = this.urlencode(parsedParams);
|
|
6034
6375
|
const signature = this.hmac(this.encode(this.rawencode(parsedParams)), this.encode(this.secret), sha256);
|
|
6035
|
-
if (Object.keys(params).length) {
|
|
6036
|
-
query = '?' + query + '&';
|
|
6037
|
-
}
|
|
6038
|
-
else {
|
|
6039
|
-
query += '?';
|
|
6040
|
-
}
|
|
6041
|
-
query += 'signature=' + signature;
|
|
6042
6376
|
headers = {
|
|
6043
6377
|
'X-BX-APIKEY': this.apiKey,
|
|
6044
6378
|
'X-SOURCE-KEY': this.safeString(this.options, 'broker', 'CCXT'),
|
|
6045
6379
|
};
|
|
6046
|
-
|
|
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
|
+
}
|
|
6047
6389
|
}
|
|
6048
6390
|
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
6049
6391
|
}
|