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