ccxt 4.3.62 → 4.3.64
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/alpaca.js +1 -0
- package/dist/cjs/src/base/Exchange.js +11 -4
- package/dist/cjs/src/base/errors.js +8 -1
- package/dist/cjs/src/binance.js +6 -9
- package/dist/cjs/src/bingx.js +554 -151
- package/dist/cjs/src/bitfinex.js +1 -1
- package/dist/cjs/src/bitfinex2.js +1 -1
- package/dist/cjs/src/cryptocom.js +18 -2
- package/dist/cjs/src/independentreserve.js +107 -0
- package/dist/cjs/src/kucoin.js +2 -0
- 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/bitmart.js +3 -3
- 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 +7 -3
- package/dist/cjs/src/pro/gemini.js +4 -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/onetrading.js +3 -2
- package/dist/cjs/src/pro/poloniexfutures.js +5 -1
- package/dist/cjs/src/pro/vertex.js +3 -2
- package/dist/cjs/src/pro/woo.js +2 -1
- package/dist/cjs/src/pro/woofipro.js +3 -2
- package/dist/cjs/src/woo.js +344 -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/kucoin.d.ts +1 -0
- package/js/src/abstract/kucoinfutures.d.ts +1 -0
- package/js/src/abstract/woo.d.ts +3 -0
- package/js/src/ace.js +34 -15
- package/js/src/alpaca.js +1 -0
- package/js/src/base/Exchange.d.ts +1 -0
- package/js/src/base/Exchange.js +11 -4
- 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 +4 -1
- package/js/src/bingx.js +554 -151
- package/js/src/bitfinex.js +1 -1
- package/js/src/bitfinex2.js +1 -1
- package/js/src/coinbaseinternational.d.ts +1 -1
- package/js/src/cryptocom.js +18 -2
- package/js/src/independentreserve.d.ts +3 -1
- package/js/src/independentreserve.js +106 -0
- package/js/src/kucoin.js +2 -0
- 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/bitmart.js +3 -3
- 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 +8 -4
- package/js/src/pro/gemini.js +4 -2
- 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/onetrading.js +3 -2
- package/js/src/pro/poloniexfutures.js +6 -2
- package/js/src/pro/vertex.js +3 -2
- package/js/src/pro/woo.js +2 -1
- package/js/src/pro/woofipro.js +3 -2
- package/js/src/whitebit.d.ts +1 -1
- package/js/src/woo.d.ts +6 -2
- package/js/src/woo.js +344 -81
- package/js/src/xt.d.ts +3 -3
- package/js/src/zonda.d.ts +1 -1
- 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,
|
|
@@ -79,6 +80,7 @@ class bingx extends bingx$1 {
|
|
|
79
80
|
'fetchTickers': true,
|
|
80
81
|
'fetchTime': true,
|
|
81
82
|
'fetchTrades': true,
|
|
83
|
+
'fetchTradingFee': true,
|
|
82
84
|
'fetchTransfers': true,
|
|
83
85
|
'fetchWithdrawals': true,
|
|
84
86
|
'reduceMargin': true,
|
|
@@ -1776,6 +1778,7 @@ class bingx extends bingx$1 {
|
|
|
1776
1778
|
* @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Query%20Assets
|
|
1777
1779
|
* @see https://bingx-api.github.io/docs/#/swapV2/account-api.html#Get%20Perpetual%20Swap%20Account%20Asset%20Information
|
|
1778
1780
|
* @see https://bingx-api.github.io/docs/#/standard/contract-interface.html#Query%20standard%20contract%20balance
|
|
1781
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Account%20Assets
|
|
1779
1782
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1780
1783
|
* @param {boolean} [params.standard] whether to fetch standard contract balances
|
|
1781
1784
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
@@ -1784,104 +1787,216 @@ class bingx extends bingx$1 {
|
|
|
1784
1787
|
let response = undefined;
|
|
1785
1788
|
let standard = undefined;
|
|
1786
1789
|
[standard, params] = this.handleOptionAndParams(params, 'fetchBalance', 'standard', false);
|
|
1790
|
+
let subType = undefined;
|
|
1791
|
+
[subType, params] = this.handleSubTypeAndParams('fetchBalance', undefined, params);
|
|
1787
1792
|
const [marketType, marketTypeQuery] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
|
|
1788
1793
|
if (standard) {
|
|
1789
1794
|
response = await this.contractV1PrivateGetBalance(marketTypeQuery);
|
|
1795
|
+
//
|
|
1796
|
+
// {
|
|
1797
|
+
// "code": 0,
|
|
1798
|
+
// "timestamp": 1721192833454,
|
|
1799
|
+
// "data": [
|
|
1800
|
+
// {
|
|
1801
|
+
// "asset": "USDT",
|
|
1802
|
+
// "balance": "4.72644300000000000000",
|
|
1803
|
+
// "crossWalletBalance": "4.72644300000000000000",
|
|
1804
|
+
// "crossUnPnl": "0",
|
|
1805
|
+
// "availableBalance": "4.72644300000000000000",
|
|
1806
|
+
// "maxWithdrawAmount": "4.72644300000000000000",
|
|
1807
|
+
// "marginAvailable": false,
|
|
1808
|
+
// "updateTime": 1721192833443
|
|
1809
|
+
// },
|
|
1810
|
+
// ]
|
|
1811
|
+
// }
|
|
1812
|
+
//
|
|
1790
1813
|
}
|
|
1791
1814
|
else if (marketType === 'spot') {
|
|
1792
1815
|
response = await this.spotV1PrivateGetAccountBalance(marketTypeQuery);
|
|
1816
|
+
//
|
|
1817
|
+
// {
|
|
1818
|
+
// "code": 0,
|
|
1819
|
+
// "msg": "",
|
|
1820
|
+
// "debugMsg": "",
|
|
1821
|
+
// "data": {
|
|
1822
|
+
// "balances": [
|
|
1823
|
+
// {
|
|
1824
|
+
// "asset": "USDT",
|
|
1825
|
+
// "free": "45.733046995800514",
|
|
1826
|
+
// "locked": "0"
|
|
1827
|
+
// },
|
|
1828
|
+
// ]
|
|
1829
|
+
// }
|
|
1830
|
+
// }
|
|
1831
|
+
//
|
|
1793
1832
|
}
|
|
1794
1833
|
else {
|
|
1795
|
-
|
|
1834
|
+
if (subType === 'inverse') {
|
|
1835
|
+
response = await this.cswapV1PrivateGetUserBalance(marketTypeQuery);
|
|
1836
|
+
//
|
|
1837
|
+
// {
|
|
1838
|
+
// "code": 0,
|
|
1839
|
+
// "msg": "",
|
|
1840
|
+
// "timestamp": 1721191833813,
|
|
1841
|
+
// "data": [
|
|
1842
|
+
// {
|
|
1843
|
+
// "asset": "SOL",
|
|
1844
|
+
// "balance": "0.35707951",
|
|
1845
|
+
// "equity": "0.35791051",
|
|
1846
|
+
// "unrealizedProfit": "0.00083099",
|
|
1847
|
+
// "availableMargin": "0.35160653",
|
|
1848
|
+
// "usedMargin": "0.00630397",
|
|
1849
|
+
// "freezedMargin": "0",
|
|
1850
|
+
// "shortUid": "12851936"
|
|
1851
|
+
// }
|
|
1852
|
+
// ]
|
|
1853
|
+
// }
|
|
1854
|
+
//
|
|
1855
|
+
}
|
|
1856
|
+
else {
|
|
1857
|
+
response = await this.swapV2PrivateGetUserBalance(marketTypeQuery);
|
|
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
|
+
// }
|
|
1876
|
+
// }
|
|
1877
|
+
//
|
|
1878
|
+
}
|
|
1796
1879
|
}
|
|
1880
|
+
return this.parseBalance(response);
|
|
1881
|
+
}
|
|
1882
|
+
parseBalance(response) {
|
|
1883
|
+
//
|
|
1884
|
+
// standard
|
|
1885
|
+
//
|
|
1886
|
+
// {
|
|
1887
|
+
// "code": 0,
|
|
1888
|
+
// "timestamp": 1721192833454,
|
|
1889
|
+
// "data": [
|
|
1890
|
+
// {
|
|
1891
|
+
// "asset": "USDT",
|
|
1892
|
+
// "balance": "4.72644300000000000000",
|
|
1893
|
+
// "crossWalletBalance": "4.72644300000000000000",
|
|
1894
|
+
// "crossUnPnl": "0",
|
|
1895
|
+
// "availableBalance": "4.72644300000000000000",
|
|
1896
|
+
// "maxWithdrawAmount": "4.72644300000000000000",
|
|
1897
|
+
// "marginAvailable": false,
|
|
1898
|
+
// "updateTime": 1721192833443
|
|
1899
|
+
// },
|
|
1900
|
+
// ]
|
|
1901
|
+
// }
|
|
1797
1902
|
//
|
|
1798
1903
|
// spot
|
|
1799
1904
|
//
|
|
1800
|
-
//
|
|
1801
|
-
//
|
|
1802
|
-
//
|
|
1803
|
-
//
|
|
1804
|
-
//
|
|
1805
|
-
//
|
|
1806
|
-
//
|
|
1807
|
-
//
|
|
1808
|
-
//
|
|
1809
|
-
//
|
|
1810
|
-
//
|
|
1811
|
-
//
|
|
1812
|
-
//
|
|
1813
|
-
//
|
|
1905
|
+
// {
|
|
1906
|
+
// "code": 0,
|
|
1907
|
+
// "msg": "",
|
|
1908
|
+
// "debugMsg": "",
|
|
1909
|
+
// "data": {
|
|
1910
|
+
// "balances": [
|
|
1911
|
+
// {
|
|
1912
|
+
// "asset": "USDT",
|
|
1913
|
+
// "free": "45.733046995800514",
|
|
1914
|
+
// "locked": "0"
|
|
1915
|
+
// },
|
|
1916
|
+
// ]
|
|
1917
|
+
// }
|
|
1918
|
+
// }
|
|
1814
1919
|
//
|
|
1815
|
-
// swap
|
|
1920
|
+
// inverse swap
|
|
1816
1921
|
//
|
|
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
|
-
// ]
|
|
1922
|
+
// {
|
|
1923
|
+
// "code": 0,
|
|
1924
|
+
// "msg": "",
|
|
1925
|
+
// "timestamp": 1721191833813,
|
|
1926
|
+
// "data": [
|
|
1927
|
+
// {
|
|
1928
|
+
// "asset": "SOL",
|
|
1929
|
+
// "balance": "0.35707951",
|
|
1930
|
+
// "equity": "0.35791051",
|
|
1931
|
+
// "unrealizedProfit": "0.00083099",
|
|
1932
|
+
// "availableMargin": "0.35160653",
|
|
1933
|
+
// "usedMargin": "0.00630397",
|
|
1934
|
+
// "freezedMargin": "0",
|
|
1935
|
+
// "shortUid": "12851936"
|
|
1936
|
+
// }
|
|
1937
|
+
// ]
|
|
1938
|
+
// }
|
|
1939
|
+
//
|
|
1940
|
+
// linear swap
|
|
1941
|
+
//
|
|
1942
|
+
// {
|
|
1943
|
+
// "code": 0,
|
|
1944
|
+
// "msg": "",
|
|
1945
|
+
// "data": {
|
|
1946
|
+
// "balance": {
|
|
1947
|
+
// "userId": "1177064765068660742",
|
|
1948
|
+
// "asset": "USDT",
|
|
1949
|
+
// "balance": "51.5198",
|
|
1950
|
+
// "equity": "50.5349",
|
|
1951
|
+
// "unrealizedProfit": "-0.9849",
|
|
1952
|
+
// "realisedProfit": "-0.2134",
|
|
1953
|
+
// "availableMargin": "49.1428",
|
|
1954
|
+
// "usedMargin": "1.3922",
|
|
1955
|
+
// "freezedMargin": "0.0000",
|
|
1956
|
+
// "shortUid": "12851936"
|
|
1957
|
+
// }
|
|
1958
|
+
// }
|
|
1859
1959
|
// }
|
|
1860
1960
|
//
|
|
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
1961
|
const result = { 'info': response };
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1962
|
+
const standardAndInverseBalances = this.safeList(response, 'data');
|
|
1963
|
+
const firstStandardOrInverse = this.safeDict(standardAndInverseBalances, 0);
|
|
1964
|
+
const isStandardOrInverse = firstStandardOrInverse !== undefined;
|
|
1965
|
+
const spotData = this.safeDict(response, 'data', {});
|
|
1966
|
+
const spotBalances = this.safeList(spotData, 'balances');
|
|
1967
|
+
const firstSpot = this.safeDict(spotBalances, 0);
|
|
1968
|
+
const isSpot = firstSpot !== undefined;
|
|
1969
|
+
if (isStandardOrInverse) {
|
|
1970
|
+
for (let i = 0; i < standardAndInverseBalances.length; i++) {
|
|
1971
|
+
const balance = standardAndInverseBalances[i];
|
|
1972
|
+
const currencyId = this.safeString(balance, 'asset');
|
|
1973
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
1974
|
+
const account = this.account();
|
|
1975
|
+
account['free'] = this.safeString2(balance, 'availableMargin', 'availableBalance');
|
|
1976
|
+
account['used'] = this.safeString(balance, 'usedMargin');
|
|
1977
|
+
account['total'] = this.safeString(balance, 'maxWithdrawAmount');
|
|
1978
|
+
result[code] = account;
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
else if (isSpot) {
|
|
1982
|
+
for (let i = 0; i < spotBalances.length; i++) {
|
|
1983
|
+
const balance = spotBalances[i];
|
|
1870
1984
|
const currencyId = this.safeString(balance, 'asset');
|
|
1871
1985
|
const code = this.safeCurrencyCode(currencyId);
|
|
1872
1986
|
const account = this.account();
|
|
1873
|
-
account['free'] = this.
|
|
1987
|
+
account['free'] = this.safeString(balance, 'free');
|
|
1874
1988
|
account['used'] = this.safeString(balance, 'locked');
|
|
1875
|
-
account['total'] = this.safeString(balance, 'balance');
|
|
1876
1989
|
result[code] = account;
|
|
1877
1990
|
}
|
|
1878
1991
|
}
|
|
1879
1992
|
else {
|
|
1880
|
-
const
|
|
1993
|
+
const linearSwapData = this.safeDict(response, 'data', {});
|
|
1994
|
+
const linearSwapBalance = this.safeDict(linearSwapData, 'balance');
|
|
1995
|
+
const currencyId = this.safeString(linearSwapBalance, 'asset');
|
|
1881
1996
|
const code = this.safeCurrencyCode(currencyId);
|
|
1882
1997
|
const account = this.account();
|
|
1883
|
-
account['free'] = this.safeString(
|
|
1884
|
-
account['used'] = this.safeString(
|
|
1998
|
+
account['free'] = this.safeString(linearSwapBalance, 'availableMargin');
|
|
1999
|
+
account['used'] = this.safeString(linearSwapBalance, 'usedMargin');
|
|
1885
2000
|
result[code] = account;
|
|
1886
2001
|
}
|
|
1887
2002
|
return this.safeBalance(result);
|
|
@@ -1891,12 +2006,13 @@ class bingx extends bingx$1 {
|
|
|
1891
2006
|
* @method
|
|
1892
2007
|
* @name bingx#fetchPositions
|
|
1893
2008
|
* @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#
|
|
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/standard/contract-interface.html#position
|
|
2011
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20warehouse
|
|
1896
2012
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
1897
2013
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1898
2014
|
* @param {boolean} [params.standard] whether to fetch standard contract positions
|
|
1899
|
-
* @returns {object[]} a list of [position
|
|
2015
|
+
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
1900
2016
|
*/
|
|
1901
2017
|
await this.loadMarkets();
|
|
1902
2018
|
symbols = this.marketSymbols(symbols);
|
|
@@ -1907,55 +2023,217 @@ class bingx extends bingx$1 {
|
|
|
1907
2023
|
response = await this.contractV1PrivateGetAllPosition(params);
|
|
1908
2024
|
}
|
|
1909
2025
|
else {
|
|
1910
|
-
|
|
2026
|
+
let market = undefined;
|
|
2027
|
+
if (symbols !== undefined) {
|
|
2028
|
+
symbols = this.marketSymbols(symbols);
|
|
2029
|
+
const firstSymbol = this.safeString(symbols, 0);
|
|
2030
|
+
if (firstSymbol !== undefined) {
|
|
2031
|
+
market = this.market(firstSymbol);
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
let subType = undefined;
|
|
2035
|
+
[subType, params] = this.handleSubTypeAndParams('fetchPositions', market, params);
|
|
2036
|
+
if (subType === 'inverse') {
|
|
2037
|
+
response = await this.cswapV1PrivateGetUserPositions(params);
|
|
2038
|
+
//
|
|
2039
|
+
// {
|
|
2040
|
+
// "code": 0,
|
|
2041
|
+
// "msg": "",
|
|
2042
|
+
// "timestamp": 0,
|
|
2043
|
+
// "data": [
|
|
2044
|
+
// {
|
|
2045
|
+
// "symbol": "SOL-USD",
|
|
2046
|
+
// "positionId": "1813080351385337856",
|
|
2047
|
+
// "positionSide": "LONG",
|
|
2048
|
+
// "isolated": false,
|
|
2049
|
+
// "positionAmt": "1",
|
|
2050
|
+
// "availableAmt": "1",
|
|
2051
|
+
// "unrealizedProfit": "-0.00009074",
|
|
2052
|
+
// "initialMargin": "0.00630398",
|
|
2053
|
+
// "liquidationPrice": 23.968303426677032,
|
|
2054
|
+
// "avgPrice": "158.63",
|
|
2055
|
+
// "leverage": 10,
|
|
2056
|
+
// "markPrice": "158.402",
|
|
2057
|
+
// "riskRate": "0.00123783",
|
|
2058
|
+
// "maxMarginReduction": "0",
|
|
2059
|
+
// "updateTime": 1721107015848
|
|
2060
|
+
// }
|
|
2061
|
+
// ]
|
|
2062
|
+
// }
|
|
2063
|
+
//
|
|
2064
|
+
}
|
|
2065
|
+
else {
|
|
2066
|
+
response = await this.swapV2PrivateGetUserPositions(params);
|
|
2067
|
+
//
|
|
2068
|
+
// {
|
|
2069
|
+
// "code": 0,
|
|
2070
|
+
// "msg": "",
|
|
2071
|
+
// "data": [
|
|
2072
|
+
// {
|
|
2073
|
+
// "positionId": "1792480725958881280",
|
|
2074
|
+
// "symbol": "LTC-USDT",
|
|
2075
|
+
// "currency": "USDT",
|
|
2076
|
+
// "positionAmt": "0.1",
|
|
2077
|
+
// "availableAmt": "0.1",
|
|
2078
|
+
// "positionSide": "LONG",
|
|
2079
|
+
// "isolated": false,
|
|
2080
|
+
// "avgPrice": "83.53",
|
|
2081
|
+
// "initialMargin": "1.3922",
|
|
2082
|
+
// "margin": "0.3528",
|
|
2083
|
+
// "leverage": 6,
|
|
2084
|
+
// "unrealizedProfit": "-1.0393",
|
|
2085
|
+
// "realisedProfit": "-0.2119",
|
|
2086
|
+
// "liquidationPrice": 0,
|
|
2087
|
+
// "pnlRatio": "-0.7465",
|
|
2088
|
+
// "maxMarginReduction": "0.0000",
|
|
2089
|
+
// "riskRate": "0.0008",
|
|
2090
|
+
// "markPrice": "73.14",
|
|
2091
|
+
// "positionValue": "7.3136",
|
|
2092
|
+
// "onlyOnePosition": true,
|
|
2093
|
+
// "updateTime": 1721088016688
|
|
2094
|
+
// }
|
|
2095
|
+
// ]
|
|
2096
|
+
// }
|
|
2097
|
+
//
|
|
2098
|
+
}
|
|
1911
2099
|
}
|
|
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
2100
|
const positions = this.safeList(response, 'data', []);
|
|
1934
2101
|
return this.parsePositions(positions, symbols);
|
|
1935
2102
|
}
|
|
2103
|
+
async fetchPosition(symbol, params = {}) {
|
|
2104
|
+
/**
|
|
2105
|
+
* @method
|
|
2106
|
+
* @name bingx#fetchPosition
|
|
2107
|
+
* @description fetch data on a single open contract trade position
|
|
2108
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query%20position%20data
|
|
2109
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20warehouse
|
|
2110
|
+
* @param {string} symbol unified market symbol of the market the position is held in
|
|
2111
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2112
|
+
* @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
2113
|
+
*/
|
|
2114
|
+
await this.loadMarkets();
|
|
2115
|
+
const market = this.market(symbol);
|
|
2116
|
+
if (!market['swap']) {
|
|
2117
|
+
throw new errors.BadRequest(this.id + ' fetchPosition() supports swap markets only');
|
|
2118
|
+
}
|
|
2119
|
+
const request = {
|
|
2120
|
+
'symbol': market['id'],
|
|
2121
|
+
};
|
|
2122
|
+
let response = undefined;
|
|
2123
|
+
if (market['inverse']) {
|
|
2124
|
+
response = await this.cswapV1PrivateGetUserPositions(this.extend(request, params));
|
|
2125
|
+
//
|
|
2126
|
+
// {
|
|
2127
|
+
// "code": 0,
|
|
2128
|
+
// "msg": "",
|
|
2129
|
+
// "timestamp": 0,
|
|
2130
|
+
// "data": [
|
|
2131
|
+
// {
|
|
2132
|
+
// "symbol": "SOL-USD",
|
|
2133
|
+
// "positionId": "1813080351385337856",
|
|
2134
|
+
// "positionSide": "LONG",
|
|
2135
|
+
// "isolated": false,
|
|
2136
|
+
// "positionAmt": "1",
|
|
2137
|
+
// "availableAmt": "1",
|
|
2138
|
+
// "unrealizedProfit": "-0.00009074",
|
|
2139
|
+
// "initialMargin": "0.00630398",
|
|
2140
|
+
// "liquidationPrice": 23.968303426677032,
|
|
2141
|
+
// "avgPrice": "158.63",
|
|
2142
|
+
// "leverage": 10,
|
|
2143
|
+
// "markPrice": "158.402",
|
|
2144
|
+
// "riskRate": "0.00123783",
|
|
2145
|
+
// "maxMarginReduction": "0",
|
|
2146
|
+
// "updateTime": 1721107015848
|
|
2147
|
+
// }
|
|
2148
|
+
// ]
|
|
2149
|
+
// }
|
|
2150
|
+
//
|
|
2151
|
+
}
|
|
2152
|
+
else {
|
|
2153
|
+
response = await this.swapV2PrivateGetUserPositions(this.extend(request, params));
|
|
2154
|
+
//
|
|
2155
|
+
// {
|
|
2156
|
+
// "code": 0,
|
|
2157
|
+
// "msg": "",
|
|
2158
|
+
// "data": [
|
|
2159
|
+
// {
|
|
2160
|
+
// "positionId": "1792480725958881280",
|
|
2161
|
+
// "symbol": "LTC-USDT",
|
|
2162
|
+
// "currency": "USDT",
|
|
2163
|
+
// "positionAmt": "0.1",
|
|
2164
|
+
// "availableAmt": "0.1",
|
|
2165
|
+
// "positionSide": "LONG",
|
|
2166
|
+
// "isolated": false,
|
|
2167
|
+
// "avgPrice": "83.53",
|
|
2168
|
+
// "initialMargin": "1.3922",
|
|
2169
|
+
// "margin": "0.3528",
|
|
2170
|
+
// "leverage": 6,
|
|
2171
|
+
// "unrealizedProfit": "-1.0393",
|
|
2172
|
+
// "realisedProfit": "-0.2119",
|
|
2173
|
+
// "liquidationPrice": 0,
|
|
2174
|
+
// "pnlRatio": "-0.7465",
|
|
2175
|
+
// "maxMarginReduction": "0.0000",
|
|
2176
|
+
// "riskRate": "0.0008",
|
|
2177
|
+
// "markPrice": "73.14",
|
|
2178
|
+
// "positionValue": "7.3136",
|
|
2179
|
+
// "onlyOnePosition": true,
|
|
2180
|
+
// "updateTime": 1721088016688
|
|
2181
|
+
// }
|
|
2182
|
+
// ]
|
|
2183
|
+
// }
|
|
2184
|
+
//
|
|
2185
|
+
}
|
|
2186
|
+
const data = this.safeList(response, 'data', []);
|
|
2187
|
+
const first = this.safeDict(data, 0, {});
|
|
2188
|
+
return this.parsePosition(first, market);
|
|
2189
|
+
}
|
|
1936
2190
|
parsePosition(position, market = undefined) {
|
|
1937
2191
|
//
|
|
1938
|
-
//
|
|
1939
|
-
//
|
|
1940
|
-
//
|
|
1941
|
-
//
|
|
1942
|
-
//
|
|
1943
|
-
//
|
|
1944
|
-
//
|
|
1945
|
-
//
|
|
1946
|
-
//
|
|
1947
|
-
//
|
|
1948
|
-
//
|
|
1949
|
-
//
|
|
1950
|
-
//
|
|
1951
|
-
//
|
|
1952
|
-
//
|
|
1953
|
-
//
|
|
1954
|
-
//
|
|
1955
|
-
//
|
|
1956
|
-
//
|
|
1957
|
-
//
|
|
1958
|
-
//
|
|
2192
|
+
// inverse swap
|
|
2193
|
+
//
|
|
2194
|
+
// {
|
|
2195
|
+
// "symbol": "SOL-USD",
|
|
2196
|
+
// "positionId": "1813080351385337856",
|
|
2197
|
+
// "positionSide": "LONG",
|
|
2198
|
+
// "isolated": false,
|
|
2199
|
+
// "positionAmt": "1",
|
|
2200
|
+
// "availableAmt": "1",
|
|
2201
|
+
// "unrealizedProfit": "-0.00009074",
|
|
2202
|
+
// "initialMargin": "0.00630398",
|
|
2203
|
+
// "liquidationPrice": 23.968303426677032,
|
|
2204
|
+
// "avgPrice": "158.63",
|
|
2205
|
+
// "leverage": 10,
|
|
2206
|
+
// "markPrice": "158.402",
|
|
2207
|
+
// "riskRate": "0.00123783",
|
|
2208
|
+
// "maxMarginReduction": "0",
|
|
2209
|
+
// "updateTime": 1721107015848
|
|
2210
|
+
// }
|
|
2211
|
+
//
|
|
2212
|
+
// linear swap
|
|
2213
|
+
//
|
|
2214
|
+
// {
|
|
2215
|
+
// "positionId": "1792480725958881280",
|
|
2216
|
+
// "symbol": "LTC-USDT",
|
|
2217
|
+
// "currency": "USDT",
|
|
2218
|
+
// "positionAmt": "0.1",
|
|
2219
|
+
// "availableAmt": "0.1",
|
|
2220
|
+
// "positionSide": "LONG",
|
|
2221
|
+
// "isolated": false,
|
|
2222
|
+
// "avgPrice": "83.53",
|
|
2223
|
+
// "initialMargin": "1.3922",
|
|
2224
|
+
// "margin": "0.3528",
|
|
2225
|
+
// "leverage": 6,
|
|
2226
|
+
// "unrealizedProfit": "-1.0393",
|
|
2227
|
+
// "realisedProfit": "-0.2119",
|
|
2228
|
+
// "liquidationPrice": 0,
|
|
2229
|
+
// "pnlRatio": "-0.7465",
|
|
2230
|
+
// "maxMarginReduction": "0.0000",
|
|
2231
|
+
// "riskRate": "0.0008",
|
|
2232
|
+
// "markPrice": "73.14",
|
|
2233
|
+
// "positionValue": "7.3136",
|
|
2234
|
+
// "onlyOnePosition": true,
|
|
2235
|
+
// "updateTime": 1721088016688
|
|
2236
|
+
// }
|
|
1959
2237
|
//
|
|
1960
2238
|
// standard position
|
|
1961
2239
|
//
|
|
@@ -1991,13 +2269,13 @@ class bingx extends bingx$1 {
|
|
|
1991
2269
|
'percentage': undefined,
|
|
1992
2270
|
'contracts': this.safeNumber(position, 'positionAmt'),
|
|
1993
2271
|
'contractSize': undefined,
|
|
1994
|
-
'markPrice':
|
|
2272
|
+
'markPrice': this.safeNumber(position, 'markPrice'),
|
|
1995
2273
|
'lastPrice': undefined,
|
|
1996
2274
|
'side': this.safeStringLower(position, 'positionSide'),
|
|
1997
2275
|
'hedged': undefined,
|
|
1998
2276
|
'timestamp': undefined,
|
|
1999
2277
|
'datetime': undefined,
|
|
2000
|
-
'lastUpdateTimestamp':
|
|
2278
|
+
'lastUpdateTimestamp': this.safeInteger(position, 'updateTime'),
|
|
2001
2279
|
'maintenanceMargin': undefined,
|
|
2002
2280
|
'maintenanceMarginPercentage': undefined,
|
|
2003
2281
|
'collateral': undefined,
|
|
@@ -4565,6 +4843,7 @@ class bingx extends bingx$1 {
|
|
|
4565
4843
|
* @name bingx#fetchMyLiquidations
|
|
4566
4844
|
* @description retrieves the users liquidated positions
|
|
4567
4845
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#User's%20Force%20Orders
|
|
4846
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20force%20orders
|
|
4568
4847
|
* @param {string} [symbol] unified CCXT market symbol
|
|
4569
4848
|
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
4570
4849
|
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
@@ -4588,38 +4867,75 @@ class bingx extends bingx$1 {
|
|
|
4588
4867
|
if (limit !== undefined) {
|
|
4589
4868
|
request['limit'] = limit;
|
|
4590
4869
|
}
|
|
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
|
-
|
|
4870
|
+
let subType = undefined;
|
|
4871
|
+
[subType, params] = this.handleSubTypeAndParams('fetchMyLiquidations', market, params);
|
|
4872
|
+
let response = undefined;
|
|
4873
|
+
let liquidations = undefined;
|
|
4874
|
+
if (subType === 'inverse') {
|
|
4875
|
+
response = await this.cswapV1PrivateGetTradeForceOrders(this.extend(request, params));
|
|
4876
|
+
//
|
|
4877
|
+
// {
|
|
4878
|
+
// "code": 0,
|
|
4879
|
+
// "msg": "",
|
|
4880
|
+
// "timestamp": 1721280071678,
|
|
4881
|
+
// "data": [
|
|
4882
|
+
// {
|
|
4883
|
+
// "orderId": "string",
|
|
4884
|
+
// "symbol": "string",
|
|
4885
|
+
// "type": "string",
|
|
4886
|
+
// "side": "string",
|
|
4887
|
+
// "positionSide": "string",
|
|
4888
|
+
// "price": "string",
|
|
4889
|
+
// "quantity": "float64",
|
|
4890
|
+
// "stopPrice": "string",
|
|
4891
|
+
// "workingType": "string",
|
|
4892
|
+
// "status": "string",
|
|
4893
|
+
// "time": "int64",
|
|
4894
|
+
// "avgPrice": "string",
|
|
4895
|
+
// "executedQty": "string",
|
|
4896
|
+
// "profit": "string",
|
|
4897
|
+
// "commission": "string",
|
|
4898
|
+
// "updateTime": "string"
|
|
4899
|
+
// }
|
|
4900
|
+
// ]
|
|
4901
|
+
// }
|
|
4902
|
+
//
|
|
4903
|
+
liquidations = this.safeList(response, 'data', []);
|
|
4904
|
+
}
|
|
4905
|
+
else {
|
|
4906
|
+
response = await this.swapV2PrivateGetTradeForceOrders(this.extend(request, params));
|
|
4907
|
+
//
|
|
4908
|
+
// {
|
|
4909
|
+
// "code": 0,
|
|
4910
|
+
// "msg": "",
|
|
4911
|
+
// "data": {
|
|
4912
|
+
// "orders": [
|
|
4913
|
+
// {
|
|
4914
|
+
// "time": "int64",
|
|
4915
|
+
// "symbol": "string",
|
|
4916
|
+
// "side": "string",
|
|
4917
|
+
// "type": "string",
|
|
4918
|
+
// "positionSide": "string",
|
|
4919
|
+
// "cumQuote": "string",
|
|
4920
|
+
// "status": "string",
|
|
4921
|
+
// "stopPrice": "string",
|
|
4922
|
+
// "price": "string",
|
|
4923
|
+
// "origQty": "string",
|
|
4924
|
+
// "avgPrice": "string",
|
|
4925
|
+
// "executedQty": "string",
|
|
4926
|
+
// "orderId": "int64",
|
|
4927
|
+
// "profit": "string",
|
|
4928
|
+
// "commission": "string",
|
|
4929
|
+
// "workingType": "string",
|
|
4930
|
+
// "updateTime": "int64"
|
|
4931
|
+
// },
|
|
4932
|
+
// ]
|
|
4933
|
+
// }
|
|
4934
|
+
// }
|
|
4935
|
+
//
|
|
4936
|
+
const data = this.safeDict(response, 'data', {});
|
|
4937
|
+
liquidations = this.safeList(data, 'orders', []);
|
|
4938
|
+
}
|
|
4623
4939
|
return this.parseLiquidations(liquidations, market, since, limit);
|
|
4624
4940
|
}
|
|
4625
4941
|
parseLiquidation(liquidation, market = undefined) {
|
|
@@ -5033,6 +5349,93 @@ class bingx extends bingx$1 {
|
|
|
5033
5349
|
'marginMode': marginType,
|
|
5034
5350
|
};
|
|
5035
5351
|
}
|
|
5352
|
+
async fetchTradingFee(symbol, params = {}) {
|
|
5353
|
+
/**
|
|
5354
|
+
* @method
|
|
5355
|
+
* @name bingx#fetchTradingFee
|
|
5356
|
+
* @description fetch the trading fees for a market
|
|
5357
|
+
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Trading%20Commission%20Rate
|
|
5358
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/account-api.html#Query%20Trading%20Commission%20Rate
|
|
5359
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Trade%20Commission%20Rate
|
|
5360
|
+
* @param {string} symbol unified market symbol
|
|
5361
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5362
|
+
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
|
|
5363
|
+
*/
|
|
5364
|
+
await this.loadMarkets();
|
|
5365
|
+
const market = this.market(symbol);
|
|
5366
|
+
const request = {
|
|
5367
|
+
'symbol': market['id'],
|
|
5368
|
+
};
|
|
5369
|
+
let response = undefined;
|
|
5370
|
+
let commission = {};
|
|
5371
|
+
const data = this.safeDict(response, 'data', {});
|
|
5372
|
+
if (market['spot']) {
|
|
5373
|
+
response = await this.spotV1PrivateGetUserCommissionRate(this.extend(request, params));
|
|
5374
|
+
//
|
|
5375
|
+
// {
|
|
5376
|
+
// "code": 0,
|
|
5377
|
+
// "msg": "",
|
|
5378
|
+
// "debugMsg": "",
|
|
5379
|
+
// "data": {
|
|
5380
|
+
// "takerCommissionRate": 0.001,
|
|
5381
|
+
// "makerCommissionRate": 0.001
|
|
5382
|
+
// }
|
|
5383
|
+
// }
|
|
5384
|
+
//
|
|
5385
|
+
commission = data;
|
|
5386
|
+
}
|
|
5387
|
+
else {
|
|
5388
|
+
if (market['inverse']) {
|
|
5389
|
+
response = await this.cswapV1PrivateGetUserCommissionRate(params);
|
|
5390
|
+
//
|
|
5391
|
+
// {
|
|
5392
|
+
// "code": 0,
|
|
5393
|
+
// "msg": "",
|
|
5394
|
+
// "timestamp": 1721365261438,
|
|
5395
|
+
// "data": {
|
|
5396
|
+
// "takerCommissionRate": "0.0005",
|
|
5397
|
+
// "makerCommissionRate": "0.0002"
|
|
5398
|
+
// }
|
|
5399
|
+
// }
|
|
5400
|
+
//
|
|
5401
|
+
commission = data;
|
|
5402
|
+
}
|
|
5403
|
+
else {
|
|
5404
|
+
response = await this.swapV2PrivateGetUserCommissionRate(params);
|
|
5405
|
+
//
|
|
5406
|
+
// {
|
|
5407
|
+
// "code": 0,
|
|
5408
|
+
// "msg": "",
|
|
5409
|
+
// "data": {
|
|
5410
|
+
// "commission": {
|
|
5411
|
+
// "takerCommissionRate": 0.0005,
|
|
5412
|
+
// "makerCommissionRate": 0.0002
|
|
5413
|
+
// }
|
|
5414
|
+
// }
|
|
5415
|
+
// }
|
|
5416
|
+
//
|
|
5417
|
+
commission = this.safeDict(data, 'commission', {});
|
|
5418
|
+
}
|
|
5419
|
+
}
|
|
5420
|
+
return this.parseTradingFee(commission, market);
|
|
5421
|
+
}
|
|
5422
|
+
parseTradingFee(fee, market = undefined) {
|
|
5423
|
+
//
|
|
5424
|
+
// {
|
|
5425
|
+
// "takerCommissionRate": 0.001,
|
|
5426
|
+
// "makerCommissionRate": 0.001
|
|
5427
|
+
// }
|
|
5428
|
+
//
|
|
5429
|
+
const symbol = (market !== undefined) ? market['symbol'] : undefined;
|
|
5430
|
+
return {
|
|
5431
|
+
'info': fee,
|
|
5432
|
+
'symbol': symbol,
|
|
5433
|
+
'maker': this.safeNumber(fee, 'makerCommissionRate'),
|
|
5434
|
+
'taker': this.safeNumber(fee, 'takerCommissionRate'),
|
|
5435
|
+
'percentage': false,
|
|
5436
|
+
'tierBased': false,
|
|
5437
|
+
};
|
|
5438
|
+
}
|
|
5036
5439
|
sign(path, section = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
5037
5440
|
const type = section[0];
|
|
5038
5441
|
const version = section[1];
|