ccxt 4.3.62__py2.py3-none-any.whl → 4.3.63__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 +2 -1
- ccxt/abstract/binance.py +5 -5
- ccxt/abstract/binancecoinm.py +5 -5
- ccxt/abstract/binanceus.py +5 -5
- ccxt/abstract/binanceusdm.py +5 -5
- ccxt/abstract/cryptocom.py +11 -0
- ccxt/abstract/woo.py +3 -0
- ccxt/ace.py +33 -15
- ccxt/async_support/__init__.py +2 -1
- ccxt/async_support/ace.py +33 -15
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/binance.py +6 -9
- ccxt/async_support/bingx.py +451 -151
- ccxt/async_support/coinbaseinternational.py +1 -1
- ccxt/async_support/cryptocom.py +17 -2
- ccxt/async_support/mercado.py +5 -1
- ccxt/async_support/woo.py +296 -81
- ccxt/async_support/xt.py +3 -3
- ccxt/base/errors.py +8 -1
- ccxt/base/exchange.py +8 -2
- ccxt/binance.py +6 -9
- ccxt/bingx.py +451 -151
- ccxt/coinbaseinternational.py +1 -1
- ccxt/cryptocom.py +17 -2
- ccxt/mercado.py +5 -1
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/binance.py +56 -35
- ccxt/pro/bitfinex2.py +6 -4
- ccxt/pro/bitget.py +5 -2
- ccxt/pro/bitvavo.py +1 -1
- ccxt/pro/bybit.py +41 -18
- ccxt/pro/cryptocom.py +7 -2
- ccxt/pro/gate.py +6 -3
- ccxt/pro/htx.py +5 -1
- ccxt/pro/independentreserve.py +6 -4
- ccxt/pro/kraken.py +79 -6
- ccxt/pro/okx.py +4 -4
- ccxt/pro/poloniexfutures.py +5 -2
- ccxt/pro/woofipro.py +1 -1
- ccxt/woo.py +296 -81
- ccxt/xt.py +3 -3
- {ccxt-4.3.62.dist-info → ccxt-4.3.63.dist-info}/METADATA +4 -4
- {ccxt-4.3.62.dist-info → ccxt-4.3.63.dist-info}/RECORD +46 -46
- {ccxt-4.3.62.dist-info → ccxt-4.3.63.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.3.62.dist-info → ccxt-4.3.63.dist-info}/WHEEL +0 -0
- {ccxt-4.3.62.dist-info → ccxt-4.3.63.dist-info}/top_level.txt +0 -0
ccxt/async_support/bingx.py
CHANGED
@@ -86,6 +86,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
86
86
|
'fetchOrder': True,
|
87
87
|
'fetchOrderBook': True,
|
88
88
|
'fetchOrders': True,
|
89
|
+
'fetchPosition': True,
|
89
90
|
'fetchPositionHistory': False,
|
90
91
|
'fetchPositionMode': True,
|
91
92
|
'fetchPositions': True,
|
@@ -1699,6 +1700,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1699
1700
|
:see: https://bingx-api.github.io/docs/#/spot/trade-api.html#Query%20Assets
|
1700
1701
|
:see: https://bingx-api.github.io/docs/#/swapV2/account-api.html#Get%20Perpetual%20Swap%20Account%20Asset%20Information
|
1701
1702
|
:see: https://bingx-api.github.io/docs/#/standard/contract-interface.html#Query%20standard%20contract%20balance
|
1703
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Account%20Assets
|
1702
1704
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1703
1705
|
:param boolean [params.standard]: whether to fetch standard contract balances
|
1704
1706
|
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
@@ -1707,111 +1709,220 @@ class bingx(Exchange, ImplicitAPI):
|
|
1707
1709
|
response = None
|
1708
1710
|
standard = None
|
1709
1711
|
standard, params = self.handle_option_and_params(params, 'fetchBalance', 'standard', False)
|
1712
|
+
subType = None
|
1713
|
+
subType, params = self.handle_sub_type_and_params('fetchBalance', None, params)
|
1710
1714
|
marketType, marketTypeQuery = self.handle_market_type_and_params('fetchBalance', None, params)
|
1711
1715
|
if standard:
|
1712
1716
|
response = await self.contractV1PrivateGetBalance(marketTypeQuery)
|
1717
|
+
#
|
1718
|
+
# {
|
1719
|
+
# "code": 0,
|
1720
|
+
# "timestamp": 1721192833454,
|
1721
|
+
# "data": [
|
1722
|
+
# {
|
1723
|
+
# "asset": "USDT",
|
1724
|
+
# "balance": "4.72644300000000000000",
|
1725
|
+
# "crossWalletBalance": "4.72644300000000000000",
|
1726
|
+
# "crossUnPnl": "0",
|
1727
|
+
# "availableBalance": "4.72644300000000000000",
|
1728
|
+
# "maxWithdrawAmount": "4.72644300000000000000",
|
1729
|
+
# "marginAvailable": False,
|
1730
|
+
# "updateTime": 1721192833443
|
1731
|
+
# },
|
1732
|
+
# ]
|
1733
|
+
# }
|
1734
|
+
#
|
1713
1735
|
elif marketType == 'spot':
|
1714
1736
|
response = await self.spotV1PrivateGetAccountBalance(marketTypeQuery)
|
1737
|
+
#
|
1738
|
+
# {
|
1739
|
+
# "code": 0,
|
1740
|
+
# "msg": "",
|
1741
|
+
# "debugMsg": "",
|
1742
|
+
# "data": {
|
1743
|
+
# "balances": [
|
1744
|
+
# {
|
1745
|
+
# "asset": "USDT",
|
1746
|
+
# "free": "45.733046995800514",
|
1747
|
+
# "locked": "0"
|
1748
|
+
# },
|
1749
|
+
# ]
|
1750
|
+
# }
|
1751
|
+
# }
|
1752
|
+
#
|
1715
1753
|
else:
|
1716
|
-
|
1754
|
+
if subType == 'inverse':
|
1755
|
+
response = await self.cswapV1PrivateGetUserBalance(marketTypeQuery)
|
1756
|
+
#
|
1757
|
+
# {
|
1758
|
+
# "code": 0,
|
1759
|
+
# "msg": "",
|
1760
|
+
# "timestamp": 1721191833813,
|
1761
|
+
# "data": [
|
1762
|
+
# {
|
1763
|
+
# "asset": "SOL",
|
1764
|
+
# "balance": "0.35707951",
|
1765
|
+
# "equity": "0.35791051",
|
1766
|
+
# "unrealizedProfit": "0.00083099",
|
1767
|
+
# "availableMargin": "0.35160653",
|
1768
|
+
# "usedMargin": "0.00630397",
|
1769
|
+
# "freezedMargin": "0",
|
1770
|
+
# "shortUid": "12851936"
|
1771
|
+
# }
|
1772
|
+
# ]
|
1773
|
+
# }
|
1774
|
+
#
|
1775
|
+
else:
|
1776
|
+
response = await self.swapV2PrivateGetUserBalance(marketTypeQuery)
|
1777
|
+
#
|
1778
|
+
# {
|
1779
|
+
# "code": 0,
|
1780
|
+
# "msg": "",
|
1781
|
+
# "data": {
|
1782
|
+
# "balance": {
|
1783
|
+
# "userId": "1177064765068660742",
|
1784
|
+
# "asset": "USDT",
|
1785
|
+
# "balance": "51.5198",
|
1786
|
+
# "equity": "50.5349",
|
1787
|
+
# "unrealizedProfit": "-0.9849",
|
1788
|
+
# "realisedProfit": "-0.2134",
|
1789
|
+
# "availableMargin": "49.1428",
|
1790
|
+
# "usedMargin": "1.3922",
|
1791
|
+
# "freezedMargin": "0.0000",
|
1792
|
+
# "shortUid": "12851936"
|
1793
|
+
# }
|
1794
|
+
# }
|
1795
|
+
# }
|
1796
|
+
#
|
1797
|
+
return self.parse_balance(response)
|
1798
|
+
|
1799
|
+
def parse_balance(self, response) -> Balances:
|
1800
|
+
#
|
1801
|
+
# standard
|
1802
|
+
#
|
1803
|
+
# {
|
1804
|
+
# "code": 0,
|
1805
|
+
# "timestamp": 1721192833454,
|
1806
|
+
# "data": [
|
1807
|
+
# {
|
1808
|
+
# "asset": "USDT",
|
1809
|
+
# "balance": "4.72644300000000000000",
|
1810
|
+
# "crossWalletBalance": "4.72644300000000000000",
|
1811
|
+
# "crossUnPnl": "0",
|
1812
|
+
# "availableBalance": "4.72644300000000000000",
|
1813
|
+
# "maxWithdrawAmount": "4.72644300000000000000",
|
1814
|
+
# "marginAvailable": False,
|
1815
|
+
# "updateTime": 1721192833443
|
1816
|
+
# },
|
1817
|
+
# ]
|
1818
|
+
# }
|
1717
1819
|
#
|
1718
1820
|
# spot
|
1719
1821
|
#
|
1720
|
-
#
|
1721
|
-
#
|
1722
|
-
#
|
1723
|
-
#
|
1724
|
-
#
|
1725
|
-
#
|
1726
|
-
#
|
1727
|
-
#
|
1728
|
-
#
|
1729
|
-
#
|
1730
|
-
#
|
1731
|
-
#
|
1732
|
-
#
|
1733
|
-
#
|
1822
|
+
# {
|
1823
|
+
# "code": 0,
|
1824
|
+
# "msg": "",
|
1825
|
+
# "debugMsg": "",
|
1826
|
+
# "data": {
|
1827
|
+
# "balances": [
|
1828
|
+
# {
|
1829
|
+
# "asset": "USDT",
|
1830
|
+
# "free": "45.733046995800514",
|
1831
|
+
# "locked": "0"
|
1832
|
+
# },
|
1833
|
+
# ]
|
1834
|
+
# }
|
1835
|
+
# }
|
1734
1836
|
#
|
1735
|
-
# swap
|
1837
|
+
# inverse swap
|
1736
1838
|
#
|
1737
|
-
#
|
1738
|
-
#
|
1739
|
-
#
|
1740
|
-
#
|
1741
|
-
#
|
1742
|
-
#
|
1743
|
-
#
|
1744
|
-
#
|
1745
|
-
#
|
1746
|
-
#
|
1747
|
-
#
|
1748
|
-
#
|
1749
|
-
#
|
1750
|
-
#
|
1751
|
-
#
|
1752
|
-
#
|
1753
|
-
#
|
1754
|
-
#
|
1755
|
-
#
|
1756
|
-
#
|
1757
|
-
#
|
1758
|
-
#
|
1759
|
-
#
|
1760
|
-
#
|
1761
|
-
#
|
1762
|
-
#
|
1763
|
-
#
|
1764
|
-
#
|
1765
|
-
#
|
1766
|
-
#
|
1767
|
-
#
|
1768
|
-
#
|
1769
|
-
#
|
1770
|
-
#
|
1771
|
-
#
|
1772
|
-
#
|
1773
|
-
#
|
1774
|
-
# "maxWithdrawAmount":"0",
|
1775
|
-
# "marginAvailable":false,
|
1776
|
-
# "updateTime":"1691148990902"
|
1777
|
-
# },
|
1778
|
-
# ]
|
1839
|
+
# {
|
1840
|
+
# "code": 0,
|
1841
|
+
# "msg": "",
|
1842
|
+
# "timestamp": 1721191833813,
|
1843
|
+
# "data": [
|
1844
|
+
# {
|
1845
|
+
# "asset": "SOL",
|
1846
|
+
# "balance": "0.35707951",
|
1847
|
+
# "equity": "0.35791051",
|
1848
|
+
# "unrealizedProfit": "0.00083099",
|
1849
|
+
# "availableMargin": "0.35160653",
|
1850
|
+
# "usedMargin": "0.00630397",
|
1851
|
+
# "freezedMargin": "0",
|
1852
|
+
# "shortUid": "12851936"
|
1853
|
+
# }
|
1854
|
+
# ]
|
1855
|
+
# }
|
1856
|
+
#
|
1857
|
+
# linear swap
|
1858
|
+
#
|
1859
|
+
# {
|
1860
|
+
# "code": 0,
|
1861
|
+
# "msg": "",
|
1862
|
+
# "data": {
|
1863
|
+
# "balance": {
|
1864
|
+
# "userId": "1177064765068660742",
|
1865
|
+
# "asset": "USDT",
|
1866
|
+
# "balance": "51.5198",
|
1867
|
+
# "equity": "50.5349",
|
1868
|
+
# "unrealizedProfit": "-0.9849",
|
1869
|
+
# "realisedProfit": "-0.2134",
|
1870
|
+
# "availableMargin": "49.1428",
|
1871
|
+
# "usedMargin": "1.3922",
|
1872
|
+
# "freezedMargin": "0.0000",
|
1873
|
+
# "shortUid": "12851936"
|
1874
|
+
# }
|
1875
|
+
# }
|
1779
1876
|
# }
|
1780
1877
|
#
|
1781
|
-
return self.parse_balance(response)
|
1782
|
-
|
1783
|
-
def parse_balance(self, response) -> Balances:
|
1784
|
-
data = self.safe_value(response, 'data')
|
1785
|
-
balances = self.safe_value_2(data, 'balance', 'balances', data)
|
1786
1878
|
result: dict = {'info': response}
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1879
|
+
standardAndInverseBalances = self.safe_list(response, 'data')
|
1880
|
+
firstStandardOrInverse = self.safe_dict(standardAndInverseBalances, 0)
|
1881
|
+
isStandardOrInverse = firstStandardOrInverse is not None
|
1882
|
+
spotData = self.safe_dict(response, 'data', {})
|
1883
|
+
spotBalances = self.safe_list(spotData, 'balances')
|
1884
|
+
firstSpot = self.safe_dict(spotBalances, 0)
|
1885
|
+
isSpot = firstSpot is not None
|
1886
|
+
if isStandardOrInverse:
|
1887
|
+
for i in range(0, len(standardAndInverseBalances)):
|
1888
|
+
balance = standardAndInverseBalances[i]
|
1889
|
+
currencyId = self.safe_string(balance, 'asset')
|
1890
|
+
code = self.safe_currency_code(currencyId)
|
1891
|
+
account = self.account()
|
1892
|
+
account['free'] = self.safe_string_2(balance, 'availableMargin', 'availableBalance')
|
1893
|
+
account['used'] = self.safe_string(balance, 'usedMargin')
|
1894
|
+
account['total'] = self.safe_string(balance, 'maxWithdrawAmount')
|
1895
|
+
result[code] = account
|
1896
|
+
elif isSpot:
|
1897
|
+
for i in range(0, len(spotBalances)):
|
1898
|
+
balance = spotBalances[i]
|
1790
1899
|
currencyId = self.safe_string(balance, 'asset')
|
1791
1900
|
code = self.safe_currency_code(currencyId)
|
1792
1901
|
account = self.account()
|
1793
|
-
account['free'] = self.
|
1902
|
+
account['free'] = self.safe_string(balance, 'free')
|
1794
1903
|
account['used'] = self.safe_string(balance, 'locked')
|
1795
|
-
account['total'] = self.safe_string(balance, 'balance')
|
1796
1904
|
result[code] = account
|
1797
1905
|
else:
|
1798
|
-
|
1906
|
+
linearSwapData = self.safe_dict(response, 'data', {})
|
1907
|
+
linearSwapBalance = self.safe_dict(linearSwapData, 'balance')
|
1908
|
+
currencyId = self.safe_string(linearSwapBalance, 'asset')
|
1799
1909
|
code = self.safe_currency_code(currencyId)
|
1800
1910
|
account = self.account()
|
1801
|
-
account['free'] = self.safe_string(
|
1802
|
-
account['used'] = self.safe_string(
|
1911
|
+
account['free'] = self.safe_string(linearSwapBalance, 'availableMargin')
|
1912
|
+
account['used'] = self.safe_string(linearSwapBalance, 'usedMargin')
|
1803
1913
|
result[code] = account
|
1804
1914
|
return self.safe_balance(result)
|
1805
1915
|
|
1806
1916
|
async def fetch_positions(self, symbols: Strings = None, params={}):
|
1807
1917
|
"""
|
1808
1918
|
fetch all open positions
|
1809
|
-
:see: https://bingx-api.github.io/docs/#/swapV2/account-api.html#
|
1810
|
-
:see: https://bingx-api.github.io/docs/#/standard/contract-interface.html#
|
1919
|
+
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query%20position%20data
|
1920
|
+
:see: https://bingx-api.github.io/docs/#/en-us/standard/contract-interface.html#position
|
1921
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20warehouse
|
1811
1922
|
:param str[]|None symbols: list of unified market symbols
|
1812
1923
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1813
1924
|
:param boolean [params.standard]: whether to fetch standard contract positions
|
1814
|
-
:returns dict[]: a list of `position
|
1925
|
+
:returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
|
1815
1926
|
"""
|
1816
1927
|
await self.load_markets()
|
1817
1928
|
symbols = self.market_symbols(symbols)
|
@@ -1821,54 +1932,207 @@ class bingx(Exchange, ImplicitAPI):
|
|
1821
1932
|
if standard:
|
1822
1933
|
response = await self.contractV1PrivateGetAllPosition(params)
|
1823
1934
|
else:
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1935
|
+
market = None
|
1936
|
+
if symbols is not None:
|
1937
|
+
symbols = self.market_symbols(symbols)
|
1938
|
+
firstSymbol = self.safe_string(symbols, 0)
|
1939
|
+
if firstSymbol is not None:
|
1940
|
+
market = self.market(firstSymbol)
|
1941
|
+
subType = None
|
1942
|
+
subType, params = self.handle_sub_type_and_params('fetchPositions', market, params)
|
1943
|
+
if subType == 'inverse':
|
1944
|
+
response = await self.cswapV1PrivateGetUserPositions(params)
|
1945
|
+
#
|
1946
|
+
# {
|
1947
|
+
# "code": 0,
|
1948
|
+
# "msg": "",
|
1949
|
+
# "timestamp": 0,
|
1950
|
+
# "data": [
|
1951
|
+
# {
|
1952
|
+
# "symbol": "SOL-USD",
|
1953
|
+
# "positionId": "1813080351385337856",
|
1954
|
+
# "positionSide": "LONG",
|
1955
|
+
# "isolated": False,
|
1956
|
+
# "positionAmt": "1",
|
1957
|
+
# "availableAmt": "1",
|
1958
|
+
# "unrealizedProfit": "-0.00009074",
|
1959
|
+
# "initialMargin": "0.00630398",
|
1960
|
+
# "liquidationPrice": 23.968303426677032,
|
1961
|
+
# "avgPrice": "158.63",
|
1962
|
+
# "leverage": 10,
|
1963
|
+
# "markPrice": "158.402",
|
1964
|
+
# "riskRate": "0.00123783",
|
1965
|
+
# "maxMarginReduction": "0",
|
1966
|
+
# "updateTime": 1721107015848
|
1967
|
+
# }
|
1968
|
+
# ]
|
1969
|
+
# }
|
1970
|
+
#
|
1971
|
+
else:
|
1972
|
+
response = await self.swapV2PrivateGetUserPositions(params)
|
1973
|
+
#
|
1974
|
+
# {
|
1975
|
+
# "code": 0,
|
1976
|
+
# "msg": "",
|
1977
|
+
# "data": [
|
1978
|
+
# {
|
1979
|
+
# "positionId": "1792480725958881280",
|
1980
|
+
# "symbol": "LTC-USDT",
|
1981
|
+
# "currency": "USDT",
|
1982
|
+
# "positionAmt": "0.1",
|
1983
|
+
# "availableAmt": "0.1",
|
1984
|
+
# "positionSide": "LONG",
|
1985
|
+
# "isolated": False,
|
1986
|
+
# "avgPrice": "83.53",
|
1987
|
+
# "initialMargin": "1.3922",
|
1988
|
+
# "margin": "0.3528",
|
1989
|
+
# "leverage": 6,
|
1990
|
+
# "unrealizedProfit": "-1.0393",
|
1991
|
+
# "realisedProfit": "-0.2119",
|
1992
|
+
# "liquidationPrice": 0,
|
1993
|
+
# "pnlRatio": "-0.7465",
|
1994
|
+
# "maxMarginReduction": "0.0000",
|
1995
|
+
# "riskRate": "0.0008",
|
1996
|
+
# "markPrice": "73.14",
|
1997
|
+
# "positionValue": "7.3136",
|
1998
|
+
# "onlyOnePosition": True,
|
1999
|
+
# "updateTime": 1721088016688
|
2000
|
+
# }
|
2001
|
+
# ]
|
2002
|
+
# }
|
2003
|
+
#
|
1846
2004
|
positions = self.safe_list(response, 'data', [])
|
1847
2005
|
return self.parse_positions(positions, symbols)
|
1848
2006
|
|
2007
|
+
async def fetch_position(self, symbol: str, params={}):
|
2008
|
+
"""
|
2009
|
+
fetch data on a single open contract trade position
|
2010
|
+
:see: https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query%20position%20data
|
2011
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20warehouse
|
2012
|
+
:param str symbol: unified market symbol of the market the position is held in
|
2013
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2014
|
+
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
2015
|
+
"""
|
2016
|
+
await self.load_markets()
|
2017
|
+
market = self.market(symbol)
|
2018
|
+
if not market['swap']:
|
2019
|
+
raise BadRequest(self.id + ' fetchPosition() supports swap markets only')
|
2020
|
+
request: dict = {
|
2021
|
+
'symbol': market['id'],
|
2022
|
+
}
|
2023
|
+
response = None
|
2024
|
+
if market['inverse']:
|
2025
|
+
response = await self.cswapV1PrivateGetUserPositions(self.extend(request, params))
|
2026
|
+
#
|
2027
|
+
# {
|
2028
|
+
# "code": 0,
|
2029
|
+
# "msg": "",
|
2030
|
+
# "timestamp": 0,
|
2031
|
+
# "data": [
|
2032
|
+
# {
|
2033
|
+
# "symbol": "SOL-USD",
|
2034
|
+
# "positionId": "1813080351385337856",
|
2035
|
+
# "positionSide": "LONG",
|
2036
|
+
# "isolated": False,
|
2037
|
+
# "positionAmt": "1",
|
2038
|
+
# "availableAmt": "1",
|
2039
|
+
# "unrealizedProfit": "-0.00009074",
|
2040
|
+
# "initialMargin": "0.00630398",
|
2041
|
+
# "liquidationPrice": 23.968303426677032,
|
2042
|
+
# "avgPrice": "158.63",
|
2043
|
+
# "leverage": 10,
|
2044
|
+
# "markPrice": "158.402",
|
2045
|
+
# "riskRate": "0.00123783",
|
2046
|
+
# "maxMarginReduction": "0",
|
2047
|
+
# "updateTime": 1721107015848
|
2048
|
+
# }
|
2049
|
+
# ]
|
2050
|
+
# }
|
2051
|
+
#
|
2052
|
+
else:
|
2053
|
+
response = await self.swapV2PrivateGetUserPositions(self.extend(request, params))
|
2054
|
+
#
|
2055
|
+
# {
|
2056
|
+
# "code": 0,
|
2057
|
+
# "msg": "",
|
2058
|
+
# "data": [
|
2059
|
+
# {
|
2060
|
+
# "positionId": "1792480725958881280",
|
2061
|
+
# "symbol": "LTC-USDT",
|
2062
|
+
# "currency": "USDT",
|
2063
|
+
# "positionAmt": "0.1",
|
2064
|
+
# "availableAmt": "0.1",
|
2065
|
+
# "positionSide": "LONG",
|
2066
|
+
# "isolated": False,
|
2067
|
+
# "avgPrice": "83.53",
|
2068
|
+
# "initialMargin": "1.3922",
|
2069
|
+
# "margin": "0.3528",
|
2070
|
+
# "leverage": 6,
|
2071
|
+
# "unrealizedProfit": "-1.0393",
|
2072
|
+
# "realisedProfit": "-0.2119",
|
2073
|
+
# "liquidationPrice": 0,
|
2074
|
+
# "pnlRatio": "-0.7465",
|
2075
|
+
# "maxMarginReduction": "0.0000",
|
2076
|
+
# "riskRate": "0.0008",
|
2077
|
+
# "markPrice": "73.14",
|
2078
|
+
# "positionValue": "7.3136",
|
2079
|
+
# "onlyOnePosition": True,
|
2080
|
+
# "updateTime": 1721088016688
|
2081
|
+
# }
|
2082
|
+
# ]
|
2083
|
+
# }
|
2084
|
+
#
|
2085
|
+
data = self.safe_list(response, 'data', [])
|
2086
|
+
first = self.safe_dict(data, 0, {})
|
2087
|
+
return self.parse_position(first, market)
|
2088
|
+
|
1849
2089
|
def parse_position(self, position: dict, market: Market = None):
|
1850
2090
|
#
|
1851
|
-
#
|
1852
|
-
#
|
1853
|
-
#
|
1854
|
-
#
|
1855
|
-
#
|
1856
|
-
#
|
1857
|
-
#
|
1858
|
-
#
|
1859
|
-
#
|
1860
|
-
#
|
1861
|
-
#
|
1862
|
-
#
|
1863
|
-
#
|
1864
|
-
#
|
1865
|
-
#
|
1866
|
-
#
|
1867
|
-
#
|
1868
|
-
#
|
1869
|
-
#
|
1870
|
-
#
|
1871
|
-
#
|
2091
|
+
# inverse swap
|
2092
|
+
#
|
2093
|
+
# {
|
2094
|
+
# "symbol": "SOL-USD",
|
2095
|
+
# "positionId": "1813080351385337856",
|
2096
|
+
# "positionSide": "LONG",
|
2097
|
+
# "isolated": False,
|
2098
|
+
# "positionAmt": "1",
|
2099
|
+
# "availableAmt": "1",
|
2100
|
+
# "unrealizedProfit": "-0.00009074",
|
2101
|
+
# "initialMargin": "0.00630398",
|
2102
|
+
# "liquidationPrice": 23.968303426677032,
|
2103
|
+
# "avgPrice": "158.63",
|
2104
|
+
# "leverage": 10,
|
2105
|
+
# "markPrice": "158.402",
|
2106
|
+
# "riskRate": "0.00123783",
|
2107
|
+
# "maxMarginReduction": "0",
|
2108
|
+
# "updateTime": 1721107015848
|
2109
|
+
# }
|
2110
|
+
#
|
2111
|
+
# linear swap
|
2112
|
+
#
|
2113
|
+
# {
|
2114
|
+
# "positionId": "1792480725958881280",
|
2115
|
+
# "symbol": "LTC-USDT",
|
2116
|
+
# "currency": "USDT",
|
2117
|
+
# "positionAmt": "0.1",
|
2118
|
+
# "availableAmt": "0.1",
|
2119
|
+
# "positionSide": "LONG",
|
2120
|
+
# "isolated": False,
|
2121
|
+
# "avgPrice": "83.53",
|
2122
|
+
# "initialMargin": "1.3922",
|
2123
|
+
# "margin": "0.3528",
|
2124
|
+
# "leverage": 6,
|
2125
|
+
# "unrealizedProfit": "-1.0393",
|
2126
|
+
# "realisedProfit": "-0.2119",
|
2127
|
+
# "liquidationPrice": 0,
|
2128
|
+
# "pnlRatio": "-0.7465",
|
2129
|
+
# "maxMarginReduction": "0.0000",
|
2130
|
+
# "riskRate": "0.0008",
|
2131
|
+
# "markPrice": "73.14",
|
2132
|
+
# "positionValue": "7.3136",
|
2133
|
+
# "onlyOnePosition": True,
|
2134
|
+
# "updateTime": 1721088016688
|
2135
|
+
# }
|
1872
2136
|
#
|
1873
2137
|
# standard position
|
1874
2138
|
#
|
@@ -1903,13 +2167,13 @@ class bingx(Exchange, ImplicitAPI):
|
|
1903
2167
|
'percentage': None,
|
1904
2168
|
'contracts': self.safe_number(position, 'positionAmt'),
|
1905
2169
|
'contractSize': None,
|
1906
|
-
'markPrice':
|
2170
|
+
'markPrice': self.safe_number(position, 'markPrice'),
|
1907
2171
|
'lastPrice': None,
|
1908
2172
|
'side': self.safe_string_lower(position, 'positionSide'),
|
1909
2173
|
'hedged': None,
|
1910
2174
|
'timestamp': None,
|
1911
2175
|
'datetime': None,
|
1912
|
-
'lastUpdateTimestamp':
|
2176
|
+
'lastUpdateTimestamp': self.safe_integer(position, 'updateTime'),
|
1913
2177
|
'maintenanceMargin': None,
|
1914
2178
|
'maintenanceMarginPercentage': None,
|
1915
2179
|
'collateral': None,
|
@@ -4270,6 +4534,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
4270
4534
|
"""
|
4271
4535
|
retrieves the users liquidated positions
|
4272
4536
|
:see: https://bingx-api.github.io/docs/#/swapV2/trade-api.html#User's%20Force%20Orders
|
4537
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20force%20orders
|
4273
4538
|
:param str [symbol]: unified CCXT market symbol
|
4274
4539
|
:param int [since]: the earliest time in ms to fetch liquidations for
|
4275
4540
|
:param int [limit]: the maximum number of liquidation structures to retrieve
|
@@ -4290,38 +4555,73 @@ class bingx(Exchange, ImplicitAPI):
|
|
4290
4555
|
request['startTime'] = since
|
4291
4556
|
if limit is not None:
|
4292
4557
|
request['limit'] = limit
|
4293
|
-
|
4294
|
-
|
4295
|
-
|
4296
|
-
|
4297
|
-
|
4298
|
-
|
4299
|
-
|
4300
|
-
|
4301
|
-
|
4302
|
-
|
4303
|
-
|
4304
|
-
|
4305
|
-
|
4306
|
-
|
4307
|
-
|
4308
|
-
|
4309
|
-
|
4310
|
-
|
4311
|
-
|
4312
|
-
|
4313
|
-
|
4314
|
-
|
4315
|
-
|
4316
|
-
|
4317
|
-
|
4318
|
-
|
4319
|
-
|
4320
|
-
|
4321
|
-
|
4322
|
-
|
4323
|
-
|
4324
|
-
|
4558
|
+
subType = None
|
4559
|
+
subType, params = self.handle_sub_type_and_params('fetchMyLiquidations', market, params)
|
4560
|
+
response = None
|
4561
|
+
liquidations = None
|
4562
|
+
if subType == 'inverse':
|
4563
|
+
response = await self.cswapV1PrivateGetTradeForceOrders(self.extend(request, params))
|
4564
|
+
#
|
4565
|
+
# {
|
4566
|
+
# "code": 0,
|
4567
|
+
# "msg": "",
|
4568
|
+
# "timestamp": 1721280071678,
|
4569
|
+
# "data": [
|
4570
|
+
# {
|
4571
|
+
# "orderId": "string",
|
4572
|
+
# "symbol": "string",
|
4573
|
+
# "type": "string",
|
4574
|
+
# "side": "string",
|
4575
|
+
# "positionSide": "string",
|
4576
|
+
# "price": "string",
|
4577
|
+
# "quantity": "float64",
|
4578
|
+
# "stopPrice": "string",
|
4579
|
+
# "workingType": "string",
|
4580
|
+
# "status": "string",
|
4581
|
+
# "time": "int64",
|
4582
|
+
# "avgPrice": "string",
|
4583
|
+
# "executedQty": "string",
|
4584
|
+
# "profit": "string",
|
4585
|
+
# "commission": "string",
|
4586
|
+
# "updateTime": "string"
|
4587
|
+
# }
|
4588
|
+
# ]
|
4589
|
+
# }
|
4590
|
+
#
|
4591
|
+
liquidations = self.safe_list(response, 'data', [])
|
4592
|
+
else:
|
4593
|
+
response = await self.swapV2PrivateGetTradeForceOrders(self.extend(request, params))
|
4594
|
+
#
|
4595
|
+
# {
|
4596
|
+
# "code": 0,
|
4597
|
+
# "msg": "",
|
4598
|
+
# "data": {
|
4599
|
+
# "orders": [
|
4600
|
+
# {
|
4601
|
+
# "time": "int64",
|
4602
|
+
# "symbol": "string",
|
4603
|
+
# "side": "string",
|
4604
|
+
# "type": "string",
|
4605
|
+
# "positionSide": "string",
|
4606
|
+
# "cumQuote": "string",
|
4607
|
+
# "status": "string",
|
4608
|
+
# "stopPrice": "string",
|
4609
|
+
# "price": "string",
|
4610
|
+
# "origQty": "string",
|
4611
|
+
# "avgPrice": "string",
|
4612
|
+
# "executedQty": "string",
|
4613
|
+
# "orderId": "int64",
|
4614
|
+
# "profit": "string",
|
4615
|
+
# "commission": "string",
|
4616
|
+
# "workingType": "string",
|
4617
|
+
# "updateTime": "int64"
|
4618
|
+
# },
|
4619
|
+
# ]
|
4620
|
+
# }
|
4621
|
+
# }
|
4622
|
+
#
|
4623
|
+
data = self.safe_dict(response, 'data', {})
|
4624
|
+
liquidations = self.safe_list(data, 'orders', [])
|
4325
4625
|
return self.parse_liquidations(liquidations, market, since, limit)
|
4326
4626
|
|
4327
4627
|
def parse_liquidation(self, liquidation, market: Market = None):
|