ccxt 4.3.61 → 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 +50 -43
- package/dist/cjs/src/bingx.js +507 -184
- package/dist/cjs/src/bybit.js +1 -1
- package/dist/cjs/src/cryptocom.js +18 -2
- package/dist/cjs/src/mercado.js +5 -1
- package/dist/cjs/src/pro/alpaca.js +3 -3
- package/dist/cjs/src/pro/binance.js +60 -38
- package/dist/cjs/src/pro/bingx.js +2 -2
- package/dist/cjs/src/pro/bitfinex2.js +8 -5
- package/dist/cjs/src/pro/bitget.js +5 -2
- package/dist/cjs/src/pro/bitmex.js +1 -1
- package/dist/cjs/src/pro/bitopro.js +1 -1
- package/dist/cjs/src/pro/bitvavo.js +1 -1
- package/dist/cjs/src/pro/bybit.js +49 -23
- package/dist/cjs/src/pro/coinbaseexchange.js +2 -2
- package/dist/cjs/src/pro/coincheck.js +1 -1
- package/dist/cjs/src/pro/coinone.js +1 -1
- package/dist/cjs/src/pro/cryptocom.js +8 -2
- package/dist/cjs/src/pro/deribit.js +1 -1
- package/dist/cjs/src/pro/gate.js +8 -4
- package/dist/cjs/src/pro/hollaex.js +1 -1
- package/dist/cjs/src/pro/htx.js +6 -2
- package/dist/cjs/src/pro/hyperliquid.js +3 -3
- package/dist/cjs/src/pro/independentreserve.js +5 -3
- package/dist/cjs/src/pro/kraken.js +83 -5
- package/dist/cjs/src/pro/kucoin.js +1 -1
- package/dist/cjs/src/pro/mexc.js +1 -1
- package/dist/cjs/src/pro/okx.js +4 -4
- package/dist/cjs/src/pro/oxfun.js +1 -1
- package/dist/cjs/src/pro/phemex.js +1 -1
- package/dist/cjs/src/pro/poloniexfutures.js +5 -1
- package/dist/cjs/src/pro/upbit.js +1 -1
- package/dist/cjs/src/pro/vertex.js +2 -2
- package/dist/cjs/src/pro/whitebit.js +1 -1
- package/dist/cjs/src/pro/woo.js +1 -1
- package/dist/cjs/src/pro/woofipro.js +1 -1
- package/dist/cjs/src/tradeogre.js +1 -1
- package/dist/cjs/src/woo.js +313 -81
- package/dist/cjs/src/xt.js +1 -1
- 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/base/ws/Client.d.ts +1 -1
- package/js/src/binance.js +50 -43
- package/js/src/bingx.d.ts +1 -0
- package/js/src/bingx.js +507 -184
- package/js/src/bybit.js +1 -1
- 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/alpaca.js +3 -3
- package/js/src/pro/binance.d.ts +1 -0
- package/js/src/pro/binance.js +61 -39
- package/js/src/pro/bingx.js +2 -2
- package/js/src/pro/bitfinex2.js +9 -6
- package/js/src/pro/bitget.js +6 -3
- package/js/src/pro/bitmex.js +1 -1
- package/js/src/pro/bitopro.js +1 -1
- package/js/src/pro/bitvavo.js +1 -1
- package/js/src/pro/bybit.d.ts +1 -0
- package/js/src/pro/bybit.js +49 -23
- package/js/src/pro/coinbaseexchange.js +2 -2
- package/js/src/pro/coincheck.js +1 -1
- package/js/src/pro/coinone.js +1 -1
- package/js/src/pro/cryptocom.js +9 -3
- package/js/src/pro/deribit.js +1 -1
- package/js/src/pro/gate.js +9 -5
- package/js/src/pro/hollaex.js +1 -1
- package/js/src/pro/htx.js +7 -3
- package/js/src/pro/hyperliquid.js +3 -3
- package/js/src/pro/independentreserve.js +6 -4
- package/js/src/pro/kraken.d.ts +3 -1
- package/js/src/pro/kraken.js +84 -6
- package/js/src/pro/kucoin.js +1 -1
- package/js/src/pro/mexc.js +1 -1
- package/js/src/pro/okx.js +5 -5
- package/js/src/pro/oxfun.js +1 -1
- package/js/src/pro/phemex.js +1 -1
- package/js/src/pro/poloniexfutures.js +6 -2
- package/js/src/pro/upbit.js +1 -1
- package/js/src/pro/vertex.js +2 -2
- package/js/src/pro/whitebit.js +1 -1
- package/js/src/pro/woo.js +1 -1
- package/js/src/pro/woofipro.js +1 -1
- package/js/src/tradeogre.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/js/src/xt.js +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,
|
|
@@ -519,37 +520,40 @@ class bingx extends bingx$1 {
|
|
|
519
520
|
const response = await this.walletsV1PrivateGetCapitalConfigGetall(params);
|
|
520
521
|
//
|
|
521
522
|
// {
|
|
522
|
-
//
|
|
523
|
-
//
|
|
524
|
-
//
|
|
523
|
+
// "code": 0,
|
|
524
|
+
// "timestamp": 1702623271477,
|
|
525
|
+
// "data": [
|
|
526
|
+
// {
|
|
527
|
+
// "coin": "BTC",
|
|
528
|
+
// "name": "BTC",
|
|
529
|
+
// "networkList": [
|
|
525
530
|
// {
|
|
526
|
-
// "coin": "BTC",
|
|
527
531
|
// "name": "BTC",
|
|
528
|
-
// "
|
|
529
|
-
//
|
|
530
|
-
//
|
|
531
|
-
//
|
|
532
|
-
//
|
|
533
|
-
//
|
|
534
|
-
//
|
|
535
|
-
//
|
|
536
|
-
//
|
|
537
|
-
//
|
|
538
|
-
//
|
|
539
|
-
//
|
|
540
|
-
//
|
|
541
|
-
//
|
|
542
|
-
//
|
|
543
|
-
//
|
|
544
|
-
//
|
|
545
|
-
//
|
|
546
|
-
//
|
|
547
|
-
//
|
|
548
|
-
//
|
|
549
|
-
//
|
|
550
|
-
//
|
|
551
|
-
//
|
|
552
|
-
//
|
|
532
|
+
// "network": "BTC",
|
|
533
|
+
// "isDefault": true,
|
|
534
|
+
// "minConfirm": 2,
|
|
535
|
+
// "withdrawEnable": true,
|
|
536
|
+
// "depositEnable": true,
|
|
537
|
+
// "withdrawFee": "0.0006",
|
|
538
|
+
// "withdrawMax": "1.17522",
|
|
539
|
+
// "withdrawMin": "0.0005",
|
|
540
|
+
// "depositMin": "0.0002"
|
|
541
|
+
// },
|
|
542
|
+
// {
|
|
543
|
+
// "name": "BTC",
|
|
544
|
+
// "network": "BEP20",
|
|
545
|
+
// "isDefault": false,
|
|
546
|
+
// "minConfirm": 15,
|
|
547
|
+
// "withdrawEnable": true,
|
|
548
|
+
// "depositEnable": true,
|
|
549
|
+
// "withdrawFee": "0.0000066",
|
|
550
|
+
// "withdrawMax": "1.17522",
|
|
551
|
+
// "withdrawMin": "0.0000066",
|
|
552
|
+
// "depositMin": "0.0002"
|
|
553
|
+
// }
|
|
554
|
+
// ]
|
|
555
|
+
// }
|
|
556
|
+
// ]
|
|
553
557
|
// }
|
|
554
558
|
//
|
|
555
559
|
const data = this.safeList(response, 'data', []);
|
|
@@ -563,6 +567,7 @@ class bingx extends bingx$1 {
|
|
|
563
567
|
const networks = {};
|
|
564
568
|
let fee = undefined;
|
|
565
569
|
let active = undefined;
|
|
570
|
+
let depositEnabled = undefined;
|
|
566
571
|
let withdrawEnabled = undefined;
|
|
567
572
|
let defaultLimits = {};
|
|
568
573
|
for (let j = 0; j < networkList.length; j++) {
|
|
@@ -570,13 +575,17 @@ class bingx extends bingx$1 {
|
|
|
570
575
|
const network = this.safeString(rawNetwork, 'network');
|
|
571
576
|
const networkCode = this.networkIdToCode(network);
|
|
572
577
|
const isDefault = this.safeBool(rawNetwork, 'isDefault');
|
|
578
|
+
depositEnabled = this.safeBool(rawNetwork, 'depositEnable');
|
|
573
579
|
withdrawEnabled = this.safeBool(rawNetwork, 'withdrawEnable');
|
|
574
580
|
const limits = {
|
|
575
|
-
'
|
|
581
|
+
'withdraw': {
|
|
582
|
+
'min': this.safeNumber(rawNetwork, 'withdrawMin'),
|
|
583
|
+
'max': this.safeNumber(rawNetwork, 'withdrawMax'),
|
|
584
|
+
},
|
|
576
585
|
};
|
|
577
586
|
if (isDefault) {
|
|
578
587
|
fee = this.safeNumber(rawNetwork, 'withdrawFee');
|
|
579
|
-
active = withdrawEnabled;
|
|
588
|
+
active = depositEnabled || withdrawEnabled;
|
|
580
589
|
defaultLimits = limits;
|
|
581
590
|
}
|
|
582
591
|
networks[networkCode] = {
|
|
@@ -585,7 +594,7 @@ class bingx extends bingx$1 {
|
|
|
585
594
|
'network': networkCode,
|
|
586
595
|
'fee': fee,
|
|
587
596
|
'active': active,
|
|
588
|
-
'deposit':
|
|
597
|
+
'deposit': depositEnabled,
|
|
589
598
|
'withdraw': withdrawEnabled,
|
|
590
599
|
'precision': undefined,
|
|
591
600
|
'limits': limits,
|
|
@@ -598,7 +607,7 @@ class bingx extends bingx$1 {
|
|
|
598
607
|
'precision': undefined,
|
|
599
608
|
'name': name,
|
|
600
609
|
'active': active,
|
|
601
|
-
'deposit':
|
|
610
|
+
'deposit': depositEnabled,
|
|
602
611
|
'withdraw': withdrawEnabled,
|
|
603
612
|
'networks': networks,
|
|
604
613
|
'fee': fee,
|
|
@@ -1768,6 +1777,7 @@ class bingx extends bingx$1 {
|
|
|
1768
1777
|
* @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Query%20Assets
|
|
1769
1778
|
* @see https://bingx-api.github.io/docs/#/swapV2/account-api.html#Get%20Perpetual%20Swap%20Account%20Asset%20Information
|
|
1770
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
|
|
1771
1781
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1772
1782
|
* @param {boolean} [params.standard] whether to fetch standard contract balances
|
|
1773
1783
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
@@ -1776,104 +1786,216 @@ class bingx extends bingx$1 {
|
|
|
1776
1786
|
let response = undefined;
|
|
1777
1787
|
let standard = undefined;
|
|
1778
1788
|
[standard, params] = this.handleOptionAndParams(params, 'fetchBalance', 'standard', false);
|
|
1789
|
+
let subType = undefined;
|
|
1790
|
+
[subType, params] = this.handleSubTypeAndParams('fetchBalance', undefined, params);
|
|
1779
1791
|
const [marketType, marketTypeQuery] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
|
|
1780
1792
|
if (standard) {
|
|
1781
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
|
+
//
|
|
1782
1812
|
}
|
|
1783
1813
|
else if (marketType === 'spot') {
|
|
1784
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
|
+
//
|
|
1785
1831
|
}
|
|
1786
1832
|
else {
|
|
1787
|
-
|
|
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
|
+
}
|
|
1788
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
|
+
// }
|
|
1789
1901
|
//
|
|
1790
1902
|
// spot
|
|
1791
1903
|
//
|
|
1792
|
-
//
|
|
1793
|
-
//
|
|
1794
|
-
//
|
|
1795
|
-
//
|
|
1796
|
-
//
|
|
1797
|
-
//
|
|
1798
|
-
//
|
|
1799
|
-
//
|
|
1800
|
-
//
|
|
1801
|
-
//
|
|
1802
|
-
//
|
|
1803
|
-
//
|
|
1804
|
-
//
|
|
1805
|
-
//
|
|
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
|
+
// }
|
|
1806
1918
|
//
|
|
1807
|
-
// swap
|
|
1919
|
+
// inverse swap
|
|
1808
1920
|
//
|
|
1809
|
-
//
|
|
1810
|
-
//
|
|
1811
|
-
//
|
|
1812
|
-
//
|
|
1813
|
-
//
|
|
1814
|
-
//
|
|
1815
|
-
//
|
|
1816
|
-
//
|
|
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
|
-
// "maxWithdrawAmount":"0",
|
|
1847
|
-
// "marginAvailable":false,
|
|
1848
|
-
// "updateTime":"1691148990902"
|
|
1849
|
-
// },
|
|
1850
|
-
// ]
|
|
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
|
+
// }
|
|
1851
1958
|
// }
|
|
1852
1959
|
//
|
|
1853
|
-
return this.parseBalance(response);
|
|
1854
|
-
}
|
|
1855
|
-
parseBalance(response) {
|
|
1856
|
-
const data = this.safeValue(response, 'data');
|
|
1857
|
-
const balances = this.safeValue2(data, 'balance', 'balances', data);
|
|
1858
1960
|
const result = { 'info': response };
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
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];
|
|
1971
|
+
const currencyId = this.safeString(balance, 'asset');
|
|
1972
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
1973
|
+
const account = this.account();
|
|
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];
|
|
1862
1983
|
const currencyId = this.safeString(balance, 'asset');
|
|
1863
1984
|
const code = this.safeCurrencyCode(currencyId);
|
|
1864
1985
|
const account = this.account();
|
|
1865
|
-
account['free'] = this.
|
|
1986
|
+
account['free'] = this.safeString(balance, 'free');
|
|
1866
1987
|
account['used'] = this.safeString(balance, 'locked');
|
|
1867
|
-
account['total'] = this.safeString(balance, 'balance');
|
|
1868
1988
|
result[code] = account;
|
|
1869
1989
|
}
|
|
1870
1990
|
}
|
|
1871
1991
|
else {
|
|
1872
|
-
const
|
|
1992
|
+
const linearSwapData = this.safeDict(response, 'data', {});
|
|
1993
|
+
const linearSwapBalance = this.safeDict(linearSwapData, 'balance');
|
|
1994
|
+
const currencyId = this.safeString(linearSwapBalance, 'asset');
|
|
1873
1995
|
const code = this.safeCurrencyCode(currencyId);
|
|
1874
1996
|
const account = this.account();
|
|
1875
|
-
account['free'] = this.safeString(
|
|
1876
|
-
account['used'] = this.safeString(
|
|
1997
|
+
account['free'] = this.safeString(linearSwapBalance, 'availableMargin');
|
|
1998
|
+
account['used'] = this.safeString(linearSwapBalance, 'usedMargin');
|
|
1877
1999
|
result[code] = account;
|
|
1878
2000
|
}
|
|
1879
2001
|
return this.safeBalance(result);
|
|
@@ -1883,12 +2005,13 @@ class bingx extends bingx$1 {
|
|
|
1883
2005
|
* @method
|
|
1884
2006
|
* @name bingx#fetchPositions
|
|
1885
2007
|
* @description fetch all open positions
|
|
1886
|
-
* @see https://bingx-api.github.io/docs/#/swapV2/account-api.html#
|
|
1887
|
-
* @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
|
|
1888
2011
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
1889
2012
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1890
2013
|
* @param {boolean} [params.standard] whether to fetch standard contract positions
|
|
1891
|
-
* @returns {object[]} a list of [position
|
|
2014
|
+
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
1892
2015
|
*/
|
|
1893
2016
|
await this.loadMarkets();
|
|
1894
2017
|
symbols = this.marketSymbols(symbols);
|
|
@@ -1899,55 +2022,217 @@ class bingx extends bingx$1 {
|
|
|
1899
2022
|
response = await this.contractV1PrivateGetAllPosition(params);
|
|
1900
2023
|
}
|
|
1901
2024
|
else {
|
|
1902
|
-
|
|
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
|
+
}
|
|
1903
2098
|
}
|
|
1904
|
-
//
|
|
1905
|
-
// {
|
|
1906
|
-
// "code": 0,
|
|
1907
|
-
// "msg": "",
|
|
1908
|
-
// "data": [
|
|
1909
|
-
// {
|
|
1910
|
-
// "symbol": "BTC-USDT",
|
|
1911
|
-
// "positionId": "12345678",
|
|
1912
|
-
// "positionSide": "LONG",
|
|
1913
|
-
// "isolated": true,
|
|
1914
|
-
// "positionAmt": "123.33",
|
|
1915
|
-
// "availableAmt": "128.99",
|
|
1916
|
-
// "unrealizedProfit": "1.22",
|
|
1917
|
-
// "realisedProfit": "8.1",
|
|
1918
|
-
// "initialMargin": "123.33",
|
|
1919
|
-
// "avgPrice": "2.2",
|
|
1920
|
-
// "leverage": 10,
|
|
1921
|
-
// }
|
|
1922
|
-
// ]
|
|
1923
|
-
// }
|
|
1924
|
-
//
|
|
1925
2099
|
const positions = this.safeList(response, 'data', []);
|
|
1926
2100
|
return this.parsePositions(positions, symbols);
|
|
1927
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
|
+
}
|
|
1928
2189
|
parsePosition(position, market = undefined) {
|
|
1929
2190
|
//
|
|
1930
|
-
//
|
|
1931
|
-
//
|
|
1932
|
-
//
|
|
1933
|
-
//
|
|
1934
|
-
//
|
|
1935
|
-
//
|
|
1936
|
-
//
|
|
1937
|
-
//
|
|
1938
|
-
//
|
|
1939
|
-
//
|
|
1940
|
-
//
|
|
1941
|
-
//
|
|
1942
|
-
//
|
|
1943
|
-
//
|
|
1944
|
-
//
|
|
1945
|
-
//
|
|
1946
|
-
//
|
|
1947
|
-
//
|
|
1948
|
-
//
|
|
1949
|
-
//
|
|
1950
|
-
//
|
|
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
|
+
// }
|
|
1951
2236
|
//
|
|
1952
2237
|
// standard position
|
|
1953
2238
|
//
|
|
@@ -1983,13 +2268,13 @@ class bingx extends bingx$1 {
|
|
|
1983
2268
|
'percentage': undefined,
|
|
1984
2269
|
'contracts': this.safeNumber(position, 'positionAmt'),
|
|
1985
2270
|
'contractSize': undefined,
|
|
1986
|
-
'markPrice':
|
|
2271
|
+
'markPrice': this.safeNumber(position, 'markPrice'),
|
|
1987
2272
|
'lastPrice': undefined,
|
|
1988
2273
|
'side': this.safeStringLower(position, 'positionSide'),
|
|
1989
2274
|
'hedged': undefined,
|
|
1990
2275
|
'timestamp': undefined,
|
|
1991
2276
|
'datetime': undefined,
|
|
1992
|
-
'lastUpdateTimestamp':
|
|
2277
|
+
'lastUpdateTimestamp': this.safeInteger(position, 'updateTime'),
|
|
1993
2278
|
'maintenanceMargin': undefined,
|
|
1994
2279
|
'maintenanceMarginPercentage': undefined,
|
|
1995
2280
|
'collateral': undefined,
|
|
@@ -4557,6 +4842,7 @@ class bingx extends bingx$1 {
|
|
|
4557
4842
|
* @name bingx#fetchMyLiquidations
|
|
4558
4843
|
* @description retrieves the users liquidated positions
|
|
4559
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
|
|
4560
4846
|
* @param {string} [symbol] unified CCXT market symbol
|
|
4561
4847
|
* @param {int} [since] the earliest time in ms to fetch liquidations for
|
|
4562
4848
|
* @param {int} [limit] the maximum number of liquidation structures to retrieve
|
|
@@ -4580,38 +4866,75 @@ class bingx extends bingx$1 {
|
|
|
4580
4866
|
if (limit !== undefined) {
|
|
4581
4867
|
request['limit'] = limit;
|
|
4582
4868
|
}
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
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
|
+
}
|
|
4615
4938
|
return this.parseLiquidations(liquidations, market, since, limit);
|
|
4616
4939
|
}
|
|
4617
4940
|
parseLiquidation(liquidation, market = undefined) {
|