ccxt 4.3.62 → 4.3.63
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.
- package/README.md +3 -3
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +2 -1
- package/dist/cjs/src/ace.js +34 -15
- package/dist/cjs/src/base/Exchange.js +8 -1
- package/dist/cjs/src/base/errors.js +8 -1
- package/dist/cjs/src/binance.js +6 -9
- package/dist/cjs/src/bingx.js +466 -151
- package/dist/cjs/src/cryptocom.js +18 -2
- package/dist/cjs/src/mercado.js +5 -1
- package/dist/cjs/src/pro/binance.js +58 -34
- package/dist/cjs/src/pro/bitfinex2.js +6 -3
- package/dist/cjs/src/pro/bitget.js +4 -1
- package/dist/cjs/src/pro/bitvavo.js +1 -1
- package/dist/cjs/src/pro/bybit.js +44 -18
- package/dist/cjs/src/pro/cryptocom.js +7 -1
- package/dist/cjs/src/pro/gate.js +6 -2
- package/dist/cjs/src/pro/htx.js +5 -1
- package/dist/cjs/src/pro/independentreserve.js +5 -3
- package/dist/cjs/src/pro/kraken.js +82 -4
- package/dist/cjs/src/pro/okx.js +3 -3
- package/dist/cjs/src/pro/poloniexfutures.js +5 -1
- package/dist/cjs/src/pro/woofipro.js +1 -1
- package/dist/cjs/src/woo.js +313 -81
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +3 -3
- package/js/src/abstract/cryptocom.d.ts +11 -0
- package/js/src/abstract/woo.d.ts +3 -0
- package/js/src/ace.js +34 -15
- package/js/src/base/Exchange.d.ts +1 -0
- package/js/src/base/Exchange.js +8 -1
- package/js/src/base/errorHierarchy.d.ts +3 -1
- package/js/src/base/errorHierarchy.js +3 -1
- package/js/src/base/errors.d.ts +5 -1
- package/js/src/base/errors.js +8 -2
- package/js/src/binance.js +6 -9
- package/js/src/bingx.d.ts +1 -0
- package/js/src/bingx.js +466 -151
- package/js/src/coinbaseinternational.d.ts +1 -1
- package/js/src/cryptocom.js +18 -2
- package/js/src/mercado.js +5 -1
- package/js/src/pro/binance.d.ts +1 -0
- package/js/src/pro/binance.js +59 -35
- package/js/src/pro/bitfinex2.js +7 -4
- package/js/src/pro/bitget.js +5 -2
- package/js/src/pro/bitvavo.js +1 -1
- package/js/src/pro/bybit.d.ts +1 -0
- package/js/src/pro/bybit.js +44 -18
- package/js/src/pro/cryptocom.js +8 -2
- package/js/src/pro/gate.js +7 -3
- package/js/src/pro/htx.js +6 -2
- package/js/src/pro/independentreserve.js +6 -4
- package/js/src/pro/kraken.d.ts +3 -1
- package/js/src/pro/kraken.js +83 -5
- package/js/src/pro/okx.js +4 -4
- package/js/src/pro/poloniexfutures.js +6 -2
- package/js/src/pro/woofipro.js +1 -1
- package/js/src/woo.d.ts +5 -1
- package/js/src/woo.js +313 -81
- package/js/src/xt.d.ts +3 -3
- package/package.json +1 -1
package/dist/cjs/src/bingx.js
CHANGED
|
@@ -71,6 +71,7 @@ class bingx extends bingx$1 {
|
|
|
71
71
|
'fetchOrder': true,
|
|
72
72
|
'fetchOrderBook': true,
|
|
73
73
|
'fetchOrders': true,
|
|
74
|
+
'fetchPosition': true,
|
|
74
75
|
'fetchPositionHistory': false,
|
|
75
76
|
'fetchPositionMode': true,
|
|
76
77
|
'fetchPositions': true,
|
|
@@ -1776,6 +1777,7 @@ class bingx extends bingx$1 {
|
|
|
1776
1777
|
* @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Query%20Assets
|
|
1777
1778
|
* @see https://bingx-api.github.io/docs/#/swapV2/account-api.html#Get%20Perpetual%20Swap%20Account%20Asset%20Information
|
|
1778
1779
|
* @see https://bingx-api.github.io/docs/#/standard/contract-interface.html#Query%20standard%20contract%20balance
|
|
1780
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Account%20Assets
|
|
1779
1781
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1780
1782
|
* @param {boolean} [params.standard] whether to fetch standard contract balances
|
|
1781
1783
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
@@ -1784,104 +1786,216 @@ class bingx extends bingx$1 {
|
|
|
1784
1786
|
let response = undefined;
|
|
1785
1787
|
let standard = undefined;
|
|
1786
1788
|
[standard, params] = this.handleOptionAndParams(params, 'fetchBalance', 'standard', false);
|
|
1789
|
+
let subType = undefined;
|
|
1790
|
+
[subType, params] = this.handleSubTypeAndParams('fetchBalance', undefined, params);
|
|
1787
1791
|
const [marketType, marketTypeQuery] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
|
|
1788
1792
|
if (standard) {
|
|
1789
1793
|
response = await this.contractV1PrivateGetBalance(marketTypeQuery);
|
|
1794
|
+
//
|
|
1795
|
+
// {
|
|
1796
|
+
// "code": 0,
|
|
1797
|
+
// "timestamp": 1721192833454,
|
|
1798
|
+
// "data": [
|
|
1799
|
+
// {
|
|
1800
|
+
// "asset": "USDT",
|
|
1801
|
+
// "balance": "4.72644300000000000000",
|
|
1802
|
+
// "crossWalletBalance": "4.72644300000000000000",
|
|
1803
|
+
// "crossUnPnl": "0",
|
|
1804
|
+
// "availableBalance": "4.72644300000000000000",
|
|
1805
|
+
// "maxWithdrawAmount": "4.72644300000000000000",
|
|
1806
|
+
// "marginAvailable": false,
|
|
1807
|
+
// "updateTime": 1721192833443
|
|
1808
|
+
// },
|
|
1809
|
+
// ]
|
|
1810
|
+
// }
|
|
1811
|
+
//
|
|
1790
1812
|
}
|
|
1791
1813
|
else if (marketType === 'spot') {
|
|
1792
1814
|
response = await this.spotV1PrivateGetAccountBalance(marketTypeQuery);
|
|
1815
|
+
//
|
|
1816
|
+
// {
|
|
1817
|
+
// "code": 0,
|
|
1818
|
+
// "msg": "",
|
|
1819
|
+
// "debugMsg": "",
|
|
1820
|
+
// "data": {
|
|
1821
|
+
// "balances": [
|
|
1822
|
+
// {
|
|
1823
|
+
// "asset": "USDT",
|
|
1824
|
+
// "free": "45.733046995800514",
|
|
1825
|
+
// "locked": "0"
|
|
1826
|
+
// },
|
|
1827
|
+
// ]
|
|
1828
|
+
// }
|
|
1829
|
+
// }
|
|
1830
|
+
//
|
|
1793
1831
|
}
|
|
1794
1832
|
else {
|
|
1795
|
-
|
|
1833
|
+
if (subType === 'inverse') {
|
|
1834
|
+
response = await this.cswapV1PrivateGetUserBalance(marketTypeQuery);
|
|
1835
|
+
//
|
|
1836
|
+
// {
|
|
1837
|
+
// "code": 0,
|
|
1838
|
+
// "msg": "",
|
|
1839
|
+
// "timestamp": 1721191833813,
|
|
1840
|
+
// "data": [
|
|
1841
|
+
// {
|
|
1842
|
+
// "asset": "SOL",
|
|
1843
|
+
// "balance": "0.35707951",
|
|
1844
|
+
// "equity": "0.35791051",
|
|
1845
|
+
// "unrealizedProfit": "0.00083099",
|
|
1846
|
+
// "availableMargin": "0.35160653",
|
|
1847
|
+
// "usedMargin": "0.00630397",
|
|
1848
|
+
// "freezedMargin": "0",
|
|
1849
|
+
// "shortUid": "12851936"
|
|
1850
|
+
// }
|
|
1851
|
+
// ]
|
|
1852
|
+
// }
|
|
1853
|
+
//
|
|
1854
|
+
}
|
|
1855
|
+
else {
|
|
1856
|
+
response = await this.swapV2PrivateGetUserBalance(marketTypeQuery);
|
|
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
|
+
// }
|
|
1875
|
+
// }
|
|
1876
|
+
//
|
|
1877
|
+
}
|
|
1796
1878
|
}
|
|
1879
|
+
return this.parseBalance(response);
|
|
1880
|
+
}
|
|
1881
|
+
parseBalance(response) {
|
|
1882
|
+
//
|
|
1883
|
+
// standard
|
|
1884
|
+
//
|
|
1885
|
+
// {
|
|
1886
|
+
// "code": 0,
|
|
1887
|
+
// "timestamp": 1721192833454,
|
|
1888
|
+
// "data": [
|
|
1889
|
+
// {
|
|
1890
|
+
// "asset": "USDT",
|
|
1891
|
+
// "balance": "4.72644300000000000000",
|
|
1892
|
+
// "crossWalletBalance": "4.72644300000000000000",
|
|
1893
|
+
// "crossUnPnl": "0",
|
|
1894
|
+
// "availableBalance": "4.72644300000000000000",
|
|
1895
|
+
// "maxWithdrawAmount": "4.72644300000000000000",
|
|
1896
|
+
// "marginAvailable": false,
|
|
1897
|
+
// "updateTime": 1721192833443
|
|
1898
|
+
// },
|
|
1899
|
+
// ]
|
|
1900
|
+
// }
|
|
1797
1901
|
//
|
|
1798
1902
|
// spot
|
|
1799
1903
|
//
|
|
1800
|
-
//
|
|
1801
|
-
//
|
|
1802
|
-
//
|
|
1803
|
-
//
|
|
1804
|
-
//
|
|
1805
|
-
//
|
|
1806
|
-
//
|
|
1807
|
-
//
|
|
1808
|
-
//
|
|
1809
|
-
//
|
|
1810
|
-
//
|
|
1811
|
-
//
|
|
1812
|
-
//
|
|
1813
|
-
//
|
|
1904
|
+
// {
|
|
1905
|
+
// "code": 0,
|
|
1906
|
+
// "msg": "",
|
|
1907
|
+
// "debugMsg": "",
|
|
1908
|
+
// "data": {
|
|
1909
|
+
// "balances": [
|
|
1910
|
+
// {
|
|
1911
|
+
// "asset": "USDT",
|
|
1912
|
+
// "free": "45.733046995800514",
|
|
1913
|
+
// "locked": "0"
|
|
1914
|
+
// },
|
|
1915
|
+
// ]
|
|
1916
|
+
// }
|
|
1917
|
+
// }
|
|
1814
1918
|
//
|
|
1815
|
-
// swap
|
|
1919
|
+
// inverse swap
|
|
1816
1920
|
//
|
|
1817
|
-
//
|
|
1818
|
-
//
|
|
1819
|
-
//
|
|
1820
|
-
//
|
|
1821
|
-
//
|
|
1822
|
-
//
|
|
1823
|
-
//
|
|
1824
|
-
//
|
|
1825
|
-
//
|
|
1826
|
-
//
|
|
1827
|
-
//
|
|
1828
|
-
//
|
|
1829
|
-
//
|
|
1830
|
-
//
|
|
1831
|
-
//
|
|
1832
|
-
//
|
|
1833
|
-
//
|
|
1834
|
-
//
|
|
1835
|
-
//
|
|
1836
|
-
//
|
|
1837
|
-
//
|
|
1838
|
-
//
|
|
1839
|
-
//
|
|
1840
|
-
//
|
|
1841
|
-
//
|
|
1842
|
-
//
|
|
1843
|
-
//
|
|
1844
|
-
//
|
|
1845
|
-
//
|
|
1846
|
-
//
|
|
1847
|
-
//
|
|
1848
|
-
//
|
|
1849
|
-
//
|
|
1850
|
-
//
|
|
1851
|
-
//
|
|
1852
|
-
//
|
|
1853
|
-
//
|
|
1854
|
-
// "maxWithdrawAmount":"0",
|
|
1855
|
-
// "marginAvailable":false,
|
|
1856
|
-
// "updateTime":"1691148990902"
|
|
1857
|
-
// },
|
|
1858
|
-
// ]
|
|
1921
|
+
// {
|
|
1922
|
+
// "code": 0,
|
|
1923
|
+
// "msg": "",
|
|
1924
|
+
// "timestamp": 1721191833813,
|
|
1925
|
+
// "data": [
|
|
1926
|
+
// {
|
|
1927
|
+
// "asset": "SOL",
|
|
1928
|
+
// "balance": "0.35707951",
|
|
1929
|
+
// "equity": "0.35791051",
|
|
1930
|
+
// "unrealizedProfit": "0.00083099",
|
|
1931
|
+
// "availableMargin": "0.35160653",
|
|
1932
|
+
// "usedMargin": "0.00630397",
|
|
1933
|
+
// "freezedMargin": "0",
|
|
1934
|
+
// "shortUid": "12851936"
|
|
1935
|
+
// }
|
|
1936
|
+
// ]
|
|
1937
|
+
// }
|
|
1938
|
+
//
|
|
1939
|
+
// linear swap
|
|
1940
|
+
//
|
|
1941
|
+
// {
|
|
1942
|
+
// "code": 0,
|
|
1943
|
+
// "msg": "",
|
|
1944
|
+
// "data": {
|
|
1945
|
+
// "balance": {
|
|
1946
|
+
// "userId": "1177064765068660742",
|
|
1947
|
+
// "asset": "USDT",
|
|
1948
|
+
// "balance": "51.5198",
|
|
1949
|
+
// "equity": "50.5349",
|
|
1950
|
+
// "unrealizedProfit": "-0.9849",
|
|
1951
|
+
// "realisedProfit": "-0.2134",
|
|
1952
|
+
// "availableMargin": "49.1428",
|
|
1953
|
+
// "usedMargin": "1.3922",
|
|
1954
|
+
// "freezedMargin": "0.0000",
|
|
1955
|
+
// "shortUid": "12851936"
|
|
1956
|
+
// }
|
|
1957
|
+
// }
|
|
1859
1958
|
// }
|
|
1860
1959
|
//
|
|
1861
|
-
return this.parseBalance(response);
|
|
1862
|
-
}
|
|
1863
|
-
parseBalance(response) {
|
|
1864
|
-
const data = this.safeValue(response, 'data');
|
|
1865
|
-
const balances = this.safeValue2(data, 'balance', 'balances', data);
|
|
1866
1960
|
const result = { 'info': response };
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1961
|
+
const standardAndInverseBalances = this.safeList(response, 'data');
|
|
1962
|
+
const firstStandardOrInverse = this.safeDict(standardAndInverseBalances, 0);
|
|
1963
|
+
const isStandardOrInverse = firstStandardOrInverse !== undefined;
|
|
1964
|
+
const spotData = this.safeDict(response, 'data', {});
|
|
1965
|
+
const spotBalances = this.safeList(spotData, 'balances');
|
|
1966
|
+
const firstSpot = this.safeDict(spotBalances, 0);
|
|
1967
|
+
const isSpot = firstSpot !== undefined;
|
|
1968
|
+
if (isStandardOrInverse) {
|
|
1969
|
+
for (let i = 0; i < standardAndInverseBalances.length; i++) {
|
|
1970
|
+
const balance = standardAndInverseBalances[i];
|
|
1870
1971
|
const currencyId = this.safeString(balance, 'asset');
|
|
1871
1972
|
const code = this.safeCurrencyCode(currencyId);
|
|
1872
1973
|
const account = this.account();
|
|
1873
|
-
account['free'] = this.safeString2(balance, '
|
|
1974
|
+
account['free'] = this.safeString2(balance, 'availableMargin', 'availableBalance');
|
|
1975
|
+
account['used'] = this.safeString(balance, 'usedMargin');
|
|
1976
|
+
account['total'] = this.safeString(balance, 'maxWithdrawAmount');
|
|
1977
|
+
result[code] = account;
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
else if (isSpot) {
|
|
1981
|
+
for (let i = 0; i < spotBalances.length; i++) {
|
|
1982
|
+
const balance = spotBalances[i];
|
|
1983
|
+
const currencyId = this.safeString(balance, 'asset');
|
|
1984
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
1985
|
+
const account = this.account();
|
|
1986
|
+
account['free'] = this.safeString(balance, 'free');
|
|
1874
1987
|
account['used'] = this.safeString(balance, 'locked');
|
|
1875
|
-
account['total'] = this.safeString(balance, 'balance');
|
|
1876
1988
|
result[code] = account;
|
|
1877
1989
|
}
|
|
1878
1990
|
}
|
|
1879
1991
|
else {
|
|
1880
|
-
const
|
|
1992
|
+
const linearSwapData = this.safeDict(response, 'data', {});
|
|
1993
|
+
const linearSwapBalance = this.safeDict(linearSwapData, 'balance');
|
|
1994
|
+
const currencyId = this.safeString(linearSwapBalance, 'asset');
|
|
1881
1995
|
const code = this.safeCurrencyCode(currencyId);
|
|
1882
1996
|
const account = this.account();
|
|
1883
|
-
account['free'] = this.safeString(
|
|
1884
|
-
account['used'] = this.safeString(
|
|
1997
|
+
account['free'] = this.safeString(linearSwapBalance, 'availableMargin');
|
|
1998
|
+
account['used'] = this.safeString(linearSwapBalance, 'usedMargin');
|
|
1885
1999
|
result[code] = account;
|
|
1886
2000
|
}
|
|
1887
2001
|
return this.safeBalance(result);
|
|
@@ -1891,12 +2005,13 @@ class bingx extends bingx$1 {
|
|
|
1891
2005
|
* @method
|
|
1892
2006
|
* @name bingx#fetchPositions
|
|
1893
2007
|
* @description fetch all open positions
|
|
1894
|
-
* @see https://bingx-api.github.io/docs/#/swapV2/account-api.html#
|
|
1895
|
-
* @see https://bingx-api.github.io/docs/#/standard/contract-interface.html#
|
|
2008
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query%20position%20data
|
|
2009
|
+
* @see https://bingx-api.github.io/docs/#/en-us/standard/contract-interface.html#position
|
|
2010
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20warehouse
|
|
1896
2011
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
1897
2012
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1898
2013
|
* @param {boolean} [params.standard] whether to fetch standard contract positions
|
|
1899
|
-
* @returns {object[]} a list of [position
|
|
2014
|
+
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
1900
2015
|
*/
|
|
1901
2016
|
await this.loadMarkets();
|
|
1902
2017
|
symbols = this.marketSymbols(symbols);
|
|
@@ -1907,55 +2022,217 @@ class bingx extends bingx$1 {
|
|
|
1907
2022
|
response = await this.contractV1PrivateGetAllPosition(params);
|
|
1908
2023
|
}
|
|
1909
2024
|
else {
|
|
1910
|
-
|
|
2025
|
+
let market = undefined;
|
|
2026
|
+
if (symbols !== undefined) {
|
|
2027
|
+
symbols = this.marketSymbols(symbols);
|
|
2028
|
+
const firstSymbol = this.safeString(symbols, 0);
|
|
2029
|
+
if (firstSymbol !== undefined) {
|
|
2030
|
+
market = this.market(firstSymbol);
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
let subType = undefined;
|
|
2034
|
+
[subType, params] = this.handleSubTypeAndParams('fetchPositions', market, params);
|
|
2035
|
+
if (subType === 'inverse') {
|
|
2036
|
+
response = await this.cswapV1PrivateGetUserPositions(params);
|
|
2037
|
+
//
|
|
2038
|
+
// {
|
|
2039
|
+
// "code": 0,
|
|
2040
|
+
// "msg": "",
|
|
2041
|
+
// "timestamp": 0,
|
|
2042
|
+
// "data": [
|
|
2043
|
+
// {
|
|
2044
|
+
// "symbol": "SOL-USD",
|
|
2045
|
+
// "positionId": "1813080351385337856",
|
|
2046
|
+
// "positionSide": "LONG",
|
|
2047
|
+
// "isolated": false,
|
|
2048
|
+
// "positionAmt": "1",
|
|
2049
|
+
// "availableAmt": "1",
|
|
2050
|
+
// "unrealizedProfit": "-0.00009074",
|
|
2051
|
+
// "initialMargin": "0.00630398",
|
|
2052
|
+
// "liquidationPrice": 23.968303426677032,
|
|
2053
|
+
// "avgPrice": "158.63",
|
|
2054
|
+
// "leverage": 10,
|
|
2055
|
+
// "markPrice": "158.402",
|
|
2056
|
+
// "riskRate": "0.00123783",
|
|
2057
|
+
// "maxMarginReduction": "0",
|
|
2058
|
+
// "updateTime": 1721107015848
|
|
2059
|
+
// }
|
|
2060
|
+
// ]
|
|
2061
|
+
// }
|
|
2062
|
+
//
|
|
2063
|
+
}
|
|
2064
|
+
else {
|
|
2065
|
+
response = await this.swapV2PrivateGetUserPositions(params);
|
|
2066
|
+
//
|
|
2067
|
+
// {
|
|
2068
|
+
// "code": 0,
|
|
2069
|
+
// "msg": "",
|
|
2070
|
+
// "data": [
|
|
2071
|
+
// {
|
|
2072
|
+
// "positionId": "1792480725958881280",
|
|
2073
|
+
// "symbol": "LTC-USDT",
|
|
2074
|
+
// "currency": "USDT",
|
|
2075
|
+
// "positionAmt": "0.1",
|
|
2076
|
+
// "availableAmt": "0.1",
|
|
2077
|
+
// "positionSide": "LONG",
|
|
2078
|
+
// "isolated": false,
|
|
2079
|
+
// "avgPrice": "83.53",
|
|
2080
|
+
// "initialMargin": "1.3922",
|
|
2081
|
+
// "margin": "0.3528",
|
|
2082
|
+
// "leverage": 6,
|
|
2083
|
+
// "unrealizedProfit": "-1.0393",
|
|
2084
|
+
// "realisedProfit": "-0.2119",
|
|
2085
|
+
// "liquidationPrice": 0,
|
|
2086
|
+
// "pnlRatio": "-0.7465",
|
|
2087
|
+
// "maxMarginReduction": "0.0000",
|
|
2088
|
+
// "riskRate": "0.0008",
|
|
2089
|
+
// "markPrice": "73.14",
|
|
2090
|
+
// "positionValue": "7.3136",
|
|
2091
|
+
// "onlyOnePosition": true,
|
|
2092
|
+
// "updateTime": 1721088016688
|
|
2093
|
+
// }
|
|
2094
|
+
// ]
|
|
2095
|
+
// }
|
|
2096
|
+
//
|
|
2097
|
+
}
|
|
1911
2098
|
}
|
|
1912
|
-
//
|
|
1913
|
-
// {
|
|
1914
|
-
// "code": 0,
|
|
1915
|
-
// "msg": "",
|
|
1916
|
-
// "data": [
|
|
1917
|
-
// {
|
|
1918
|
-
// "symbol": "BTC-USDT",
|
|
1919
|
-
// "positionId": "12345678",
|
|
1920
|
-
// "positionSide": "LONG",
|
|
1921
|
-
// "isolated": true,
|
|
1922
|
-
// "positionAmt": "123.33",
|
|
1923
|
-
// "availableAmt": "128.99",
|
|
1924
|
-
// "unrealizedProfit": "1.22",
|
|
1925
|
-
// "realisedProfit": "8.1",
|
|
1926
|
-
// "initialMargin": "123.33",
|
|
1927
|
-
// "avgPrice": "2.2",
|
|
1928
|
-
// "leverage": 10,
|
|
1929
|
-
// }
|
|
1930
|
-
// ]
|
|
1931
|
-
// }
|
|
1932
|
-
//
|
|
1933
2099
|
const positions = this.safeList(response, 'data', []);
|
|
1934
2100
|
return this.parsePositions(positions, symbols);
|
|
1935
2101
|
}
|
|
2102
|
+
async fetchPosition(symbol, params = {}) {
|
|
2103
|
+
/**
|
|
2104
|
+
* @method
|
|
2105
|
+
* @name bingx#fetchPosition
|
|
2106
|
+
* @description fetch data on a single open contract trade position
|
|
2107
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query%20position%20data
|
|
2108
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20warehouse
|
|
2109
|
+
* @param {string} symbol unified market symbol of the market the position is held in
|
|
2110
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2111
|
+
* @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
2112
|
+
*/
|
|
2113
|
+
await this.loadMarkets();
|
|
2114
|
+
const market = this.market(symbol);
|
|
2115
|
+
if (!market['swap']) {
|
|
2116
|
+
throw new errors.BadRequest(this.id + ' fetchPosition() supports swap markets only');
|
|
2117
|
+
}
|
|
2118
|
+
const request = {
|
|
2119
|
+
'symbol': market['id'],
|
|
2120
|
+
};
|
|
2121
|
+
let response = undefined;
|
|
2122
|
+
if (market['inverse']) {
|
|
2123
|
+
response = await this.cswapV1PrivateGetUserPositions(this.extend(request, params));
|
|
2124
|
+
//
|
|
2125
|
+
// {
|
|
2126
|
+
// "code": 0,
|
|
2127
|
+
// "msg": "",
|
|
2128
|
+
// "timestamp": 0,
|
|
2129
|
+
// "data": [
|
|
2130
|
+
// {
|
|
2131
|
+
// "symbol": "SOL-USD",
|
|
2132
|
+
// "positionId": "1813080351385337856",
|
|
2133
|
+
// "positionSide": "LONG",
|
|
2134
|
+
// "isolated": false,
|
|
2135
|
+
// "positionAmt": "1",
|
|
2136
|
+
// "availableAmt": "1",
|
|
2137
|
+
// "unrealizedProfit": "-0.00009074",
|
|
2138
|
+
// "initialMargin": "0.00630398",
|
|
2139
|
+
// "liquidationPrice": 23.968303426677032,
|
|
2140
|
+
// "avgPrice": "158.63",
|
|
2141
|
+
// "leverage": 10,
|
|
2142
|
+
// "markPrice": "158.402",
|
|
2143
|
+
// "riskRate": "0.00123783",
|
|
2144
|
+
// "maxMarginReduction": "0",
|
|
2145
|
+
// "updateTime": 1721107015848
|
|
2146
|
+
// }
|
|
2147
|
+
// ]
|
|
2148
|
+
// }
|
|
2149
|
+
//
|
|
2150
|
+
}
|
|
2151
|
+
else {
|
|
2152
|
+
response = await this.swapV2PrivateGetUserPositions(this.extend(request, params));
|
|
2153
|
+
//
|
|
2154
|
+
// {
|
|
2155
|
+
// "code": 0,
|
|
2156
|
+
// "msg": "",
|
|
2157
|
+
// "data": [
|
|
2158
|
+
// {
|
|
2159
|
+
// "positionId": "1792480725958881280",
|
|
2160
|
+
// "symbol": "LTC-USDT",
|
|
2161
|
+
// "currency": "USDT",
|
|
2162
|
+
// "positionAmt": "0.1",
|
|
2163
|
+
// "availableAmt": "0.1",
|
|
2164
|
+
// "positionSide": "LONG",
|
|
2165
|
+
// "isolated": false,
|
|
2166
|
+
// "avgPrice": "83.53",
|
|
2167
|
+
// "initialMargin": "1.3922",
|
|
2168
|
+
// "margin": "0.3528",
|
|
2169
|
+
// "leverage": 6,
|
|
2170
|
+
// "unrealizedProfit": "-1.0393",
|
|
2171
|
+
// "realisedProfit": "-0.2119",
|
|
2172
|
+
// "liquidationPrice": 0,
|
|
2173
|
+
// "pnlRatio": "-0.7465",
|
|
2174
|
+
// "maxMarginReduction": "0.0000",
|
|
2175
|
+
// "riskRate": "0.0008",
|
|
2176
|
+
// "markPrice": "73.14",
|
|
2177
|
+
// "positionValue": "7.3136",
|
|
2178
|
+
// "onlyOnePosition": true,
|
|
2179
|
+
// "updateTime": 1721088016688
|
|
2180
|
+
// }
|
|
2181
|
+
// ]
|
|
2182
|
+
// }
|
|
2183
|
+
//
|
|
2184
|
+
}
|
|
2185
|
+
const data = this.safeList(response, 'data', []);
|
|
2186
|
+
const first = this.safeDict(data, 0, {});
|
|
2187
|
+
return this.parsePosition(first, market);
|
|
2188
|
+
}
|
|
1936
2189
|
parsePosition(position, market = undefined) {
|
|
1937
2190
|
//
|
|
1938
|
-
//
|
|
1939
|
-
//
|
|
1940
|
-
//
|
|
1941
|
-
//
|
|
1942
|
-
//
|
|
1943
|
-
//
|
|
1944
|
-
//
|
|
1945
|
-
//
|
|
1946
|
-
//
|
|
1947
|
-
//
|
|
1948
|
-
//
|
|
1949
|
-
//
|
|
1950
|
-
//
|
|
1951
|
-
//
|
|
1952
|
-
//
|
|
1953
|
-
//
|
|
1954
|
-
//
|
|
1955
|
-
//
|
|
1956
|
-
//
|
|
1957
|
-
//
|
|
1958
|
-
//
|
|
2191
|
+
// inverse swap
|
|
2192
|
+
//
|
|
2193
|
+
// {
|
|
2194
|
+
// "symbol": "SOL-USD",
|
|
2195
|
+
// "positionId": "1813080351385337856",
|
|
2196
|
+
// "positionSide": "LONG",
|
|
2197
|
+
// "isolated": false,
|
|
2198
|
+
// "positionAmt": "1",
|
|
2199
|
+
// "availableAmt": "1",
|
|
2200
|
+
// "unrealizedProfit": "-0.00009074",
|
|
2201
|
+
// "initialMargin": "0.00630398",
|
|
2202
|
+
// "liquidationPrice": 23.968303426677032,
|
|
2203
|
+
// "avgPrice": "158.63",
|
|
2204
|
+
// "leverage": 10,
|
|
2205
|
+
// "markPrice": "158.402",
|
|
2206
|
+
// "riskRate": "0.00123783",
|
|
2207
|
+
// "maxMarginReduction": "0",
|
|
2208
|
+
// "updateTime": 1721107015848
|
|
2209
|
+
// }
|
|
2210
|
+
//
|
|
2211
|
+
// linear swap
|
|
2212
|
+
//
|
|
2213
|
+
// {
|
|
2214
|
+
// "positionId": "1792480725958881280",
|
|
2215
|
+
// "symbol": "LTC-USDT",
|
|
2216
|
+
// "currency": "USDT",
|
|
2217
|
+
// "positionAmt": "0.1",
|
|
2218
|
+
// "availableAmt": "0.1",
|
|
2219
|
+
// "positionSide": "LONG",
|
|
2220
|
+
// "isolated": false,
|
|
2221
|
+
// "avgPrice": "83.53",
|
|
2222
|
+
// "initialMargin": "1.3922",
|
|
2223
|
+
// "margin": "0.3528",
|
|
2224
|
+
// "leverage": 6,
|
|
2225
|
+
// "unrealizedProfit": "-1.0393",
|
|
2226
|
+
// "realisedProfit": "-0.2119",
|
|
2227
|
+
// "liquidationPrice": 0,
|
|
2228
|
+
// "pnlRatio": "-0.7465",
|
|
2229
|
+
// "maxMarginReduction": "0.0000",
|
|
2230
|
+
// "riskRate": "0.0008",
|
|
2231
|
+
// "markPrice": "73.14",
|
|
2232
|
+
// "positionValue": "7.3136",
|
|
2233
|
+
// "onlyOnePosition": true,
|
|
2234
|
+
// "updateTime": 1721088016688
|
|
2235
|
+
// }
|
|
1959
2236
|
//
|
|
1960
2237
|
// standard position
|
|
1961
2238
|
//
|
|
@@ -1991,13 +2268,13 @@ class bingx extends bingx$1 {
|
|
|
1991
2268
|
'percentage': undefined,
|
|
1992
2269
|
'contracts': this.safeNumber(position, 'positionAmt'),
|
|
1993
2270
|
'contractSize': undefined,
|
|
1994
|
-
'markPrice':
|
|
2271
|
+
'markPrice': this.safeNumber(position, 'markPrice'),
|
|
1995
2272
|
'lastPrice': undefined,
|
|
1996
2273
|
'side': this.safeStringLower(position, 'positionSide'),
|
|
1997
2274
|
'hedged': undefined,
|
|
1998
2275
|
'timestamp': undefined,
|
|
1999
2276
|
'datetime': undefined,
|
|
2000
|
-
'lastUpdateTimestamp':
|
|
2277
|
+
'lastUpdateTimestamp': this.safeInteger(position, 'updateTime'),
|
|
2001
2278
|
'maintenanceMargin': undefined,
|
|
2002
2279
|
'maintenanceMarginPercentage': undefined,
|
|
2003
2280
|
'collateral': undefined,
|
|
@@ -4565,6 +4842,7 @@ class bingx extends bingx$1 {
|
|
|
4565
4842
|
* @name bingx#fetchMyLiquidations
|
|
4566
4843
|
* @description retrieves the users liquidated positions
|
|
4567
4844
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#User's%20Force%20Orders
|
|
4845
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20force%20orders
|
|
4568
4846
|
* @param {string} [symbol] unified CCXT market symbol
|
|
4569
4847
|
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
4570
4848
|
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
@@ -4588,38 +4866,75 @@ class bingx extends bingx$1 {
|
|
|
4588
4866
|
if (limit !== undefined) {
|
|
4589
4867
|
request['limit'] = limit;
|
|
4590
4868
|
}
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4869
|
+
let subType = undefined;
|
|
4870
|
+
[subType, params] = this.handleSubTypeAndParams('fetchMyLiquidations', market, params);
|
|
4871
|
+
let response = undefined;
|
|
4872
|
+
let liquidations = undefined;
|
|
4873
|
+
if (subType === 'inverse') {
|
|
4874
|
+
response = await this.cswapV1PrivateGetTradeForceOrders(this.extend(request, params));
|
|
4875
|
+
//
|
|
4876
|
+
// {
|
|
4877
|
+
// "code": 0,
|
|
4878
|
+
// "msg": "",
|
|
4879
|
+
// "timestamp": 1721280071678,
|
|
4880
|
+
// "data": [
|
|
4881
|
+
// {
|
|
4882
|
+
// "orderId": "string",
|
|
4883
|
+
// "symbol": "string",
|
|
4884
|
+
// "type": "string",
|
|
4885
|
+
// "side": "string",
|
|
4886
|
+
// "positionSide": "string",
|
|
4887
|
+
// "price": "string",
|
|
4888
|
+
// "quantity": "float64",
|
|
4889
|
+
// "stopPrice": "string",
|
|
4890
|
+
// "workingType": "string",
|
|
4891
|
+
// "status": "string",
|
|
4892
|
+
// "time": "int64",
|
|
4893
|
+
// "avgPrice": "string",
|
|
4894
|
+
// "executedQty": "string",
|
|
4895
|
+
// "profit": "string",
|
|
4896
|
+
// "commission": "string",
|
|
4897
|
+
// "updateTime": "string"
|
|
4898
|
+
// }
|
|
4899
|
+
// ]
|
|
4900
|
+
// }
|
|
4901
|
+
//
|
|
4902
|
+
liquidations = this.safeList(response, 'data', []);
|
|
4903
|
+
}
|
|
4904
|
+
else {
|
|
4905
|
+
response = await this.swapV2PrivateGetTradeForceOrders(this.extend(request, params));
|
|
4906
|
+
//
|
|
4907
|
+
// {
|
|
4908
|
+
// "code": 0,
|
|
4909
|
+
// "msg": "",
|
|
4910
|
+
// "data": {
|
|
4911
|
+
// "orders": [
|
|
4912
|
+
// {
|
|
4913
|
+
// "time": "int64",
|
|
4914
|
+
// "symbol": "string",
|
|
4915
|
+
// "side": "string",
|
|
4916
|
+
// "type": "string",
|
|
4917
|
+
// "positionSide": "string",
|
|
4918
|
+
// "cumQuote": "string",
|
|
4919
|
+
// "status": "string",
|
|
4920
|
+
// "stopPrice": "string",
|
|
4921
|
+
// "price": "string",
|
|
4922
|
+
// "origQty": "string",
|
|
4923
|
+
// "avgPrice": "string",
|
|
4924
|
+
// "executedQty": "string",
|
|
4925
|
+
// "orderId": "int64",
|
|
4926
|
+
// "profit": "string",
|
|
4927
|
+
// "commission": "string",
|
|
4928
|
+
// "workingType": "string",
|
|
4929
|
+
// "updateTime": "int64"
|
|
4930
|
+
// },
|
|
4931
|
+
// ]
|
|
4932
|
+
// }
|
|
4933
|
+
// }
|
|
4934
|
+
//
|
|
4935
|
+
const data = this.safeDict(response, 'data', {});
|
|
4936
|
+
liquidations = this.safeList(data, 'orders', []);
|
|
4937
|
+
}
|
|
4623
4938
|
return this.parseLiquidations(liquidations, market, since, limit);
|
|
4624
4939
|
}
|
|
4625
4940
|
parseLiquidation(liquidation, market = undefined) {
|