ccxt 4.3.58__py2.py3-none-any.whl → 4.3.60__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 +5 -5
- ccxt/abstract/bingx.py +1 -1
- ccxt/abstract/bitmart.py +1 -0
- ccxt/abstract/btcbox.py +1 -0
- ccxt/abstract/upbit.py +3 -0
- ccxt/abstract/xt.py +1 -0
- ccxt/async_support/__init__.py +5 -5
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/binance.py +91 -2
- ccxt/async_support/bingx.py +448 -123
- ccxt/async_support/bitfinex.py +38 -4
- ccxt/async_support/bitget.py +1 -1
- ccxt/async_support/bitmart.py +1 -0
- ccxt/async_support/bitso.py +4 -1
- ccxt/async_support/btcbox.py +145 -8
- ccxt/async_support/bybit.py +3 -5
- ccxt/async_support/cex.py +1 -1
- ccxt/async_support/coinsph.py +1 -1
- ccxt/async_support/cryptocom.py +11 -5
- ccxt/async_support/deribit.py +15 -1
- ccxt/async_support/digifinex.py +30 -7
- ccxt/async_support/gate.py +17 -18
- ccxt/async_support/htx.py +7 -7
- ccxt/async_support/hyperliquid.py +107 -3
- ccxt/async_support/kraken.py +2 -2
- ccxt/async_support/mexc.py +11 -11
- ccxt/async_support/novadax.py +1 -1
- ccxt/async_support/okcoin.py +1 -1
- ccxt/async_support/okx.py +11 -2
- ccxt/async_support/phemex.py +1 -1
- ccxt/async_support/probit.py +1 -1
- ccxt/async_support/timex.py +16 -2
- ccxt/async_support/tokocrypto.py +1 -1
- ccxt/async_support/upbit.py +139 -45
- ccxt/async_support/xt.py +71 -8
- ccxt/base/errors.py +23 -23
- ccxt/base/exchange.py +9 -9
- ccxt/binance.py +91 -2
- ccxt/bingx.py +448 -123
- ccxt/bitfinex.py +38 -4
- ccxt/bitget.py +1 -1
- ccxt/bitmart.py +1 -0
- ccxt/bitso.py +4 -1
- ccxt/btcbox.py +145 -8
- ccxt/bybit.py +3 -5
- ccxt/cex.py +1 -1
- ccxt/coinsph.py +1 -1
- ccxt/cryptocom.py +11 -5
- ccxt/deribit.py +15 -1
- ccxt/digifinex.py +30 -7
- ccxt/gate.py +17 -18
- ccxt/htx.py +7 -7
- ccxt/hyperliquid.py +107 -3
- ccxt/kraken.py +2 -2
- ccxt/mexc.py +11 -11
- ccxt/novadax.py +1 -1
- ccxt/okcoin.py +1 -1
- ccxt/okx.py +11 -2
- ccxt/phemex.py +1 -1
- ccxt/pro/__init__.py +3 -1
- ccxt/pro/binance.py +11 -13
- ccxt/pro/bingx.py +11 -8
- ccxt/pro/bitmart.py +2 -2
- ccxt/pro/bitopro.py +1 -1
- ccxt/pro/cex.py +1 -1
- ccxt/pro/coincheck.py +1 -1
- ccxt/pro/coinone.py +1 -1
- ccxt/pro/hyperliquid.py +1 -1
- ccxt/pro/kucoin.py +35 -3
- ccxt/pro/phemex.py +1 -1
- ccxt/pro/xt.py +1046 -0
- ccxt/probit.py +1 -1
- ccxt/test/tests_async.py +2 -2
- ccxt/test/tests_helpers.py +1 -1
- ccxt/test/tests_sync.py +2 -2
- ccxt/timex.py +16 -2
- ccxt/tokocrypto.py +1 -1
- ccxt/upbit.py +139 -45
- ccxt/xt.py +71 -8
- {ccxt-4.3.58.dist-info → ccxt-4.3.60.dist-info}/METADATA +5 -5
- {ccxt-4.3.58.dist-info → ccxt-4.3.60.dist-info}/RECORD +84 -83
- {ccxt-4.3.58.dist-info → ccxt-4.3.60.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.3.58.dist-info → ccxt-4.3.60.dist-info}/WHEEL +0 -0
- {ccxt-4.3.58.dist-info → ccxt-4.3.60.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
|
|
@@ -1920,7 +1990,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1920
1990
|
elif timeInForce == 'GTC':
|
1921
1991
|
request['timeInForce'] = 'GTC'
|
1922
1992
|
if isSpot:
|
1923
|
-
cost = self.
|
1993
|
+
cost = self.safe_string_2(params, 'cost', 'quoteOrderQty')
|
1924
1994
|
params = self.omit(params, 'cost')
|
1925
1995
|
if cost is not None:
|
1926
1996
|
request['quoteOrderQty'] = self.parse_to_numeric(self.cost_to_precision(symbol, cost))
|
@@ -2030,7 +2100,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2030
2100
|
else:
|
2031
2101
|
positionSide = 'LONG' if (side == 'buy') else 'SHORT'
|
2032
2102
|
request['positionSide'] = positionSide
|
2033
|
-
request['quantity'] = self.parse_to_numeric(self.amount_to_precision(symbol, amount))
|
2103
|
+
request['quantity'] = amount if (market['inverse']) else self.parse_to_numeric(self.amount_to_precision(symbol, amount)) # precision not available for inverse contracts
|
2034
2104
|
params = self.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingType', 'takeProfit', 'stopLoss', 'clientOrderId'])
|
2035
2105
|
return self.extend(request, params)
|
2036
2106
|
|
@@ -2039,6 +2109,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2039
2109
|
create a trade order
|
2040
2110
|
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Trade%20order
|
2041
2111
|
:see: https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Create%20an%20Order
|
2112
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Trade%20order
|
2042
2113
|
:param str symbol: unified symbol of the market to create an order in
|
2043
2114
|
:param str type: 'market' or 'limit'
|
2044
2115
|
:param str side: 'buy' or 'sell'
|
@@ -2071,6 +2142,8 @@ class bingx(Exchange, ImplicitAPI):
|
|
2071
2142
|
if market['swap']:
|
2072
2143
|
if test:
|
2073
2144
|
response = await self.swapV2PrivatePostTradeOrderTest(request)
|
2145
|
+
elif market['inverse']:
|
2146
|
+
response = await self.cswapV1PrivatePostTradeOrder(request)
|
2074
2147
|
else:
|
2075
2148
|
response = await self.swapV2PrivatePostTradeOrder(request)
|
2076
2149
|
else:
|
@@ -2095,7 +2168,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2095
2168
|
# }
|
2096
2169
|
# }
|
2097
2170
|
#
|
2098
|
-
# swap
|
2171
|
+
# linear swap
|
2099
2172
|
#
|
2100
2173
|
# {
|
2101
2174
|
# "code": 0,
|
@@ -2113,15 +2186,37 @@ class bingx(Exchange, ImplicitAPI):
|
|
2113
2186
|
# }
|
2114
2187
|
# }
|
2115
2188
|
#
|
2189
|
+
# inverse swap
|
2190
|
+
#
|
2191
|
+
# {
|
2192
|
+
# "orderId": 1809841379603398656,
|
2193
|
+
# "symbol": "SOL-USD",
|
2194
|
+
# "positionSide": "LONG",
|
2195
|
+
# "side": "BUY",
|
2196
|
+
# "type": "LIMIT",
|
2197
|
+
# "price": 100,
|
2198
|
+
# "quantity": 1,
|
2199
|
+
# "stopPrice": 0,
|
2200
|
+
# "workingType": "",
|
2201
|
+
# "timeInForce": ""
|
2202
|
+
# }
|
2203
|
+
#
|
2116
2204
|
if isinstance(response, str):
|
2117
2205
|
# broken api engine : order-ids are too long numbers(i.e. 1742930526912864656)
|
2118
2206
|
# and json.loadscan not handle them in JS, so we have to use .parseJson
|
2119
2207
|
# however, when order has an attached SL/TP, their value types need extra parsing
|
2120
2208
|
response = self.fix_stringified_json_members(response)
|
2121
2209
|
response = self.parse_json(response)
|
2122
|
-
data = self.
|
2123
|
-
|
2124
|
-
|
2210
|
+
data = self.safe_dict(response, 'data', {})
|
2211
|
+
result: dict = {}
|
2212
|
+
if market['swap']:
|
2213
|
+
if market['inverse']:
|
2214
|
+
result = response
|
2215
|
+
else:
|
2216
|
+
result = self.safe_dict(data, 'order', {})
|
2217
|
+
else:
|
2218
|
+
result = data
|
2219
|
+
return self.parse_order(result, market)
|
2125
2220
|
|
2126
2221
|
async def create_orders(self, orders: List[OrderRequest], params={}):
|
2127
2222
|
"""
|
@@ -2287,7 +2382,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2287
2382
|
# }
|
2288
2383
|
#
|
2289
2384
|
#
|
2290
|
-
# swap
|
2385
|
+
# linear swap
|
2291
2386
|
# createOrder, createOrders
|
2292
2387
|
#
|
2293
2388
|
# {
|
@@ -2298,6 +2393,21 @@ class bingx(Exchange, ImplicitAPI):
|
|
2298
2393
|
# "type": "LIMIT"
|
2299
2394
|
# }
|
2300
2395
|
#
|
2396
|
+
# inverse swap createOrder
|
2397
|
+
#
|
2398
|
+
# {
|
2399
|
+
# "orderId": 1809841379603398656,
|
2400
|
+
# "symbol": "SOL-USD",
|
2401
|
+
# "positionSide": "LONG",
|
2402
|
+
# "side": "BUY",
|
2403
|
+
# "type": "LIMIT",
|
2404
|
+
# "price": 100,
|
2405
|
+
# "quantity": 1,
|
2406
|
+
# "stopPrice": 0,
|
2407
|
+
# "workingType": "",
|
2408
|
+
# "timeInForce": ""
|
2409
|
+
# }
|
2410
|
+
#
|
2301
2411
|
# fetchOrder, fetchOpenOrders, fetchClosedOrders
|
2302
2412
|
#
|
2303
2413
|
# {
|
@@ -2430,7 +2540,9 @@ class bingx(Exchange, ImplicitAPI):
|
|
2430
2540
|
# side: 'SELL'
|
2431
2541
|
# }
|
2432
2542
|
# }
|
2543
|
+
#
|
2433
2544
|
# stop loss order
|
2545
|
+
#
|
2434
2546
|
# {
|
2435
2547
|
# "symbol": "ETH-USDT",
|
2436
2548
|
# "orderId": "1792461744476422144",
|
@@ -2450,6 +2562,52 @@ class bingx(Exchange, ImplicitAPI):
|
|
2450
2562
|
# "clientOrderID": ""
|
2451
2563
|
# }
|
2452
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
|
+
#
|
2453
2611
|
info = order
|
2454
2612
|
newOrder = self.safe_dict_2(order, 'newOrderResponse', 'orderOpenResponse')
|
2455
2613
|
if newOrder is not None:
|
@@ -2630,6 +2788,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
2630
2788
|
cancel all open orders
|
2631
2789
|
:see: https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20orders%20by%20symbol
|
2632
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
|
2633
2792
|
:param str [symbol]: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
|
2634
2793
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2635
2794
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
@@ -2667,36 +2826,94 @@ class bingx(Exchange, ImplicitAPI):
|
|
2667
2826
|
# }
|
2668
2827
|
#
|
2669
2828
|
elif market['swap']:
|
2670
|
-
|
2671
|
-
|
2672
|
-
|
2673
|
-
|
2674
|
-
|
2675
|
-
|
2676
|
-
|
2677
|
-
|
2678
|
-
|
2679
|
-
|
2680
|
-
|
2681
|
-
|
2682
|
-
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2688
|
-
|
2689
|
-
|
2690
|
-
|
2691
|
-
|
2692
|
-
|
2693
|
-
|
2694
|
-
|
2695
|
-
|
2696
|
-
|
2697
|
-
|
2698
|
-
|
2699
|
-
|
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
|
+
#
|
2700
2917
|
else:
|
2701
2918
|
raise BadRequest(self.id + ' cancelAllOrders is only supported for spot and swap markets.')
|
2702
2919
|
data = self.safe_dict(response, 'data', {})
|
@@ -3671,6 +3888,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3671
3888
|
"""
|
3672
3889
|
fetch the set leverage for a market
|
3673
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
|
3674
3892
|
:param str symbol: unified market symbol
|
3675
3893
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3676
3894
|
:returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
|
@@ -3680,21 +3898,77 @@ class bingx(Exchange, ImplicitAPI):
|
|
3680
3898
|
request: dict = {
|
3681
3899
|
'symbol': market['id'],
|
3682
3900
|
}
|
3683
|
-
response =
|
3684
|
-
|
3685
|
-
|
3686
|
-
|
3687
|
-
|
3688
|
-
|
3689
|
-
|
3690
|
-
|
3691
|
-
|
3692
|
-
|
3693
|
-
|
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
|
+
#
|
3694
3940
|
data = self.safe_dict(response, 'data', {})
|
3695
3941
|
return self.parse_leverage(data, market)
|
3696
3942
|
|
3697
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
|
+
#
|
3698
3972
|
marketId = self.safe_string(leverage, 'symbol')
|
3699
3973
|
return {
|
3700
3974
|
'info': leverage,
|
@@ -3708,6 +3982,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3708
3982
|
"""
|
3709
3983
|
set the level of leverage for a market
|
3710
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
|
3711
3986
|
:param float leverage: the rate of leverage
|
3712
3987
|
:param str symbol: unified market symbol
|
3713
3988
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
@@ -3725,17 +4000,42 @@ class bingx(Exchange, ImplicitAPI):
|
|
3725
4000
|
'side': side,
|
3726
4001
|
'leverage': leverage,
|
3727
4002
|
}
|
3728
|
-
|
3729
|
-
|
3730
|
-
|
3731
|
-
|
3732
|
-
|
3733
|
-
|
3734
|
-
|
3735
|
-
|
3736
|
-
|
3737
|
-
|
3738
|
-
|
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
|
+
#
|
3739
4039
|
|
3740
4040
|
async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
3741
4041
|
"""
|
@@ -4061,93 +4361,118 @@ class bingx(Exchange, ImplicitAPI):
|
|
4061
4361
|
"""
|
4062
4362
|
closes open positions for a market
|
4063
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
|
4064
4365
|
:param str symbol: Unified CCXT market symbol
|
4065
4366
|
:param str [side]: not used by bingx
|
4066
4367
|
:param dict [params]: extra parameters specific to the bingx api endpoint
|
4067
|
-
:param str|None [params.positionId]:
|
4368
|
+
:param str|None [params.positionId]: the id of the position you would like to close
|
4068
4369
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
4069
4370
|
"""
|
4070
4371
|
await self.load_markets()
|
4372
|
+
market = self.market(symbol)
|
4071
4373
|
positionId = self.safe_string(params, 'positionId')
|
4072
|
-
|
4374
|
+
request: dict = {}
|
4073
4375
|
response = None
|
4074
4376
|
if positionId is not None:
|
4075
|
-
request: dict = {
|
4076
|
-
'positionId': positionId,
|
4077
|
-
}
|
4078
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
|
+
#
|
4079
4394
|
else:
|
4080
|
-
|
4081
|
-
|
4082
|
-
|
4083
|
-
|
4084
|
-
|
4085
|
-
|
4086
|
-
|
4087
|
-
|
4088
|
-
|
4089
|
-
|
4090
|
-
|
4091
|
-
|
4092
|
-
|
4093
|
-
|
4094
|
-
|
4095
|
-
|
4096
|
-
|
4097
|
-
|
4098
|
-
|
4099
|
-
|
4100
|
-
|
4101
|
-
|
4102
|
-
|
4103
|
-
|
4104
|
-
|
4105
|
-
|
4106
|
-
|
4107
|
-
|
4108
|
-
# "data": {
|
4109
|
-
# "success": [
|
4110
|
-
# 1727686766700486656,
|
4111
|
-
# ],
|
4112
|
-
# "failed": null
|
4113
|
-
# }
|
4114
|
-
# }
|
4115
|
-
#
|
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
|
+
#
|
4116
4423
|
data = self.safe_dict(response, 'data')
|
4117
|
-
return self.parse_order(data)
|
4424
|
+
return self.parse_order(data, market)
|
4118
4425
|
|
4119
4426
|
async def close_all_positions(self, params={}) -> List[Position]:
|
4120
4427
|
"""
|
4121
4428
|
closes open positions for a market
|
4122
4429
|
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#One-Click%20Close%20All%20Positions
|
4123
|
-
:
|
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
|
4124
4432
|
:param str [params.recvWindow]: request valid time window value
|
4125
|
-
:returns dict[]: `
|
4433
|
+
:returns dict[]: `a list of position structures <https://docs.ccxt.com/#/?id=position-structure>`
|
4126
4434
|
"""
|
4127
4435
|
await self.load_markets()
|
4128
4436
|
defaultRecvWindow = self.safe_integer(self.options, 'recvWindow')
|
4129
4437
|
recvWindow = self.safe_integer(self.parse_params, 'recvWindow', defaultRecvWindow)
|
4130
4438
|
marketType = None
|
4131
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)
|
4132
4442
|
if marketType == 'margin':
|
4133
4443
|
raise BadRequest(self.id + ' closePositions() cannot be used for ' + marketType + ' markets')
|
4134
4444
|
request: dict = {
|
4135
4445
|
'recvWindow': recvWindow,
|
4136
4446
|
}
|
4137
|
-
response =
|
4138
|
-
|
4139
|
-
|
4140
|
-
|
4141
|
-
|
4142
|
-
|
4143
|
-
|
4144
|
-
|
4145
|
-
|
4146
|
-
|
4147
|
-
|
4148
|
-
|
4149
|
-
|
4150
|
-
|
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
|
+
#
|
4151
4476
|
data = self.safe_dict(response, 'data', {})
|
4152
4477
|
success = self.safe_list(data, 'success', [])
|
4153
4478
|
positions = []
|