ccxt 4.3.59__py2.py3-none-any.whl → 4.3.61__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.
Potentially problematic release.
This version of ccxt might be problematic. Click here for more details.
- ccxt/__init__.py +1 -1
- ccxt/abstract/bingx.py +1 -1
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/binance.py +90 -1
- ccxt/async_support/bingx.py +401 -116
- ccxt/async_support/bitfinex.py +38 -4
- ccxt/async_support/bitso.py +4 -1
- ccxt/async_support/bybit.py +9 -3
- ccxt/async_support/cryptocom.py +11 -5
- ccxt/async_support/gate.py +1 -2
- ccxt/async_support/hyperliquid.py +11 -3
- ccxt/async_support/kraken.py +1 -1
- ccxt/async_support/mexc.py +2 -1
- ccxt/async_support/okx.py +10 -1
- ccxt/async_support/timex.py +16 -2
- ccxt/async_support/vertex.py +10 -1
- ccxt/async_support/xt.py +1 -1
- ccxt/base/exchange.py +1 -1
- ccxt/binance.py +90 -1
- ccxt/bingx.py +401 -116
- ccxt/bitfinex.py +38 -4
- ccxt/bitso.py +4 -1
- ccxt/bybit.py +9 -3
- ccxt/cryptocom.py +11 -5
- ccxt/gate.py +1 -2
- ccxt/hyperliquid.py +11 -3
- ccxt/kraken.py +1 -1
- ccxt/mexc.py +2 -1
- ccxt/okx.py +10 -1
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/cex.py +1 -1
- ccxt/pro/kucoin.py +34 -3
- ccxt/pro/phemex.py +1 -1
- ccxt/pro/xt.py +4 -1
- ccxt/timex.py +16 -2
- ccxt/vertex.py +10 -1
- ccxt/xt.py +1 -1
- {ccxt-4.3.59.dist-info → ccxt-4.3.61.dist-info}/METADATA +4 -4
- {ccxt-4.3.59.dist-info → ccxt-4.3.61.dist-info}/RECORD +43 -43
- {ccxt-4.3.59.dist-info → ccxt-4.3.61.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.3.59.dist-info → ccxt-4.3.61.dist-info}/WHEEL +0 -0
- {ccxt-4.3.59.dist-info → ccxt-4.3.61.dist-info}/top_level.txt +0 -0
ccxt/async_support/bingx.py
CHANGED
@@ -303,9 +303,11 @@ class bingx(Exchange, ImplicitAPI):
|
|
303
303
|
'post': {
|
304
304
|
'trade/order': 2,
|
305
305
|
'trade/leverage': 2,
|
306
|
-
'trade/allOpenOrders': 2,
|
307
306
|
'trade/closeAllPositions': 2,
|
308
307
|
},
|
308
|
+
'delete': {
|
309
|
+
'trade/allOpenOrders': 2,
|
310
|
+
},
|
309
311
|
},
|
310
312
|
},
|
311
313
|
},
|
@@ -1478,8 +1480,9 @@ class bingx(Exchange, ImplicitAPI):
|
|
1478
1480
|
async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
|
1479
1481
|
"""
|
1480
1482
|
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
1481
|
-
:see: https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Ticker
|
1482
|
-
:see: https://bingx-api.github.io/docs/#/spot/market-api.html#24%
|
1483
|
+
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Get%20Ticker
|
1484
|
+
:see: https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#24-hour%20price%20changes
|
1485
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Query%2024-Hour%20Price%20Change
|
1483
1486
|
:param str symbol: unified symbol of the market to fetch the ticker for
|
1484
1487
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1485
1488
|
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
@@ -1493,7 +1496,38 @@ class bingx(Exchange, ImplicitAPI):
|
|
1493
1496
|
if market['spot']:
|
1494
1497
|
response = await self.spotV1PublicGetTicker24hr(self.extend(request, params))
|
1495
1498
|
else:
|
1496
|
-
|
1499
|
+
if market['inverse']:
|
1500
|
+
response = await self.cswapV1PublicGetMarketTicker(self.extend(request, params))
|
1501
|
+
else:
|
1502
|
+
response = await self.swapV2PublicGetQuoteTicker(self.extend(request, params))
|
1503
|
+
#
|
1504
|
+
# spot and swap
|
1505
|
+
#
|
1506
|
+
# {
|
1507
|
+
# "code": 0,
|
1508
|
+
# "msg": "",
|
1509
|
+
# "timestamp": 1720647285296,
|
1510
|
+
# "data": [
|
1511
|
+
# {
|
1512
|
+
# "symbol": "SOL-USD",
|
1513
|
+
# "priceChange": "-2.418",
|
1514
|
+
# "priceChangePercent": "-1.6900%",
|
1515
|
+
# "lastPrice": "140.574",
|
1516
|
+
# "lastQty": "1",
|
1517
|
+
# "highPrice": "146.190",
|
1518
|
+
# "lowPrice": "138.586",
|
1519
|
+
# "volume": "1464648.00",
|
1520
|
+
# "quoteVolume": "102928.12",
|
1521
|
+
# "openPrice": "142.994",
|
1522
|
+
# "closeTime": "1720647284976",
|
1523
|
+
# "bidPrice": "140.573",
|
1524
|
+
# "bidQty": "372",
|
1525
|
+
# "askPrice": "140.577",
|
1526
|
+
# "askQty": "58"
|
1527
|
+
# }
|
1528
|
+
# ]
|
1529
|
+
# }
|
1530
|
+
#
|
1497
1531
|
data = self.safe_list(response, 'data')
|
1498
1532
|
if data is not None:
|
1499
1533
|
first = self.safe_dict(data, 0, {})
|
@@ -1504,7 +1538,9 @@ class bingx(Exchange, ImplicitAPI):
|
|
1504
1538
|
async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
1505
1539
|
"""
|
1506
1540
|
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
1507
|
-
:see: https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Ticker
|
1541
|
+
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Get%20Ticker
|
1542
|
+
:see: https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#24-hour%20price%20changes
|
1543
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Query%2024-Hour%20Price%20Change
|
1508
1544
|
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
1509
1545
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1510
1546
|
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
@@ -1518,11 +1554,45 @@ class bingx(Exchange, ImplicitAPI):
|
|
1518
1554
|
market = self.market(firstSymbol)
|
1519
1555
|
type = None
|
1520
1556
|
type, params = self.handle_market_type_and_params('fetchTickers', market, params)
|
1557
|
+
subType = None
|
1558
|
+
subType, params = self.handle_sub_type_and_params('fetchTickers', market, params)
|
1521
1559
|
response = None
|
1522
1560
|
if type == 'spot':
|
1523
1561
|
response = await self.spotV1PublicGetTicker24hr(params)
|
1524
1562
|
else:
|
1525
|
-
|
1563
|
+
if subType == 'inverse':
|
1564
|
+
response = await self.cswapV1PublicGetMarketTicker(params)
|
1565
|
+
else:
|
1566
|
+
response = await self.swapV2PublicGetQuoteTicker(params)
|
1567
|
+
#
|
1568
|
+
# spot and swap
|
1569
|
+
#
|
1570
|
+
# {
|
1571
|
+
# "code": 0,
|
1572
|
+
# "msg": "",
|
1573
|
+
# "timestamp": 1720647285296,
|
1574
|
+
# "data": [
|
1575
|
+
# {
|
1576
|
+
# "symbol": "SOL-USD",
|
1577
|
+
# "priceChange": "-2.418",
|
1578
|
+
# "priceChangePercent": "-1.6900%",
|
1579
|
+
# "lastPrice": "140.574",
|
1580
|
+
# "lastQty": "1",
|
1581
|
+
# "highPrice": "146.190",
|
1582
|
+
# "lowPrice": "138.586",
|
1583
|
+
# "volume": "1464648.00",
|
1584
|
+
# "quoteVolume": "102928.12",
|
1585
|
+
# "openPrice": "142.994",
|
1586
|
+
# "closeTime": "1720647284976",
|
1587
|
+
# "bidPrice": "140.573",
|
1588
|
+
# "bidQty": "372",
|
1589
|
+
# "askPrice": "140.577",
|
1590
|
+
# "askQty": "58"
|
1591
|
+
# },
|
1592
|
+
# ...
|
1593
|
+
# ]
|
1594
|
+
# }
|
1595
|
+
#
|
1526
1596
|
tickers = self.safe_list(response, 'data')
|
1527
1597
|
return self.parse_tickers(tickers, symbols)
|
1528
1598
|
|
@@ -2470,7 +2540,9 @@ class bingx(Exchange, ImplicitAPI):
|
|
2470
2540
|
# side: 'SELL'
|
2471
2541
|
# }
|
2472
2542
|
# }
|
2543
|
+
#
|
2473
2544
|
# stop loss order
|
2545
|
+
#
|
2474
2546
|
# {
|
2475
2547
|
# "symbol": "ETH-USDT",
|
2476
2548
|
# "orderId": "1792461744476422144",
|
@@ -2490,6 +2562,52 @@ class bingx(Exchange, ImplicitAPI):
|
|
2490
2562
|
# "clientOrderID": ""
|
2491
2563
|
# }
|
2492
2564
|
#
|
2565
|
+
# inverse swap cancelAllOrders
|
2566
|
+
#
|
2567
|
+
# {
|
2568
|
+
# "symbol": "SOL-USD",
|
2569
|
+
# "orderId": "1809845251327672320",
|
2570
|
+
# "side": "BUY",
|
2571
|
+
# "positionSide": "LONG",
|
2572
|
+
# "type": "LIMIT",
|
2573
|
+
# "quantity": 1,
|
2574
|
+
# "origQty": "0",
|
2575
|
+
# "price": "90",
|
2576
|
+
# "executedQty": "0",
|
2577
|
+
# "avgPrice": "0",
|
2578
|
+
# "cumQuote": "0",
|
2579
|
+
# "stopPrice": "",
|
2580
|
+
# "profit": "0.0000",
|
2581
|
+
# "commission": "0.000000",
|
2582
|
+
# "status": "CANCELLED",
|
2583
|
+
# "time": 1720335707872,
|
2584
|
+
# "updateTime": 1720335707912,
|
2585
|
+
# "clientOrderId": "",
|
2586
|
+
# "leverage": "",
|
2587
|
+
# "takeProfit": {
|
2588
|
+
# "type": "",
|
2589
|
+
# "quantity": 0,
|
2590
|
+
# "stopPrice": 0,
|
2591
|
+
# "price": 0,
|
2592
|
+
# "workingType": "",
|
2593
|
+
# "stopGuaranteed": ""
|
2594
|
+
# },
|
2595
|
+
# "stopLoss": {
|
2596
|
+
# "type": "",
|
2597
|
+
# "quantity": 0,
|
2598
|
+
# "stopPrice": 0,
|
2599
|
+
# "price": 0,
|
2600
|
+
# "workingType": "",
|
2601
|
+
# "stopGuaranteed": ""
|
2602
|
+
# },
|
2603
|
+
# "advanceAttr": 0,
|
2604
|
+
# "positionID": 0,
|
2605
|
+
# "takeProfitEntrustPrice": 0,
|
2606
|
+
# "stopLossEntrustPrice": 0,
|
2607
|
+
# "orderType": "",
|
2608
|
+
# "workingType": ""
|
2609
|
+
# }
|
2610
|
+
#
|
2493
2611
|
info = order
|
2494
2612
|
newOrder = self.safe_dict_2(order, 'newOrderResponse', 'orderOpenResponse')
|
2495
2613
|
if newOrder is not None:
|
@@ -2670,6 +2788,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2670
2788
|
cancel all open orders
|
2671
2789
|
:see: https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20orders%20by%20symbol
|
2672
2790
|
:see: https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Cancel%20All%20Orders
|
2791
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Cancel%20all%20orders
|
2673
2792
|
:param str [symbol]: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
|
2674
2793
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2675
2794
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
@@ -2707,36 +2826,94 @@ class bingx(Exchange, ImplicitAPI):
|
|
2707
2826
|
# }
|
2708
2827
|
#
|
2709
2828
|
elif market['swap']:
|
2710
|
-
|
2711
|
-
|
2712
|
-
|
2713
|
-
|
2714
|
-
|
2715
|
-
|
2716
|
-
|
2717
|
-
|
2718
|
-
|
2719
|
-
|
2720
|
-
|
2721
|
-
|
2722
|
-
|
2723
|
-
|
2724
|
-
|
2725
|
-
|
2726
|
-
|
2727
|
-
|
2728
|
-
|
2729
|
-
|
2730
|
-
|
2731
|
-
|
2732
|
-
|
2733
|
-
|
2734
|
-
|
2735
|
-
|
2736
|
-
|
2737
|
-
|
2738
|
-
|
2739
|
-
|
2829
|
+
if market['inverse']:
|
2830
|
+
response = await self.cswapV1PrivateDeleteTradeAllOpenOrders(self.extend(request, params))
|
2831
|
+
#
|
2832
|
+
# {
|
2833
|
+
# "code": 0,
|
2834
|
+
# "msg": "",
|
2835
|
+
# "timestamp": 1720501468364,
|
2836
|
+
# "data": {
|
2837
|
+
# "success": [
|
2838
|
+
# {
|
2839
|
+
# "symbol": "SOL-USD",
|
2840
|
+
# "orderId": "1809845251327672320",
|
2841
|
+
# "side": "BUY",
|
2842
|
+
# "positionSide": "LONG",
|
2843
|
+
# "type": "LIMIT",
|
2844
|
+
# "quantity": 1,
|
2845
|
+
# "origQty": "0",
|
2846
|
+
# "price": "90",
|
2847
|
+
# "executedQty": "0",
|
2848
|
+
# "avgPrice": "0",
|
2849
|
+
# "cumQuote": "0",
|
2850
|
+
# "stopPrice": "",
|
2851
|
+
# "profit": "0.0000",
|
2852
|
+
# "commission": "0.000000",
|
2853
|
+
# "status": "CANCELLED",
|
2854
|
+
# "time": 1720335707872,
|
2855
|
+
# "updateTime": 1720335707912,
|
2856
|
+
# "clientOrderId": "",
|
2857
|
+
# "leverage": "",
|
2858
|
+
# "takeProfit": {
|
2859
|
+
# "type": "",
|
2860
|
+
# "quantity": 0,
|
2861
|
+
# "stopPrice": 0,
|
2862
|
+
# "price": 0,
|
2863
|
+
# "workingType": "",
|
2864
|
+
# "stopGuaranteed": ""
|
2865
|
+
# },
|
2866
|
+
# "stopLoss": {
|
2867
|
+
# "type": "",
|
2868
|
+
# "quantity": 0,
|
2869
|
+
# "stopPrice": 0,
|
2870
|
+
# "price": 0,
|
2871
|
+
# "workingType": "",
|
2872
|
+
# "stopGuaranteed": ""
|
2873
|
+
# },
|
2874
|
+
# "advanceAttr": 0,
|
2875
|
+
# "positionID": 0,
|
2876
|
+
# "takeProfitEntrustPrice": 0,
|
2877
|
+
# "stopLossEntrustPrice": 0,
|
2878
|
+
# "orderType": "",
|
2879
|
+
# "workingType": ""
|
2880
|
+
# }
|
2881
|
+
# ],
|
2882
|
+
# "failed": null
|
2883
|
+
# }
|
2884
|
+
# }
|
2885
|
+
#
|
2886
|
+
else:
|
2887
|
+
response = await self.swapV2PrivateDeleteTradeAllOpenOrders(self.extend(request, params))
|
2888
|
+
#
|
2889
|
+
# {
|
2890
|
+
# "code": 0,
|
2891
|
+
# "msg": "",
|
2892
|
+
# "data": {
|
2893
|
+
# "success": [
|
2894
|
+
# {
|
2895
|
+
# "symbol": "LINK-USDT",
|
2896
|
+
# "orderId": 1597783835095859200,
|
2897
|
+
# "side": "BUY",
|
2898
|
+
# "positionSide": "LONG",
|
2899
|
+
# "type": "TRIGGER_LIMIT",
|
2900
|
+
# "origQty": "5.0",
|
2901
|
+
# "price": "9.0000",
|
2902
|
+
# "executedQty": "0.0",
|
2903
|
+
# "avgPrice": "0.0000",
|
2904
|
+
# "cumQuote": "0",
|
2905
|
+
# "stopPrice": "9.5000",
|
2906
|
+
# "profit": "",
|
2907
|
+
# "commission": "",
|
2908
|
+
# "status": "NEW",
|
2909
|
+
# "time": 1669776326000,
|
2910
|
+
# "updateTime": 1669776326000
|
2911
|
+
# }
|
2912
|
+
# ],
|
2913
|
+
# "failed": null
|
2914
|
+
# }
|
2915
|
+
# }
|
2916
|
+
#
|
2740
2917
|
else:
|
2741
2918
|
raise BadRequest(self.id + ' cancelAllOrders is only supported for spot and swap markets.')
|
2742
2919
|
data = self.safe_dict(response, 'data', {})
|
@@ -3711,6 +3888,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3711
3888
|
"""
|
3712
3889
|
fetch the set leverage for a market
|
3713
3890
|
:see: https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Query%20Leverage
|
3891
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Leverage
|
3714
3892
|
:param str symbol: unified market symbol
|
3715
3893
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3716
3894
|
:returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
|
@@ -3720,21 +3898,77 @@ class bingx(Exchange, ImplicitAPI):
|
|
3720
3898
|
request: dict = {
|
3721
3899
|
'symbol': market['id'],
|
3722
3900
|
}
|
3723
|
-
response =
|
3724
|
-
|
3725
|
-
|
3726
|
-
|
3727
|
-
|
3728
|
-
|
3729
|
-
|
3730
|
-
|
3731
|
-
|
3732
|
-
|
3733
|
-
|
3901
|
+
response = None
|
3902
|
+
if market['inverse']:
|
3903
|
+
response = await self.cswapV1PrivateGetTradeLeverage(self.extend(request, params))
|
3904
|
+
#
|
3905
|
+
# {
|
3906
|
+
# "code": 0,
|
3907
|
+
# "msg": "",
|
3908
|
+
# "timestamp": 1720683803391,
|
3909
|
+
# "data": {
|
3910
|
+
# "symbol": "SOL-USD",
|
3911
|
+
# "longLeverage": 5,
|
3912
|
+
# "shortLeverage": 5,
|
3913
|
+
# "maxLongLeverage": 50,
|
3914
|
+
# "maxShortLeverage": 50,
|
3915
|
+
# "availableLongVol": "4000000",
|
3916
|
+
# "availableShortVol": "4000000"
|
3917
|
+
# }
|
3918
|
+
# }
|
3919
|
+
#
|
3920
|
+
else:
|
3921
|
+
response = await self.swapV2PrivateGetTradeLeverage(self.extend(request, params))
|
3922
|
+
#
|
3923
|
+
# {
|
3924
|
+
# "code": 0,
|
3925
|
+
# "msg": "",
|
3926
|
+
# "data": {
|
3927
|
+
# "longLeverage": 5,
|
3928
|
+
# "shortLeverage": 5,
|
3929
|
+
# "maxLongLeverage": 125,
|
3930
|
+
# "maxShortLeverage": 125,
|
3931
|
+
# "availableLongVol": "0.0000",
|
3932
|
+
# "availableShortVol": "0.0000",
|
3933
|
+
# "availableLongVal": "0.0",
|
3934
|
+
# "availableShortVal": "0.0",
|
3935
|
+
# "maxPositionLongVal": "0.0",
|
3936
|
+
# "maxPositionShortVal": "0.0"
|
3937
|
+
# }
|
3938
|
+
# }
|
3939
|
+
#
|
3734
3940
|
data = self.safe_dict(response, 'data', {})
|
3735
3941
|
return self.parse_leverage(data, market)
|
3736
3942
|
|
3737
3943
|
def parse_leverage(self, leverage: dict, market: Market = None) -> Leverage:
|
3944
|
+
#
|
3945
|
+
# linear swap
|
3946
|
+
#
|
3947
|
+
# {
|
3948
|
+
# "longLeverage": 5,
|
3949
|
+
# "shortLeverage": 5,
|
3950
|
+
# "maxLongLeverage": 125,
|
3951
|
+
# "maxShortLeverage": 125,
|
3952
|
+
# "availableLongVol": "0.0000",
|
3953
|
+
# "availableShortVol": "0.0000",
|
3954
|
+
# "availableLongVal": "0.0",
|
3955
|
+
# "availableShortVal": "0.0",
|
3956
|
+
# "maxPositionLongVal": "0.0",
|
3957
|
+
# "maxPositionShortVal": "0.0"
|
3958
|
+
# }
|
3959
|
+
#
|
3960
|
+
# inverse swap
|
3961
|
+
#
|
3962
|
+
# {
|
3963
|
+
# "symbol": "SOL-USD",
|
3964
|
+
# "longLeverage": 5,
|
3965
|
+
# "shortLeverage": 5,
|
3966
|
+
# "maxLongLeverage": 50,
|
3967
|
+
# "maxShortLeverage": 50,
|
3968
|
+
# "availableLongVol": "4000000",
|
3969
|
+
# "availableShortVol": "4000000"
|
3970
|
+
# }
|
3971
|
+
#
|
3738
3972
|
marketId = self.safe_string(leverage, 'symbol')
|
3739
3973
|
return {
|
3740
3974
|
'info': leverage,
|
@@ -3748,6 +3982,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3748
3982
|
"""
|
3749
3983
|
set the level of leverage for a market
|
3750
3984
|
:see: https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Switch%20Leverage
|
3985
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Modify%20Leverage
|
3751
3986
|
:param float leverage: the rate of leverage
|
3752
3987
|
:param str symbol: unified market symbol
|
3753
3988
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -3765,17 +4000,42 @@ class bingx(Exchange, ImplicitAPI):
|
|
3765
4000
|
'side': side,
|
3766
4001
|
'leverage': leverage,
|
3767
4002
|
}
|
3768
|
-
|
3769
|
-
|
3770
|
-
|
3771
|
-
|
3772
|
-
|
3773
|
-
|
3774
|
-
|
3775
|
-
|
3776
|
-
|
3777
|
-
|
3778
|
-
|
4003
|
+
if market['inverse']:
|
4004
|
+
return await self.cswapV1PrivatePostTradeLeverage(self.extend(request, params))
|
4005
|
+
#
|
4006
|
+
# {
|
4007
|
+
# "code": 0,
|
4008
|
+
# "msg": "",
|
4009
|
+
# "timestamp": 1720725058059,
|
4010
|
+
# "data": {
|
4011
|
+
# "symbol": "SOL-USD",
|
4012
|
+
# "longLeverage": 10,
|
4013
|
+
# "shortLeverage": 5,
|
4014
|
+
# "maxLongLeverage": 50,
|
4015
|
+
# "maxShortLeverage": 50,
|
4016
|
+
# "availableLongVol": "4000000",
|
4017
|
+
# "availableShortVol": "4000000"
|
4018
|
+
# }
|
4019
|
+
# }
|
4020
|
+
#
|
4021
|
+
else:
|
4022
|
+
return await self.swapV2PrivatePostTradeLeverage(self.extend(request, params))
|
4023
|
+
#
|
4024
|
+
# {
|
4025
|
+
# "code": 0,
|
4026
|
+
# "msg": "",
|
4027
|
+
# "data": {
|
4028
|
+
# "leverage": 10,
|
4029
|
+
# "symbol": "BTC-USDT",
|
4030
|
+
# "availableLongVol": "0.0000",
|
4031
|
+
# "availableShortVol": "0.0000",
|
4032
|
+
# "availableLongVal": "0.0",
|
4033
|
+
# "availableShortVal": "0.0",
|
4034
|
+
# "maxPositionLongVal": "0.0",
|
4035
|
+
# "maxPositionShortVal": "0.0"
|
4036
|
+
# }
|
4037
|
+
# }
|
4038
|
+
#
|
3779
4039
|
|
3780
4040
|
async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
3781
4041
|
"""
|
@@ -4101,93 +4361,118 @@ class bingx(Exchange, ImplicitAPI):
|
|
4101
4361
|
"""
|
4102
4362
|
closes open positions for a market
|
4103
4363
|
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#One-Click%20Close%20All%20Positions
|
4364
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Close%20all%20positions%20in%20bulk
|
4104
4365
|
:param str symbol: Unified CCXT market symbol
|
4105
4366
|
:param str [side]: not used by bingx
|
4106
4367
|
:param dict [params]: extra parameters specific to the bingx api endpoint
|
4107
|
-
:param str|None [params.positionId]:
|
4368
|
+
:param str|None [params.positionId]: the id of the position you would like to close
|
4108
4369
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
4109
4370
|
"""
|
4110
4371
|
await self.load_markets()
|
4372
|
+
market = self.market(symbol)
|
4111
4373
|
positionId = self.safe_string(params, 'positionId')
|
4112
|
-
|
4374
|
+
request: dict = {}
|
4113
4375
|
response = None
|
4114
4376
|
if positionId is not None:
|
4115
|
-
request: dict = {
|
4116
|
-
'positionId': positionId,
|
4117
|
-
}
|
4118
4377
|
response = await self.swapV1PrivatePostTradeClosePosition(self.extend(request, params))
|
4378
|
+
#
|
4379
|
+
# {
|
4380
|
+
# "code": 0,
|
4381
|
+
# "msg": "",
|
4382
|
+
# "timestamp": 1710992264190,
|
4383
|
+
# "data": {
|
4384
|
+
# "orderId": 1770656007907930112,
|
4385
|
+
# "positionId": "1751667128353910784",
|
4386
|
+
# "symbol": "LTC-USDT",
|
4387
|
+
# "side": "Ask",
|
4388
|
+
# "type": "MARKET",
|
4389
|
+
# "positionSide": "Long",
|
4390
|
+
# "origQty": "0.2"
|
4391
|
+
# }
|
4392
|
+
# }
|
4393
|
+
#
|
4119
4394
|
else:
|
4120
|
-
|
4121
|
-
|
4122
|
-
|
4123
|
-
|
4124
|
-
|
4125
|
-
|
4126
|
-
|
4127
|
-
|
4128
|
-
|
4129
|
-
|
4130
|
-
|
4131
|
-
|
4132
|
-
|
4133
|
-
|
4134
|
-
|
4135
|
-
|
4136
|
-
|
4137
|
-
|
4138
|
-
|
4139
|
-
|
4140
|
-
|
4141
|
-
|
4142
|
-
|
4143
|
-
|
4144
|
-
|
4145
|
-
|
4146
|
-
|
4147
|
-
|
4148
|
-
# "data": {
|
4149
|
-
# "success": [
|
4150
|
-
# 1727686766700486656,
|
4151
|
-
# ],
|
4152
|
-
# "failed": null
|
4153
|
-
# }
|
4154
|
-
# }
|
4155
|
-
#
|
4395
|
+
request['symbol'] = market['id']
|
4396
|
+
if market['inverse']:
|
4397
|
+
response = await self.cswapV1PrivatePostTradeCloseAllPositions(self.extend(request, params))
|
4398
|
+
#
|
4399
|
+
# {
|
4400
|
+
# "code": 0,
|
4401
|
+
# "msg": "",
|
4402
|
+
# "timestamp": 1720771601428,
|
4403
|
+
# "data": {
|
4404
|
+
# "success": ["1811673520637231104"],
|
4405
|
+
# "failed": null
|
4406
|
+
# }
|
4407
|
+
# }
|
4408
|
+
#
|
4409
|
+
else:
|
4410
|
+
response = await self.swapV2PrivatePostTradeCloseAllPositions(self.extend(request, params))
|
4411
|
+
#
|
4412
|
+
# {
|
4413
|
+
# "code": 0,
|
4414
|
+
# "msg": "",
|
4415
|
+
# "data": {
|
4416
|
+
# "success": [
|
4417
|
+
# 1727686766700486656,
|
4418
|
+
# ],
|
4419
|
+
# "failed": null
|
4420
|
+
# }
|
4421
|
+
# }
|
4422
|
+
#
|
4156
4423
|
data = self.safe_dict(response, 'data')
|
4157
|
-
return self.parse_order(data)
|
4424
|
+
return self.parse_order(data, market)
|
4158
4425
|
|
4159
4426
|
async def close_all_positions(self, params={}) -> List[Position]:
|
4160
4427
|
"""
|
4161
4428
|
closes open positions for a market
|
4162
4429
|
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#One-Click%20Close%20All%20Positions
|
4163
|
-
:
|
4430
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Close%20all%20positions%20in%20bulk
|
4431
|
+
:param dict [params]: extra parameters specific to the bingx api endpoint
|
4164
4432
|
:param str [params.recvWindow]: request valid time window value
|
4165
|
-
:returns dict[]: `
|
4433
|
+
:returns dict[]: `a list of position structures <https://docs.ccxt.com/#/?id=position-structure>`
|
4166
4434
|
"""
|
4167
4435
|
await self.load_markets()
|
4168
4436
|
defaultRecvWindow = self.safe_integer(self.options, 'recvWindow')
|
4169
4437
|
recvWindow = self.safe_integer(self.parse_params, 'recvWindow', defaultRecvWindow)
|
4170
4438
|
marketType = None
|
4171
4439
|
marketType, params = self.handle_market_type_and_params('closeAllPositions', None, params)
|
4440
|
+
subType = None
|
4441
|
+
subType, params = self.handle_sub_type_and_params('closeAllPositions', None, params)
|
4172
4442
|
if marketType == 'margin':
|
4173
4443
|
raise BadRequest(self.id + ' closePositions() cannot be used for ' + marketType + ' markets')
|
4174
4444
|
request: dict = {
|
4175
4445
|
'recvWindow': recvWindow,
|
4176
4446
|
}
|
4177
|
-
response =
|
4178
|
-
|
4179
|
-
|
4180
|
-
|
4181
|
-
|
4182
|
-
|
4183
|
-
|
4184
|
-
|
4185
|
-
|
4186
|
-
|
4187
|
-
|
4188
|
-
|
4189
|
-
|
4190
|
-
|
4447
|
+
response = None
|
4448
|
+
if subType == 'inverse':
|
4449
|
+
response = await self.cswapV1PrivatePostTradeCloseAllPositions(self.extend(request, params))
|
4450
|
+
#
|
4451
|
+
# {
|
4452
|
+
# "code": 0,
|
4453
|
+
# "msg": "",
|
4454
|
+
# "timestamp": 1720771601428,
|
4455
|
+
# "data": {
|
4456
|
+
# "success": ["1811673520637231104"],
|
4457
|
+
# "failed": null
|
4458
|
+
# }
|
4459
|
+
# }
|
4460
|
+
#
|
4461
|
+
else:
|
4462
|
+
response = await self.swapV2PrivatePostTradeCloseAllPositions(self.extend(request, params))
|
4463
|
+
#
|
4464
|
+
# {
|
4465
|
+
# "code": 0,
|
4466
|
+
# "msg": "",
|
4467
|
+
# "data": {
|
4468
|
+
# "success": [
|
4469
|
+
# 1727686766700486656,
|
4470
|
+
# 1727686767048613888
|
4471
|
+
# ],
|
4472
|
+
# "failed": null
|
4473
|
+
# }
|
4474
|
+
# }
|
4475
|
+
#
|
4191
4476
|
data = self.safe_dict(response, 'data', {})
|
4192
4477
|
success = self.safe_list(data, 'success', [])
|
4193
4478
|
positions = []
|