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