ccxt 4.4.34__py2.py3-none-any.whl → 4.4.36__py2.py3-none-any.whl
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.
- ccxt/__init__.py +3 -1
- ccxt/abstract/bingx.py +1 -0
- ccxt/abstract/bitopro.py +1 -0
- ccxt/abstract/bitpanda.py +0 -12
- ccxt/abstract/bitrue.py +3 -3
- ccxt/abstract/bybit.py +15 -0
- ccxt/abstract/defx.py +69 -0
- ccxt/abstract/deribit.py +1 -0
- ccxt/abstract/gate.py +14 -0
- ccxt/abstract/gateio.py +14 -0
- ccxt/abstract/okx.py +1 -0
- ccxt/abstract/onetrading.py +0 -12
- ccxt/abstract/xt.py +5 -5
- ccxt/async_support/__init__.py +3 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/bingx.py +324 -138
- ccxt/async_support/bitfinex2.py +18 -13
- ccxt/async_support/bitmex.py +104 -2
- ccxt/async_support/bitopro.py +21 -4
- ccxt/async_support/bitrue.py +2 -2
- ccxt/async_support/bitso.py +2 -1
- ccxt/async_support/btcmarkets.py +3 -3
- ccxt/async_support/btcturk.py +19 -19
- ccxt/async_support/bybit.py +21 -1
- ccxt/async_support/defx.py +1981 -0
- ccxt/async_support/deribit.py +27 -12
- ccxt/async_support/gate.py +156 -39
- ccxt/async_support/htx.py +11 -2
- ccxt/async_support/hyperliquid.py +68 -11
- ccxt/async_support/idex.py +3 -4
- ccxt/async_support/kraken.py +97 -90
- ccxt/async_support/kucoin.py +1 -1
- ccxt/async_support/okx.py +1 -0
- ccxt/async_support/onetrading.py +47 -369
- ccxt/async_support/xt.py +10 -10
- ccxt/base/exchange.py +2 -1
- ccxt/bingx.py +324 -138
- ccxt/bitfinex2.py +18 -13
- ccxt/bitmex.py +104 -2
- ccxt/bitopro.py +21 -4
- ccxt/bitrue.py +2 -2
- ccxt/bitso.py +2 -1
- ccxt/btcmarkets.py +3 -3
- ccxt/btcturk.py +19 -19
- ccxt/bybit.py +21 -1
- ccxt/defx.py +1980 -0
- ccxt/deribit.py +27 -12
- ccxt/gate.py +156 -39
- ccxt/htx.py +11 -2
- ccxt/hyperliquid.py +68 -11
- ccxt/idex.py +3 -4
- ccxt/kraken.py +97 -90
- ccxt/kucoin.py +1 -1
- ccxt/okx.py +1 -0
- ccxt/onetrading.py +47 -369
- ccxt/pro/__init__.py +3 -1
- ccxt/pro/bitrue.py +13 -11
- ccxt/pro/defx.py +832 -0
- ccxt/pro/probit.py +54 -66
- ccxt/test/tests_async.py +44 -3
- ccxt/test/tests_sync.py +44 -3
- ccxt/xt.py +10 -10
- {ccxt-4.4.34.dist-info → ccxt-4.4.36.dist-info}/METADATA +7 -6
- {ccxt-4.4.34.dist-info → ccxt-4.4.36.dist-info}/RECORD +67 -63
- {ccxt-4.4.34.dist-info → ccxt-4.4.36.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.34.dist-info → ccxt-4.4.36.dist-info}/WHEEL +0 -0
- {ccxt-4.4.34.dist-info → ccxt-4.4.36.dist-info}/top_level.txt +0 -0
ccxt/async_support/bingx.py
CHANGED
@@ -381,6 +381,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
381
381
|
'get': {
|
382
382
|
'list': 10,
|
383
383
|
'assets': 2,
|
384
|
+
'allAccountBalance': 2,
|
384
385
|
},
|
385
386
|
'post': {
|
386
387
|
'create': 10,
|
@@ -2598,6 +2599,9 @@ class bingx(Exchange, ImplicitAPI):
|
|
2598
2599
|
}
|
2599
2600
|
isMarketOrder = type == 'MARKET'
|
2600
2601
|
isSpot = marketType == 'spot'
|
2602
|
+
isTwapOrder = type == 'TWAP'
|
2603
|
+
if isTwapOrder and isSpot:
|
2604
|
+
raise BadSymbol(self.id + ' createOrder() twap order supports swap contracts only')
|
2601
2605
|
stopLossPrice = self.safe_string(params, 'stopLossPrice')
|
2602
2606
|
takeProfitPrice = self.safe_string(params, 'takeProfitPrice')
|
2603
2607
|
triggerPrice = self.safe_string_2(params, 'stopPrice', 'triggerPrice')
|
@@ -2646,6 +2650,26 @@ class bingx(Exchange, ImplicitAPI):
|
|
2646
2650
|
request['type'] = 'TAKE_STOP_MARKET'
|
2647
2651
|
request['stopPrice'] = self.parse_to_numeric(self.price_to_precision(symbol, stopTakePrice))
|
2648
2652
|
else:
|
2653
|
+
if isTwapOrder:
|
2654
|
+
twapRequest: dict = {
|
2655
|
+
'symbol': request['symbol'],
|
2656
|
+
'side': request['side'],
|
2657
|
+
'positionSide': 'LONG' if (side == 'buy') else 'SHORT',
|
2658
|
+
'triggerPrice': self.parse_to_numeric(self.price_to_precision(symbol, triggerPrice)),
|
2659
|
+
'totalAmount': self.parse_to_numeric(self.amount_to_precision(symbol, amount)),
|
2660
|
+
}
|
2661
|
+
# {
|
2662
|
+
# "symbol": "LTC-USDT",
|
2663
|
+
# "side": "BUY",
|
2664
|
+
# "positionSide": "LONG",
|
2665
|
+
# "priceType": "constant",
|
2666
|
+
# "priceVariance": "10",
|
2667
|
+
# "triggerPrice": "120",
|
2668
|
+
# "interval": 8,
|
2669
|
+
# "amountPerOrder": "0.5",
|
2670
|
+
# "totalAmount": "1"
|
2671
|
+
# }
|
2672
|
+
return self.extend(twapRequest, params)
|
2649
2673
|
if timeInForce == 'FOK':
|
2650
2674
|
request['timeInForce'] = 'FOK'
|
2651
2675
|
trailingAmount = self.safe_string(params, 'trailingAmount')
|
@@ -2743,6 +2767,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2743
2767
|
https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Trade%20order
|
2744
2768
|
https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Create%20an%20Order
|
2745
2769
|
https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Trade%20order
|
2770
|
+
https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Place%20TWAP%20Order
|
2746
2771
|
|
2747
2772
|
:param str symbol: unified symbol of the market to create an order in
|
2748
2773
|
:param str type: 'market' or 'limit'
|
@@ -2780,6 +2805,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
2780
2805
|
response = await self.swapV2PrivatePostTradeOrderTest(request)
|
2781
2806
|
elif market['inverse']:
|
2782
2807
|
response = await self.cswapV1PrivatePostTradeOrder(request)
|
2808
|
+
elif type == 'twap':
|
2809
|
+
response = await self.swapV1PrivatePostTwapOrder(request)
|
2783
2810
|
else:
|
2784
2811
|
response = await self.swapV2PrivatePostTradeOrder(request)
|
2785
2812
|
else:
|
@@ -2837,6 +2864,17 @@ class bingx(Exchange, ImplicitAPI):
|
|
2837
2864
|
# "timeInForce": ""
|
2838
2865
|
# }
|
2839
2866
|
#
|
2867
|
+
# twap order
|
2868
|
+
#
|
2869
|
+
# {
|
2870
|
+
# "code": 0,
|
2871
|
+
# "msg": "",
|
2872
|
+
# "timestamp": 1732693774386,
|
2873
|
+
# "data": {
|
2874
|
+
# "mainOrderId": "4633860139993029715"
|
2875
|
+
# }
|
2876
|
+
# }
|
2877
|
+
#
|
2840
2878
|
if isinstance(response, str):
|
2841
2879
|
# broken api engine : order-ids are too long numbers(i.e. 1742930526912864656)
|
2842
2880
|
# and json.loadscan not handle them in JS, so we have to use .parseJson
|
@@ -2849,7 +2887,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2849
2887
|
if market['inverse']:
|
2850
2888
|
result = response
|
2851
2889
|
else:
|
2852
|
-
result = self.safe_dict(data, 'order',
|
2890
|
+
result = self.safe_dict(data, 'order', data)
|
2853
2891
|
else:
|
2854
2892
|
result = data
|
2855
2893
|
return self.parse_order(result, market)
|
@@ -3266,9 +3304,9 @@ class bingx(Exchange, ImplicitAPI):
|
|
3266
3304
|
if market is None:
|
3267
3305
|
market = self.safe_market(marketId, None, None, marketType)
|
3268
3306
|
side = self.safe_string_lower_2(order, 'side', 'S')
|
3269
|
-
timestamp = self.safe_integer_n(order, ['time', 'transactTime', 'E'])
|
3307
|
+
timestamp = self.safe_integer_n(order, ['time', 'transactTime', 'E', 'createdTime'])
|
3270
3308
|
lastTradeTimestamp = self.safe_integer_2(order, 'updateTime', 'T')
|
3271
|
-
statusId = self.
|
3309
|
+
statusId = self.safe_string_upper_n(order, ['status', 'X', 'orderStatus'])
|
3272
3310
|
feeCurrencyCode = self.safe_string_2(order, 'feeAsset', 'N')
|
3273
3311
|
feeCost = self.safe_string_n(order, ['fee', 'commission', 'n'])
|
3274
3312
|
if (feeCurrencyCode is None):
|
@@ -3309,7 +3347,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3309
3347
|
triggerPrice = None
|
3310
3348
|
return self.safe_order({
|
3311
3349
|
'info': info,
|
3312
|
-
'id': self.
|
3350
|
+
'id': self.safe_string_n(order, ['orderId', 'i', 'mainOrderId']),
|
3313
3351
|
'clientOrderId': self.safe_string_n(order, ['clientOrderID', 'clientOrderId', 'origClientOrderId', 'c']),
|
3314
3352
|
'symbol': self.safe_symbol(marketId, market, '-', marketType),
|
3315
3353
|
'timestamp': timestamp,
|
@@ -3327,7 +3365,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3327
3365
|
'takeProfitPrice': takeProfitPrice,
|
3328
3366
|
'average': self.safe_string_2(order, 'avgPrice', 'ap'),
|
3329
3367
|
'cost': self.safe_string(order, 'cummulativeQuoteQty'),
|
3330
|
-
'amount': self.safe_string_n(order, ['origQty', 'q', 'quantity']),
|
3368
|
+
'amount': self.safe_string_n(order, ['origQty', 'q', 'quantity', 'totalAmount']),
|
3331
3369
|
'filled': self.safe_string_2(order, 'executedQty', 'z'),
|
3332
3370
|
'remaining': None,
|
3333
3371
|
'status': self.parse_order_status(statusId),
|
@@ -3344,6 +3382,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3344
3382
|
'NEW': 'open',
|
3345
3383
|
'PENDING': 'open',
|
3346
3384
|
'PARTIALLY_FILLED': 'open',
|
3385
|
+
'RUNNING': 'open',
|
3347
3386
|
'FILLED': 'closed',
|
3348
3387
|
'CANCELED': 'canceled',
|
3349
3388
|
'CANCELLED': 'canceled',
|
@@ -3358,6 +3397,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3358
3397
|
https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20Order
|
3359
3398
|
https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20Order
|
3360
3399
|
https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Cancel%20an%20Order
|
3400
|
+
https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Cancel%20TWAP%20Order
|
3361
3401
|
|
3362
3402
|
:param str id: order id
|
3363
3403
|
:param str symbol: unified symbol of the market the order was made in
|
@@ -3365,31 +3405,64 @@ class bingx(Exchange, ImplicitAPI):
|
|
3365
3405
|
:param str [params.clientOrderId]: a unique id for the order
|
3366
3406
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
3367
3407
|
"""
|
3368
|
-
if symbol is None:
|
3369
|
-
raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
|
3370
3408
|
await self.load_markets()
|
3371
|
-
|
3372
|
-
|
3373
|
-
'symbol': market['id'],
|
3374
|
-
}
|
3375
|
-
clientOrderId = self.safe_string_2(params, 'clientOrderId', 'clientOrderID')
|
3376
|
-
params = self.omit(params, ['clientOrderId'])
|
3377
|
-
if clientOrderId is not None:
|
3378
|
-
request['clientOrderID'] = clientOrderId
|
3379
|
-
else:
|
3380
|
-
request['orderId'] = id
|
3409
|
+
isTwapOrder = self.safe_bool(params, 'twap', False)
|
3410
|
+
params = self.omit(params, 'twap')
|
3381
3411
|
response = None
|
3382
|
-
|
3383
|
-
|
3384
|
-
|
3385
|
-
|
3386
|
-
|
3387
|
-
response = await self.
|
3412
|
+
market = None
|
3413
|
+
if isTwapOrder:
|
3414
|
+
twapRequest: dict = {
|
3415
|
+
'mainOrderId': id,
|
3416
|
+
}
|
3417
|
+
response = await self.swapV1PrivatePostTwapCancelOrder(self.extend(twapRequest, params))
|
3418
|
+
#
|
3419
|
+
# {
|
3420
|
+
# "code": 0,
|
3421
|
+
# "msg": "",
|
3422
|
+
# "timestamp": 1702731661854,
|
3423
|
+
# "data": {
|
3424
|
+
# "symbol": "BNB-USDT",
|
3425
|
+
# "side": "BUY",
|
3426
|
+
# "positionSide": "LONG",
|
3427
|
+
# "priceType": "constant",
|
3428
|
+
# "priceVariance": "2000",
|
3429
|
+
# "triggerPrice": "68000",
|
3430
|
+
# "interval": 8,
|
3431
|
+
# "amountPerOrder": "0.111",
|
3432
|
+
# "totalAmount": "0.511",
|
3433
|
+
# "orderStatus": "Running",
|
3434
|
+
# "executedQty": "0.1",
|
3435
|
+
# "duration": 800,
|
3436
|
+
# "maxDuration": 9000,
|
3437
|
+
# "createdTime": 1702731661854,
|
3438
|
+
# "updateTime": 1702731661854
|
3439
|
+
# }
|
3440
|
+
# }
|
3441
|
+
#
|
3388
3442
|
else:
|
3389
|
-
if
|
3390
|
-
|
3443
|
+
if symbol is None:
|
3444
|
+
raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
|
3445
|
+
market = self.market(symbol)
|
3446
|
+
request: dict = {
|
3447
|
+
'symbol': market['id'],
|
3448
|
+
}
|
3449
|
+
clientOrderId = self.safe_string_2(params, 'clientOrderId', 'clientOrderID')
|
3450
|
+
params = self.omit(params, ['clientOrderId'])
|
3451
|
+
if clientOrderId is not None:
|
3452
|
+
request['clientOrderID'] = clientOrderId
|
3453
|
+
else:
|
3454
|
+
request['orderId'] = id
|
3455
|
+
type = None
|
3456
|
+
subType = None
|
3457
|
+
type, params = self.handle_market_type_and_params('cancelOrder', market, params)
|
3458
|
+
subType, params = self.handle_sub_type_and_params('cancelOrder', market, params)
|
3459
|
+
if type == 'spot':
|
3460
|
+
response = await self.spotV1PrivatePostTradeCancel(self.extend(request, params))
|
3391
3461
|
else:
|
3392
|
-
|
3462
|
+
if subType == 'inverse':
|
3463
|
+
response = await self.cswapV1PrivateDeleteTradeCancelOrder(self.extend(request, params))
|
3464
|
+
else:
|
3465
|
+
response = await self.swapV2PrivateDeleteTradeOrder(self.extend(request, params))
|
3393
3466
|
#
|
3394
3467
|
# spot
|
3395
3468
|
#
|
@@ -3779,131 +3852,167 @@ class bingx(Exchange, ImplicitAPI):
|
|
3779
3852
|
https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20details
|
3780
3853
|
https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20details
|
3781
3854
|
https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Order
|
3855
|
+
https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#TWAP%20Order%20Details
|
3782
3856
|
|
3783
3857
|
:param str id: the order id
|
3784
3858
|
:param str symbol: unified symbol of the market the order was made in
|
3785
3859
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3860
|
+
:param boolean [params.twap]: if fetching twap order
|
3786
3861
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
3787
3862
|
"""
|
3788
|
-
if symbol is None:
|
3789
|
-
raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument')
|
3790
3863
|
await self.load_markets()
|
3791
|
-
|
3792
|
-
|
3793
|
-
'symbol': market['id'],
|
3794
|
-
'orderId': id,
|
3795
|
-
}
|
3796
|
-
type = None
|
3797
|
-
subType = None
|
3864
|
+
isTwapOrder = self.safe_bool(params, 'twap', False)
|
3865
|
+
params = self.omit(params, 'twap')
|
3798
3866
|
response = None
|
3799
|
-
|
3800
|
-
|
3801
|
-
|
3802
|
-
|
3867
|
+
market = None
|
3868
|
+
if isTwapOrder:
|
3869
|
+
twapRequest: dict = {
|
3870
|
+
'mainOrderId': id,
|
3871
|
+
}
|
3872
|
+
response = await self.swapV1PrivateGetTwapOrderDetail(self.extend(twapRequest, params))
|
3803
3873
|
#
|
3804
3874
|
# {
|
3805
3875
|
# "code": 0,
|
3806
|
-
# "msg": "",
|
3876
|
+
# "msg": "success cancel order",
|
3877
|
+
# "timestamp": 1732760856617,
|
3807
3878
|
# "data": {
|
3808
|
-
# "symbol": "
|
3809
|
-
# "
|
3810
|
-
# "price": "0.5",
|
3811
|
-
# "origQty": "10",
|
3812
|
-
# "executedQty": "0",
|
3813
|
-
# "cummulativeQuoteQty": "0",
|
3814
|
-
# "status": "CANCELED",
|
3815
|
-
# "type": "LIMIT",
|
3879
|
+
# "symbol": "LTC-USDT",
|
3880
|
+
# "mainOrderId": "5596903086063901779",
|
3816
3881
|
# "side": "BUY",
|
3817
|
-
# "
|
3818
|
-
# "
|
3819
|
-
# "
|
3820
|
-
# "
|
3821
|
-
# "
|
3882
|
+
# "positionSide": "LONG",
|
3883
|
+
# "priceType": "constant",
|
3884
|
+
# "priceVariance": "10.00",
|
3885
|
+
# "triggerPrice": "120.00",
|
3886
|
+
# "interval": 8,
|
3887
|
+
# "amountPerOrder": "0.5",
|
3888
|
+
# "totalAmount": "1.0",
|
3889
|
+
# "orderStatus": "Filled",
|
3890
|
+
# "executedQty": "1.0",
|
3891
|
+
# "duration": 16,
|
3892
|
+
# "maxDuration": 86400,
|
3893
|
+
# "createdTime": 1732693017000,
|
3894
|
+
# "updateTime": 1732693033000
|
3822
3895
|
# }
|
3823
3896
|
# }
|
3824
3897
|
#
|
3825
3898
|
else:
|
3826
|
-
if
|
3827
|
-
|
3899
|
+
if symbol is None:
|
3900
|
+
raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument')
|
3901
|
+
market = self.market(symbol)
|
3902
|
+
request: dict = {
|
3903
|
+
'symbol': market['id'],
|
3904
|
+
'orderId': id,
|
3905
|
+
}
|
3906
|
+
type = None
|
3907
|
+
subType = None
|
3908
|
+
type, params = self.handle_market_type_and_params('fetchOrder', market, params)
|
3909
|
+
subType, params = self.handle_sub_type_and_params('fetchOrder', market, params)
|
3910
|
+
if type == 'spot':
|
3911
|
+
response = await self.spotV1PrivateGetTradeQuery(self.extend(request, params))
|
3828
3912
|
#
|
3829
3913
|
# {
|
3830
3914
|
# "code": 0,
|
3831
3915
|
# "msg": "",
|
3832
3916
|
# "data": {
|
3833
|
-
# "
|
3834
|
-
#
|
3835
|
-
#
|
3836
|
-
#
|
3837
|
-
#
|
3838
|
-
#
|
3839
|
-
#
|
3840
|
-
#
|
3841
|
-
#
|
3842
|
-
#
|
3843
|
-
#
|
3844
|
-
#
|
3845
|
-
#
|
3846
|
-
#
|
3847
|
-
# "commission": "0.0000",
|
3848
|
-
# "status": "Pending",
|
3849
|
-
# "time": 1721884753767,
|
3850
|
-
# "updateTime": 1721884753786,
|
3851
|
-
# "clientOrderId": "",
|
3852
|
-
# "leverage": "",
|
3853
|
-
# "takeProfit": {
|
3854
|
-
# "type": "TAKE_PROFIT",
|
3855
|
-
# "quantity": 0,
|
3856
|
-
# "stopPrice": 0,
|
3857
|
-
# "price": 0,
|
3858
|
-
# "workingType": "MARK_PRICE",
|
3859
|
-
# "stopGuaranteed": ""
|
3860
|
-
# },
|
3861
|
-
# "stopLoss": {
|
3862
|
-
# "type": "STOP",
|
3863
|
-
# "quantity": 0,
|
3864
|
-
# "stopPrice": 0,
|
3865
|
-
# "price": 0,
|
3866
|
-
# "workingType": "MARK_PRICE",
|
3867
|
-
# "stopGuaranteed": ""
|
3868
|
-
# },
|
3869
|
-
# "advanceAttr": 0,
|
3870
|
-
# "positionID": 0,
|
3871
|
-
# "takeProfitEntrustPrice": 0,
|
3872
|
-
# "stopLossEntrustPrice": 0,
|
3873
|
-
# "orderType": "",
|
3874
|
-
# "workingType": "MARK_PRICE"
|
3875
|
-
# }
|
3917
|
+
# "symbol": "XRP-USDT",
|
3918
|
+
# "orderId": 1514087361158316032,
|
3919
|
+
# "price": "0.5",
|
3920
|
+
# "origQty": "10",
|
3921
|
+
# "executedQty": "0",
|
3922
|
+
# "cummulativeQuoteQty": "0",
|
3923
|
+
# "status": "CANCELED",
|
3924
|
+
# "type": "LIMIT",
|
3925
|
+
# "side": "BUY",
|
3926
|
+
# "time": 1649821532000,
|
3927
|
+
# "updateTime": 1649821543000,
|
3928
|
+
# "origQuoteOrderQty": "0",
|
3929
|
+
# "fee": "0",
|
3930
|
+
# "feeAsset": "XRP"
|
3876
3931
|
# }
|
3877
3932
|
# }
|
3878
3933
|
#
|
3879
3934
|
else:
|
3880
|
-
|
3881
|
-
|
3882
|
-
|
3883
|
-
|
3884
|
-
|
3885
|
-
|
3886
|
-
|
3887
|
-
|
3888
|
-
|
3889
|
-
|
3890
|
-
|
3891
|
-
|
3892
|
-
|
3893
|
-
|
3894
|
-
|
3895
|
-
|
3896
|
-
|
3897
|
-
|
3898
|
-
|
3899
|
-
|
3900
|
-
|
3901
|
-
|
3902
|
-
|
3903
|
-
|
3904
|
-
|
3905
|
-
|
3906
|
-
|
3935
|
+
if subType == 'inverse':
|
3936
|
+
response = await self.cswapV1PrivateGetTradeOrderDetail(self.extend(request, params))
|
3937
|
+
#
|
3938
|
+
# {
|
3939
|
+
# "code": 0,
|
3940
|
+
# "msg": "",
|
3941
|
+
# "data": {
|
3942
|
+
# "order": {
|
3943
|
+
# "symbol": "SOL-USD",
|
3944
|
+
# "orderId": "1816342420721254400",
|
3945
|
+
# "side": "BUY",
|
3946
|
+
# "positionSide": "Long",
|
3947
|
+
# "type": "LIMIT",
|
3948
|
+
# "quantity": 1,
|
3949
|
+
# "origQty": "",
|
3950
|
+
# "price": "150",
|
3951
|
+
# "executedQty": "0",
|
3952
|
+
# "avgPrice": "0.000",
|
3953
|
+
# "cumQuote": "",
|
3954
|
+
# "stopPrice": "",
|
3955
|
+
# "profit": "0.0000",
|
3956
|
+
# "commission": "0.0000",
|
3957
|
+
# "status": "Pending",
|
3958
|
+
# "time": 1721884753767,
|
3959
|
+
# "updateTime": 1721884753786,
|
3960
|
+
# "clientOrderId": "",
|
3961
|
+
# "leverage": "",
|
3962
|
+
# "takeProfit": {
|
3963
|
+
# "type": "TAKE_PROFIT",
|
3964
|
+
# "quantity": 0,
|
3965
|
+
# "stopPrice": 0,
|
3966
|
+
# "price": 0,
|
3967
|
+
# "workingType": "MARK_PRICE",
|
3968
|
+
# "stopGuaranteed": ""
|
3969
|
+
# },
|
3970
|
+
# "stopLoss": {
|
3971
|
+
# "type": "STOP",
|
3972
|
+
# "quantity": 0,
|
3973
|
+
# "stopPrice": 0,
|
3974
|
+
# "price": 0,
|
3975
|
+
# "workingType": "MARK_PRICE",
|
3976
|
+
# "stopGuaranteed": ""
|
3977
|
+
# },
|
3978
|
+
# "advanceAttr": 0,
|
3979
|
+
# "positionID": 0,
|
3980
|
+
# "takeProfitEntrustPrice": 0,
|
3981
|
+
# "stopLossEntrustPrice": 0,
|
3982
|
+
# "orderType": "",
|
3983
|
+
# "workingType": "MARK_PRICE"
|
3984
|
+
# }
|
3985
|
+
# }
|
3986
|
+
# }
|
3987
|
+
#
|
3988
|
+
else:
|
3989
|
+
response = await self.swapV2PrivateGetTradeOrder(self.extend(request, params))
|
3990
|
+
#
|
3991
|
+
# {
|
3992
|
+
# "code": 0,
|
3993
|
+
# "msg": "",
|
3994
|
+
# "data": {
|
3995
|
+
# "order": {
|
3996
|
+
# "symbol": "BTC-USDT",
|
3997
|
+
# "orderId": 1597597642269917184,
|
3998
|
+
# "side": "SELL",
|
3999
|
+
# "positionSide": "LONG",
|
4000
|
+
# "type": "TAKE_PROFIT_MARKET",
|
4001
|
+
# "origQty": "1.0000",
|
4002
|
+
# "price": "0.0",
|
4003
|
+
# "executedQty": "0.0000",
|
4004
|
+
# "avgPrice": "0.0",
|
4005
|
+
# "cumQuote": "",
|
4006
|
+
# "stopPrice": "16494.0",
|
4007
|
+
# "profit": "",
|
4008
|
+
# "commission": "",
|
4009
|
+
# "status": "FILLED",
|
4010
|
+
# "time": 1669731935000,
|
4011
|
+
# "updateTime": 1669752524000
|
4012
|
+
# }
|
4013
|
+
# }
|
4014
|
+
# }
|
4015
|
+
#
|
3907
4016
|
data = self.safe_dict(response, 'data', {})
|
3908
4017
|
order = self.safe_dict(data, 'order', data)
|
3909
4018
|
return self.parse_order(order, market)
|
@@ -4002,11 +4111,13 @@ class bingx(Exchange, ImplicitAPI):
|
|
4002
4111
|
https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Current%20Open%20Orders
|
4003
4112
|
https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Current%20All%20Open%20Orders
|
4004
4113
|
https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20all%20current%20pending%20orders
|
4114
|
+
https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20TWAP%20Entrusted%20Order
|
4005
4115
|
|
4006
4116
|
:param str symbol: unified market symbol
|
4007
4117
|
:param int [since]: the earliest time in ms to fetch open orders for
|
4008
4118
|
:param int [limit]: the maximum number of open order structures to retrieve
|
4009
4119
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4120
|
+
:param boolean [params.twap]: if fetching twap open orders
|
4010
4121
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
4011
4122
|
"""
|
4012
4123
|
await self.load_markets()
|
@@ -4023,7 +4134,11 @@ class bingx(Exchange, ImplicitAPI):
|
|
4023
4134
|
if type == 'spot':
|
4024
4135
|
response = await self.spotV1PrivateGetTradeOpenOrders(self.extend(request, params))
|
4025
4136
|
else:
|
4026
|
-
|
4137
|
+
isTwapOrder = self.safe_bool(params, 'twap', False)
|
4138
|
+
params = self.omit(params, 'twap')
|
4139
|
+
if isTwapOrder:
|
4140
|
+
response = await self.swapV1PrivateGetTwapOpenOrders(self.extend(request, params))
|
4141
|
+
elif subType == 'inverse':
|
4027
4142
|
response = await self.cswapV1PrivateGetTradeOpenOrders(self.extend(request, params))
|
4028
4143
|
else:
|
4029
4144
|
response = await self.swapV2PrivateGetTradeOpenOrders(self.extend(request, params))
|
@@ -4136,8 +4251,38 @@ class bingx(Exchange, ImplicitAPI):
|
|
4136
4251
|
# }
|
4137
4252
|
# }
|
4138
4253
|
#
|
4254
|
+
# twap
|
4255
|
+
#
|
4256
|
+
# {
|
4257
|
+
# "code": 0,
|
4258
|
+
# "msg": "",
|
4259
|
+
# "timestamp": 1702731661854,
|
4260
|
+
# "data": {
|
4261
|
+
# "list": [
|
4262
|
+
# {
|
4263
|
+
# "symbol": "BNB-USDT",
|
4264
|
+
# "side": "BUY",
|
4265
|
+
# "positionSide": "LONG",
|
4266
|
+
# "priceType": "constant",
|
4267
|
+
# "priceVariance": "2000",
|
4268
|
+
# "triggerPrice": "68000",
|
4269
|
+
# "interval": 8,
|
4270
|
+
# "amountPerOrder": "0.111",
|
4271
|
+
# "totalAmount": "0.511",
|
4272
|
+
# "orderStatus": "Running",
|
4273
|
+
# "executedQty": "0.1",
|
4274
|
+
# "duration": 800,
|
4275
|
+
# "maxDuration": 9000,
|
4276
|
+
# "createdTime": 1702731661854,
|
4277
|
+
# "updateTime": 1702731661854
|
4278
|
+
# }
|
4279
|
+
# ],
|
4280
|
+
# "total": 1
|
4281
|
+
# }
|
4282
|
+
# }
|
4283
|
+
#
|
4139
4284
|
data = self.safe_dict(response, 'data', {})
|
4140
|
-
orders = self.
|
4285
|
+
orders = self.safe_list_2(data, 'orders', 'list', [])
|
4141
4286
|
return self.parse_orders(orders, market, since, limit)
|
4142
4287
|
|
4143
4288
|
async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
@@ -4190,6 +4335,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
4190
4335
|
https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history
|
4191
4336
|
https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#User's%20History%20Orders
|
4192
4337
|
https://bingx-api.github.io/docs/#/standard/contract-interface.html#Historical%20order
|
4338
|
+
https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20TWAP%20Historical%20Orders
|
4193
4339
|
|
4194
4340
|
:param str [symbol]: unified market symbol of the market orders were made in
|
4195
4341
|
:param int [since]: the earliest time in ms to fetch orders for
|
@@ -4197,6 +4343,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
4197
4343
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4198
4344
|
:param int [params.until]: the latest time in ms to fetch orders for
|
4199
4345
|
:param boolean [params.standard]: whether to fetch standard contract orders
|
4346
|
+
:param boolean [params.twap]: if fetching twap orders
|
4200
4347
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
4201
4348
|
"""
|
4202
4349
|
if symbol is None:
|
@@ -4244,7 +4391,46 @@ class bingx(Exchange, ImplicitAPI):
|
|
4244
4391
|
# }
|
4245
4392
|
#
|
4246
4393
|
else:
|
4247
|
-
|
4394
|
+
isTwapOrder = self.safe_bool(params, 'twap', False)
|
4395
|
+
params = self.omit(params, 'twap')
|
4396
|
+
if isTwapOrder:
|
4397
|
+
request['pageIndex'] = 1
|
4398
|
+
request['pageSize'] = 100 if (limit is None) else limit
|
4399
|
+
request['startTime'] = 1 if (since is None) else since
|
4400
|
+
until = self.safe_integer(params, 'until', self.milliseconds())
|
4401
|
+
params = self.omit(params, 'until')
|
4402
|
+
request['endTime'] = until
|
4403
|
+
response = await self.swapV1PrivateGetTwapHistoryOrders(self.extend(request, params))
|
4404
|
+
#
|
4405
|
+
# {
|
4406
|
+
# "code": 0,
|
4407
|
+
# "msg": "",
|
4408
|
+
# "timestamp": 1702731661854,
|
4409
|
+
# "data": {
|
4410
|
+
# "list": [
|
4411
|
+
# {
|
4412
|
+
# "symbol": "BNB-USDT",
|
4413
|
+
# "side": "BUY",
|
4414
|
+
# "positionSide": "LONG",
|
4415
|
+
# "priceType": "constant",
|
4416
|
+
# "priceVariance": "2000",
|
4417
|
+
# "triggerPrice": "68000",
|
4418
|
+
# "interval": 8,
|
4419
|
+
# "amountPerOrder": "0.111",
|
4420
|
+
# "totalAmount": "0.511",
|
4421
|
+
# "orderStatus": "Running",
|
4422
|
+
# "executedQty": "0.1",
|
4423
|
+
# "duration": 800,
|
4424
|
+
# "maxDuration": 9000,
|
4425
|
+
# "createdTime": 1702731661854,
|
4426
|
+
# "updateTime": 1702731661854
|
4427
|
+
# }
|
4428
|
+
# ],
|
4429
|
+
# "total": 1
|
4430
|
+
# }
|
4431
|
+
# }
|
4432
|
+
#
|
4433
|
+
elif subType == 'inverse':
|
4248
4434
|
response = await self.cswapV1PrivateGetTradeOrderHistory(self.extend(request, params))
|
4249
4435
|
#
|
4250
4436
|
# {
|
@@ -4330,7 +4516,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
4330
4516
|
# }
|
4331
4517
|
#
|
4332
4518
|
data = self.safe_dict(response, 'data', {})
|
4333
|
-
orders = self.
|
4519
|
+
orders = self.safe_list_2(data, 'orders', 'list', [])
|
4334
4520
|
return self.parse_orders(orders, market, since, limit)
|
4335
4521
|
|
4336
4522
|
async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
|
@@ -5883,27 +6069,27 @@ class bingx(Exchange, ImplicitAPI):
|
|
5883
6069
|
path = self.implode_params(path, params)
|
5884
6070
|
url += path
|
5885
6071
|
params = self.omit(params, self.extract_params(path))
|
6072
|
+
params['timestamp'] = self.nonce()
|
5886
6073
|
params = self.keysort(params)
|
5887
6074
|
if access == 'public':
|
5888
|
-
params['timestamp'] = self.nonce()
|
5889
6075
|
if params:
|
5890
6076
|
url += '?' + self.urlencode(params)
|
5891
6077
|
elif access == 'private':
|
5892
6078
|
self.check_required_credentials()
|
5893
|
-
|
6079
|
+
isJsonContentType = ((type == 'subAccount') and (method == 'POST'))
|
5894
6080
|
parsedParams = self.parse_params(params)
|
5895
|
-
query = self.urlencode(parsedParams)
|
5896
6081
|
signature = self.hmac(self.encode(self.rawencode(parsedParams)), self.encode(self.secret), hashlib.sha256)
|
5897
|
-
if params:
|
5898
|
-
query = '?' + query + '&'
|
5899
|
-
else:
|
5900
|
-
query += '?'
|
5901
|
-
query += 'signature=' + signature
|
5902
6082
|
headers = {
|
5903
6083
|
'X-BX-APIKEY': self.apiKey,
|
5904
6084
|
'X-SOURCE-KEY': self.safe_string(self.options, 'broker', 'CCXT'),
|
5905
6085
|
}
|
5906
|
-
|
6086
|
+
if isJsonContentType:
|
6087
|
+
headers['Content-Type'] = 'application/json'
|
6088
|
+
parsedParams['signature'] = signature
|
6089
|
+
body = self.json(parsedParams)
|
6090
|
+
else:
|
6091
|
+
query = self.urlencode(parsedParams)
|
6092
|
+
url += '?' + query + '&signature=' + signature
|
5907
6093
|
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|
5908
6094
|
|
5909
6095
|
def nonce(self):
|