ccxt 4.3.59 → 4.3.61
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 +1 -1
- package/dist/cjs/src/binance.js +90 -1
- package/dist/cjs/src/bingx.js +415 -116
- package/dist/cjs/src/bitfinex.js +38 -4
- package/dist/cjs/src/bitso.js +4 -1
- package/dist/cjs/src/bybit.js +11 -3
- package/dist/cjs/src/cryptocom.js +14 -6
- package/dist/cjs/src/gate.js +1 -2
- package/dist/cjs/src/hyperliquid.js +11 -3
- package/dist/cjs/src/kraken.js +1 -1
- package/dist/cjs/src/mexc.js +2 -1
- package/dist/cjs/src/okx.js +11 -2
- package/dist/cjs/src/pro/cex.js +1 -1
- package/dist/cjs/src/pro/kucoin.js +34 -3
- package/dist/cjs/src/pro/phemex.js +1 -1
- package/dist/cjs/src/pro/xt.js +5 -1
- package/dist/cjs/src/timex.js +18 -2
- package/dist/cjs/src/vertex.js +10 -1
- package/dist/cjs/src/xt.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bingx.d.ts +1 -1
- package/js/src/binance.d.ts +1 -1
- package/js/src/binance.js +90 -1
- package/js/src/bingx.js +415 -116
- package/js/src/bitfinex.d.ts +2 -2
- package/js/src/bitfinex.js +38 -4
- package/js/src/bitso.js +4 -1
- package/js/src/bybit.js +11 -3
- package/js/src/cryptocom.js +14 -6
- package/js/src/gate.js +1 -2
- package/js/src/hyperliquid.js +11 -3
- package/js/src/kraken.js +1 -1
- package/js/src/mexc.js +2 -1
- package/js/src/okx.js +11 -2
- package/js/src/pro/cex.js +1 -1
- package/js/src/pro/kucoin.js +34 -3
- package/js/src/pro/phemex.js +1 -1
- package/js/src/pro/xt.js +5 -1
- package/js/src/timex.d.ts +2 -2
- package/js/src/timex.js +18 -2
- package/js/src/vertex.js +10 -1
- package/js/src/xt.js +1 -1
- package/package.json +1 -1
package/js/src/bingx.js
CHANGED
|
@@ -291,9 +291,11 @@ export default class bingx extends Exchange {
|
|
|
291
291
|
'post': {
|
|
292
292
|
'trade/order': 2,
|
|
293
293
|
'trade/leverage': 2,
|
|
294
|
-
'trade/allOpenOrders': 2,
|
|
295
294
|
'trade/closeAllPositions': 2,
|
|
296
295
|
},
|
|
296
|
+
'delete': {
|
|
297
|
+
'trade/allOpenOrders': 2,
|
|
298
|
+
},
|
|
297
299
|
},
|
|
298
300
|
},
|
|
299
301
|
},
|
|
@@ -1541,8 +1543,9 @@ export default class bingx extends Exchange {
|
|
|
1541
1543
|
* @method
|
|
1542
1544
|
* @name bingx#fetchTicker
|
|
1543
1545
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
1544
|
-
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Ticker
|
|
1545
|
-
* @see https://bingx-api.github.io/docs/#/spot/market-api.html#24%
|
|
1546
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Get%20Ticker
|
|
1547
|
+
* @see https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#24-hour%20price%20changes
|
|
1548
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Query%2024-Hour%20Price%20Change
|
|
1546
1549
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
1547
1550
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1548
1551
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -1557,8 +1560,41 @@ export default class bingx extends Exchange {
|
|
|
1557
1560
|
response = await this.spotV1PublicGetTicker24hr(this.extend(request, params));
|
|
1558
1561
|
}
|
|
1559
1562
|
else {
|
|
1560
|
-
|
|
1563
|
+
if (market['inverse']) {
|
|
1564
|
+
response = await this.cswapV1PublicGetMarketTicker(this.extend(request, params));
|
|
1565
|
+
}
|
|
1566
|
+
else {
|
|
1567
|
+
response = await this.swapV2PublicGetQuoteTicker(this.extend(request, params));
|
|
1568
|
+
}
|
|
1561
1569
|
}
|
|
1570
|
+
//
|
|
1571
|
+
// spot and swap
|
|
1572
|
+
//
|
|
1573
|
+
// {
|
|
1574
|
+
// "code": 0,
|
|
1575
|
+
// "msg": "",
|
|
1576
|
+
// "timestamp": 1720647285296,
|
|
1577
|
+
// "data": [
|
|
1578
|
+
// {
|
|
1579
|
+
// "symbol": "SOL-USD",
|
|
1580
|
+
// "priceChange": "-2.418",
|
|
1581
|
+
// "priceChangePercent": "-1.6900%",
|
|
1582
|
+
// "lastPrice": "140.574",
|
|
1583
|
+
// "lastQty": "1",
|
|
1584
|
+
// "highPrice": "146.190",
|
|
1585
|
+
// "lowPrice": "138.586",
|
|
1586
|
+
// "volume": "1464648.00",
|
|
1587
|
+
// "quoteVolume": "102928.12",
|
|
1588
|
+
// "openPrice": "142.994",
|
|
1589
|
+
// "closeTime": "1720647284976",
|
|
1590
|
+
// "bidPrice": "140.573",
|
|
1591
|
+
// "bidQty": "372",
|
|
1592
|
+
// "askPrice": "140.577",
|
|
1593
|
+
// "askQty": "58"
|
|
1594
|
+
// }
|
|
1595
|
+
// ]
|
|
1596
|
+
// }
|
|
1597
|
+
//
|
|
1562
1598
|
const data = this.safeList(response, 'data');
|
|
1563
1599
|
if (data !== undefined) {
|
|
1564
1600
|
const first = this.safeDict(data, 0, {});
|
|
@@ -1572,7 +1608,9 @@ export default class bingx extends Exchange {
|
|
|
1572
1608
|
* @method
|
|
1573
1609
|
* @name bingx#fetchTickers
|
|
1574
1610
|
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
1575
|
-
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Ticker
|
|
1611
|
+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Get%20Ticker
|
|
1612
|
+
* @see https://bingx-api.github.io/docs/#/en-us/spot/market-api.html#24-hour%20price%20changes
|
|
1613
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Query%2024-Hour%20Price%20Change
|
|
1576
1614
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
1577
1615
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1578
1616
|
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -1588,13 +1626,49 @@ export default class bingx extends Exchange {
|
|
|
1588
1626
|
}
|
|
1589
1627
|
let type = undefined;
|
|
1590
1628
|
[type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
1629
|
+
let subType = undefined;
|
|
1630
|
+
[subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params);
|
|
1591
1631
|
let response = undefined;
|
|
1592
1632
|
if (type === 'spot') {
|
|
1593
1633
|
response = await this.spotV1PublicGetTicker24hr(params);
|
|
1594
1634
|
}
|
|
1595
1635
|
else {
|
|
1596
|
-
|
|
1636
|
+
if (subType === 'inverse') {
|
|
1637
|
+
response = await this.cswapV1PublicGetMarketTicker(params);
|
|
1638
|
+
}
|
|
1639
|
+
else {
|
|
1640
|
+
response = await this.swapV2PublicGetQuoteTicker(params);
|
|
1641
|
+
}
|
|
1597
1642
|
}
|
|
1643
|
+
//
|
|
1644
|
+
// spot and swap
|
|
1645
|
+
//
|
|
1646
|
+
// {
|
|
1647
|
+
// "code": 0,
|
|
1648
|
+
// "msg": "",
|
|
1649
|
+
// "timestamp": 1720647285296,
|
|
1650
|
+
// "data": [
|
|
1651
|
+
// {
|
|
1652
|
+
// "symbol": "SOL-USD",
|
|
1653
|
+
// "priceChange": "-2.418",
|
|
1654
|
+
// "priceChangePercent": "-1.6900%",
|
|
1655
|
+
// "lastPrice": "140.574",
|
|
1656
|
+
// "lastQty": "1",
|
|
1657
|
+
// "highPrice": "146.190",
|
|
1658
|
+
// "lowPrice": "138.586",
|
|
1659
|
+
// "volume": "1464648.00",
|
|
1660
|
+
// "quoteVolume": "102928.12",
|
|
1661
|
+
// "openPrice": "142.994",
|
|
1662
|
+
// "closeTime": "1720647284976",
|
|
1663
|
+
// "bidPrice": "140.573",
|
|
1664
|
+
// "bidQty": "372",
|
|
1665
|
+
// "askPrice": "140.577",
|
|
1666
|
+
// "askQty": "58"
|
|
1667
|
+
// },
|
|
1668
|
+
// ...
|
|
1669
|
+
// ]
|
|
1670
|
+
// }
|
|
1671
|
+
//
|
|
1598
1672
|
const tickers = this.safeList(response, 'data');
|
|
1599
1673
|
return this.parseTickers(tickers, symbols);
|
|
1600
1674
|
}
|
|
@@ -2625,7 +2699,9 @@ export default class bingx extends Exchange {
|
|
|
2625
2699
|
// side: 'SELL'
|
|
2626
2700
|
// }
|
|
2627
2701
|
// }
|
|
2702
|
+
//
|
|
2628
2703
|
// stop loss order
|
|
2704
|
+
//
|
|
2629
2705
|
// {
|
|
2630
2706
|
// "symbol": "ETH-USDT",
|
|
2631
2707
|
// "orderId": "1792461744476422144",
|
|
@@ -2645,6 +2721,52 @@ export default class bingx extends Exchange {
|
|
|
2645
2721
|
// "clientOrderID": ""
|
|
2646
2722
|
// }
|
|
2647
2723
|
//
|
|
2724
|
+
// inverse swap cancelAllOrders
|
|
2725
|
+
//
|
|
2726
|
+
// {
|
|
2727
|
+
// "symbol": "SOL-USD",
|
|
2728
|
+
// "orderId": "1809845251327672320",
|
|
2729
|
+
// "side": "BUY",
|
|
2730
|
+
// "positionSide": "LONG",
|
|
2731
|
+
// "type": "LIMIT",
|
|
2732
|
+
// "quantity": 1,
|
|
2733
|
+
// "origQty": "0",
|
|
2734
|
+
// "price": "90",
|
|
2735
|
+
// "executedQty": "0",
|
|
2736
|
+
// "avgPrice": "0",
|
|
2737
|
+
// "cumQuote": "0",
|
|
2738
|
+
// "stopPrice": "",
|
|
2739
|
+
// "profit": "0.0000",
|
|
2740
|
+
// "commission": "0.000000",
|
|
2741
|
+
// "status": "CANCELLED",
|
|
2742
|
+
// "time": 1720335707872,
|
|
2743
|
+
// "updateTime": 1720335707912,
|
|
2744
|
+
// "clientOrderId": "",
|
|
2745
|
+
// "leverage": "",
|
|
2746
|
+
// "takeProfit": {
|
|
2747
|
+
// "type": "",
|
|
2748
|
+
// "quantity": 0,
|
|
2749
|
+
// "stopPrice": 0,
|
|
2750
|
+
// "price": 0,
|
|
2751
|
+
// "workingType": "",
|
|
2752
|
+
// "stopGuaranteed": ""
|
|
2753
|
+
// },
|
|
2754
|
+
// "stopLoss": {
|
|
2755
|
+
// "type": "",
|
|
2756
|
+
// "quantity": 0,
|
|
2757
|
+
// "stopPrice": 0,
|
|
2758
|
+
// "price": 0,
|
|
2759
|
+
// "workingType": "",
|
|
2760
|
+
// "stopGuaranteed": ""
|
|
2761
|
+
// },
|
|
2762
|
+
// "advanceAttr": 0,
|
|
2763
|
+
// "positionID": 0,
|
|
2764
|
+
// "takeProfitEntrustPrice": 0,
|
|
2765
|
+
// "stopLossEntrustPrice": 0,
|
|
2766
|
+
// "orderType": "",
|
|
2767
|
+
// "workingType": ""
|
|
2768
|
+
// }
|
|
2769
|
+
//
|
|
2648
2770
|
const info = order;
|
|
2649
2771
|
const newOrder = this.safeDict2(order, 'newOrderResponse', 'orderOpenResponse');
|
|
2650
2772
|
if (newOrder !== undefined) {
|
|
@@ -2850,6 +2972,7 @@ export default class bingx extends Exchange {
|
|
|
2850
2972
|
* @description cancel all open orders
|
|
2851
2973
|
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20orders%20by%20symbol
|
|
2852
2974
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Cancel%20All%20Orders
|
|
2975
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Cancel%20all%20orders
|
|
2853
2976
|
* @param {string} [symbol] unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
2854
2977
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2855
2978
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
@@ -2889,36 +3012,96 @@ export default class bingx extends Exchange {
|
|
|
2889
3012
|
//
|
|
2890
3013
|
}
|
|
2891
3014
|
else if (market['swap']) {
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
3015
|
+
if (market['inverse']) {
|
|
3016
|
+
response = await this.cswapV1PrivateDeleteTradeAllOpenOrders(this.extend(request, params));
|
|
3017
|
+
//
|
|
3018
|
+
// {
|
|
3019
|
+
// "code": 0,
|
|
3020
|
+
// "msg": "",
|
|
3021
|
+
// "timestamp": 1720501468364,
|
|
3022
|
+
// "data": {
|
|
3023
|
+
// "success": [
|
|
3024
|
+
// {
|
|
3025
|
+
// "symbol": "SOL-USD",
|
|
3026
|
+
// "orderId": "1809845251327672320",
|
|
3027
|
+
// "side": "BUY",
|
|
3028
|
+
// "positionSide": "LONG",
|
|
3029
|
+
// "type": "LIMIT",
|
|
3030
|
+
// "quantity": 1,
|
|
3031
|
+
// "origQty": "0",
|
|
3032
|
+
// "price": "90",
|
|
3033
|
+
// "executedQty": "0",
|
|
3034
|
+
// "avgPrice": "0",
|
|
3035
|
+
// "cumQuote": "0",
|
|
3036
|
+
// "stopPrice": "",
|
|
3037
|
+
// "profit": "0.0000",
|
|
3038
|
+
// "commission": "0.000000",
|
|
3039
|
+
// "status": "CANCELLED",
|
|
3040
|
+
// "time": 1720335707872,
|
|
3041
|
+
// "updateTime": 1720335707912,
|
|
3042
|
+
// "clientOrderId": "",
|
|
3043
|
+
// "leverage": "",
|
|
3044
|
+
// "takeProfit": {
|
|
3045
|
+
// "type": "",
|
|
3046
|
+
// "quantity": 0,
|
|
3047
|
+
// "stopPrice": 0,
|
|
3048
|
+
// "price": 0,
|
|
3049
|
+
// "workingType": "",
|
|
3050
|
+
// "stopGuaranteed": ""
|
|
3051
|
+
// },
|
|
3052
|
+
// "stopLoss": {
|
|
3053
|
+
// "type": "",
|
|
3054
|
+
// "quantity": 0,
|
|
3055
|
+
// "stopPrice": 0,
|
|
3056
|
+
// "price": 0,
|
|
3057
|
+
// "workingType": "",
|
|
3058
|
+
// "stopGuaranteed": ""
|
|
3059
|
+
// },
|
|
3060
|
+
// "advanceAttr": 0,
|
|
3061
|
+
// "positionID": 0,
|
|
3062
|
+
// "takeProfitEntrustPrice": 0,
|
|
3063
|
+
// "stopLossEntrustPrice": 0,
|
|
3064
|
+
// "orderType": "",
|
|
3065
|
+
// "workingType": ""
|
|
3066
|
+
// }
|
|
3067
|
+
// ],
|
|
3068
|
+
// "failed": null
|
|
3069
|
+
// }
|
|
3070
|
+
// }
|
|
3071
|
+
//
|
|
3072
|
+
}
|
|
3073
|
+
else {
|
|
3074
|
+
response = await this.swapV2PrivateDeleteTradeAllOpenOrders(this.extend(request, params));
|
|
3075
|
+
//
|
|
3076
|
+
// {
|
|
3077
|
+
// "code": 0,
|
|
3078
|
+
// "msg": "",
|
|
3079
|
+
// "data": {
|
|
3080
|
+
// "success": [
|
|
3081
|
+
// {
|
|
3082
|
+
// "symbol": "LINK-USDT",
|
|
3083
|
+
// "orderId": 1597783835095859200,
|
|
3084
|
+
// "side": "BUY",
|
|
3085
|
+
// "positionSide": "LONG",
|
|
3086
|
+
// "type": "TRIGGER_LIMIT",
|
|
3087
|
+
// "origQty": "5.0",
|
|
3088
|
+
// "price": "9.0000",
|
|
3089
|
+
// "executedQty": "0.0",
|
|
3090
|
+
// "avgPrice": "0.0000",
|
|
3091
|
+
// "cumQuote": "0",
|
|
3092
|
+
// "stopPrice": "9.5000",
|
|
3093
|
+
// "profit": "",
|
|
3094
|
+
// "commission": "",
|
|
3095
|
+
// "status": "NEW",
|
|
3096
|
+
// "time": 1669776326000,
|
|
3097
|
+
// "updateTime": 1669776326000
|
|
3098
|
+
// }
|
|
3099
|
+
// ],
|
|
3100
|
+
// "failed": null
|
|
3101
|
+
// }
|
|
3102
|
+
// }
|
|
3103
|
+
//
|
|
3104
|
+
}
|
|
2922
3105
|
}
|
|
2923
3106
|
else {
|
|
2924
3107
|
throw new BadRequest(this.id + ' cancelAllOrders is only supported for spot and swap markets.');
|
|
@@ -3971,6 +4154,7 @@ export default class bingx extends Exchange {
|
|
|
3971
4154
|
* @name bingx#fetchLeverage
|
|
3972
4155
|
* @description fetch the set leverage for a market
|
|
3973
4156
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Query%20Leverage
|
|
4157
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Leverage
|
|
3974
4158
|
* @param {string} symbol unified market symbol
|
|
3975
4159
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3976
4160
|
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
@@ -3980,21 +4164,79 @@ export default class bingx extends Exchange {
|
|
|
3980
4164
|
const request = {
|
|
3981
4165
|
'symbol': market['id'],
|
|
3982
4166
|
};
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
4167
|
+
let response = undefined;
|
|
4168
|
+
if (market['inverse']) {
|
|
4169
|
+
response = await this.cswapV1PrivateGetTradeLeverage(this.extend(request, params));
|
|
4170
|
+
//
|
|
4171
|
+
// {
|
|
4172
|
+
// "code": 0,
|
|
4173
|
+
// "msg": "",
|
|
4174
|
+
// "timestamp": 1720683803391,
|
|
4175
|
+
// "data": {
|
|
4176
|
+
// "symbol": "SOL-USD",
|
|
4177
|
+
// "longLeverage": 5,
|
|
4178
|
+
// "shortLeverage": 5,
|
|
4179
|
+
// "maxLongLeverage": 50,
|
|
4180
|
+
// "maxShortLeverage": 50,
|
|
4181
|
+
// "availableLongVol": "4000000",
|
|
4182
|
+
// "availableShortVol": "4000000"
|
|
4183
|
+
// }
|
|
4184
|
+
// }
|
|
4185
|
+
//
|
|
4186
|
+
}
|
|
4187
|
+
else {
|
|
4188
|
+
response = await this.swapV2PrivateGetTradeLeverage(this.extend(request, params));
|
|
4189
|
+
//
|
|
4190
|
+
// {
|
|
4191
|
+
// "code": 0,
|
|
4192
|
+
// "msg": "",
|
|
4193
|
+
// "data": {
|
|
4194
|
+
// "longLeverage": 5,
|
|
4195
|
+
// "shortLeverage": 5,
|
|
4196
|
+
// "maxLongLeverage": 125,
|
|
4197
|
+
// "maxShortLeverage": 125,
|
|
4198
|
+
// "availableLongVol": "0.0000",
|
|
4199
|
+
// "availableShortVol": "0.0000",
|
|
4200
|
+
// "availableLongVal": "0.0",
|
|
4201
|
+
// "availableShortVal": "0.0",
|
|
4202
|
+
// "maxPositionLongVal": "0.0",
|
|
4203
|
+
// "maxPositionShortVal": "0.0"
|
|
4204
|
+
// }
|
|
4205
|
+
// }
|
|
4206
|
+
//
|
|
4207
|
+
}
|
|
3994
4208
|
const data = this.safeDict(response, 'data', {});
|
|
3995
4209
|
return this.parseLeverage(data, market);
|
|
3996
4210
|
}
|
|
3997
4211
|
parseLeverage(leverage, market = undefined) {
|
|
4212
|
+
//
|
|
4213
|
+
// linear swap
|
|
4214
|
+
//
|
|
4215
|
+
// {
|
|
4216
|
+
// "longLeverage": 5,
|
|
4217
|
+
// "shortLeverage": 5,
|
|
4218
|
+
// "maxLongLeverage": 125,
|
|
4219
|
+
// "maxShortLeverage": 125,
|
|
4220
|
+
// "availableLongVol": "0.0000",
|
|
4221
|
+
// "availableShortVol": "0.0000",
|
|
4222
|
+
// "availableLongVal": "0.0",
|
|
4223
|
+
// "availableShortVal": "0.0",
|
|
4224
|
+
// "maxPositionLongVal": "0.0",
|
|
4225
|
+
// "maxPositionShortVal": "0.0"
|
|
4226
|
+
// }
|
|
4227
|
+
//
|
|
4228
|
+
// inverse swap
|
|
4229
|
+
//
|
|
4230
|
+
// {
|
|
4231
|
+
// "symbol": "SOL-USD",
|
|
4232
|
+
// "longLeverage": 5,
|
|
4233
|
+
// "shortLeverage": 5,
|
|
4234
|
+
// "maxLongLeverage": 50,
|
|
4235
|
+
// "maxShortLeverage": 50,
|
|
4236
|
+
// "availableLongVol": "4000000",
|
|
4237
|
+
// "availableShortVol": "4000000"
|
|
4238
|
+
// }
|
|
4239
|
+
//
|
|
3998
4240
|
const marketId = this.safeString(leverage, 'symbol');
|
|
3999
4241
|
return {
|
|
4000
4242
|
'info': leverage,
|
|
@@ -4010,6 +4252,7 @@ export default class bingx extends Exchange {
|
|
|
4010
4252
|
* @name bingx#setLeverage
|
|
4011
4253
|
* @description set the level of leverage for a market
|
|
4012
4254
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Switch%20Leverage
|
|
4255
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Modify%20Leverage
|
|
4013
4256
|
* @param {float} leverage the rate of leverage
|
|
4014
4257
|
* @param {string} symbol unified market symbol
|
|
4015
4258
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -4028,17 +4271,44 @@ export default class bingx extends Exchange {
|
|
|
4028
4271
|
'side': side,
|
|
4029
4272
|
'leverage': leverage,
|
|
4030
4273
|
};
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4274
|
+
if (market['inverse']) {
|
|
4275
|
+
return await this.cswapV1PrivatePostTradeLeverage(this.extend(request, params));
|
|
4276
|
+
//
|
|
4277
|
+
// {
|
|
4278
|
+
// "code": 0,
|
|
4279
|
+
// "msg": "",
|
|
4280
|
+
// "timestamp": 1720725058059,
|
|
4281
|
+
// "data": {
|
|
4282
|
+
// "symbol": "SOL-USD",
|
|
4283
|
+
// "longLeverage": 10,
|
|
4284
|
+
// "shortLeverage": 5,
|
|
4285
|
+
// "maxLongLeverage": 50,
|
|
4286
|
+
// "maxShortLeverage": 50,
|
|
4287
|
+
// "availableLongVol": "4000000",
|
|
4288
|
+
// "availableShortVol": "4000000"
|
|
4289
|
+
// }
|
|
4290
|
+
// }
|
|
4291
|
+
//
|
|
4292
|
+
}
|
|
4293
|
+
else {
|
|
4294
|
+
return await this.swapV2PrivatePostTradeLeverage(this.extend(request, params));
|
|
4295
|
+
//
|
|
4296
|
+
// {
|
|
4297
|
+
// "code": 0,
|
|
4298
|
+
// "msg": "",
|
|
4299
|
+
// "data": {
|
|
4300
|
+
// "leverage": 10,
|
|
4301
|
+
// "symbol": "BTC-USDT",
|
|
4302
|
+
// "availableLongVol": "0.0000",
|
|
4303
|
+
// "availableShortVol": "0.0000",
|
|
4304
|
+
// "availableLongVal": "0.0",
|
|
4305
|
+
// "availableShortVal": "0.0",
|
|
4306
|
+
// "maxPositionLongVal": "0.0",
|
|
4307
|
+
// "maxPositionShortVal": "0.0"
|
|
4308
|
+
// }
|
|
4309
|
+
// }
|
|
4310
|
+
//
|
|
4311
|
+
}
|
|
4042
4312
|
}
|
|
4043
4313
|
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
4044
4314
|
/**
|
|
@@ -4394,62 +4664,71 @@ export default class bingx extends Exchange {
|
|
|
4394
4664
|
* @name bingx#closePosition
|
|
4395
4665
|
* @description closes open positions for a market
|
|
4396
4666
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#One-Click%20Close%20All%20Positions
|
|
4667
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Close%20all%20positions%20in%20bulk
|
|
4397
4668
|
* @param {string} symbol Unified CCXT market symbol
|
|
4398
4669
|
* @param {string} [side] not used by bingx
|
|
4399
4670
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
4400
|
-
* @param {string|undefined} [params.positionId]
|
|
4671
|
+
* @param {string|undefined} [params.positionId] the id of the position you would like to close
|
|
4401
4672
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4402
4673
|
*/
|
|
4403
4674
|
await this.loadMarkets();
|
|
4675
|
+
const market = this.market(symbol);
|
|
4404
4676
|
const positionId = this.safeString(params, 'positionId');
|
|
4405
|
-
|
|
4677
|
+
const request = {};
|
|
4406
4678
|
let response = undefined;
|
|
4407
4679
|
if (positionId !== undefined) {
|
|
4408
|
-
const request = {
|
|
4409
|
-
'positionId': positionId,
|
|
4410
|
-
};
|
|
4411
4680
|
response = await this.swapV1PrivatePostTradeClosePosition(this.extend(request, params));
|
|
4681
|
+
//
|
|
4682
|
+
// {
|
|
4683
|
+
// "code": 0,
|
|
4684
|
+
// "msg": "",
|
|
4685
|
+
// "timestamp": 1710992264190,
|
|
4686
|
+
// "data": {
|
|
4687
|
+
// "orderId": 1770656007907930112,
|
|
4688
|
+
// "positionId": "1751667128353910784",
|
|
4689
|
+
// "symbol": "LTC-USDT",
|
|
4690
|
+
// "side": "Ask",
|
|
4691
|
+
// "type": "MARKET",
|
|
4692
|
+
// "positionSide": "Long",
|
|
4693
|
+
// "origQty": "0.2"
|
|
4694
|
+
// }
|
|
4695
|
+
// }
|
|
4696
|
+
//
|
|
4412
4697
|
}
|
|
4413
4698
|
else {
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4699
|
+
request['symbol'] = market['id'];
|
|
4700
|
+
if (market['inverse']) {
|
|
4701
|
+
response = await this.cswapV1PrivatePostTradeCloseAllPositions(this.extend(request, params));
|
|
4702
|
+
//
|
|
4703
|
+
// {
|
|
4704
|
+
// "code": 0,
|
|
4705
|
+
// "msg": "",
|
|
4706
|
+
// "timestamp": 1720771601428,
|
|
4707
|
+
// "data": {
|
|
4708
|
+
// "success": ["1811673520637231104"],
|
|
4709
|
+
// "failed": null
|
|
4710
|
+
// }
|
|
4711
|
+
// }
|
|
4712
|
+
//
|
|
4713
|
+
}
|
|
4714
|
+
else {
|
|
4715
|
+
response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
|
|
4716
|
+
//
|
|
4717
|
+
// {
|
|
4718
|
+
// "code": 0,
|
|
4719
|
+
// "msg": "",
|
|
4720
|
+
// "data": {
|
|
4721
|
+
// "success": [
|
|
4722
|
+
// 1727686766700486656,
|
|
4723
|
+
// ],
|
|
4724
|
+
// "failed": null
|
|
4725
|
+
// }
|
|
4726
|
+
// }
|
|
4727
|
+
//
|
|
4728
|
+
}
|
|
4419
4729
|
}
|
|
4420
|
-
//
|
|
4421
|
-
// swapV1PrivatePostTradeClosePosition
|
|
4422
|
-
//
|
|
4423
|
-
// {
|
|
4424
|
-
// "code": 0,
|
|
4425
|
-
// "msg": "",
|
|
4426
|
-
// "timestamp": 1710992264190,
|
|
4427
|
-
// "data": {
|
|
4428
|
-
// "orderId": 1770656007907930112,
|
|
4429
|
-
// "positionId": "1751667128353910784",
|
|
4430
|
-
// "symbol": "LTC-USDT",
|
|
4431
|
-
// "side": "Ask",
|
|
4432
|
-
// "type": "MARKET",
|
|
4433
|
-
// "positionSide": "Long",
|
|
4434
|
-
// "origQty": "0.2"
|
|
4435
|
-
// }
|
|
4436
|
-
// }
|
|
4437
|
-
//
|
|
4438
|
-
// swapV2PrivatePostTradeCloseAllPositions
|
|
4439
|
-
//
|
|
4440
|
-
// {
|
|
4441
|
-
// "code": 0,
|
|
4442
|
-
// "msg": "",
|
|
4443
|
-
// "data": {
|
|
4444
|
-
// "success": [
|
|
4445
|
-
// 1727686766700486656,
|
|
4446
|
-
// ],
|
|
4447
|
-
// "failed": null
|
|
4448
|
-
// }
|
|
4449
|
-
// }
|
|
4450
|
-
//
|
|
4451
4730
|
const data = this.safeDict(response, 'data');
|
|
4452
|
-
return this.parseOrder(data);
|
|
4731
|
+
return this.parseOrder(data, market);
|
|
4453
4732
|
}
|
|
4454
4733
|
async closeAllPositions(params = {}) {
|
|
4455
4734
|
/**
|
|
@@ -4457,35 +4736,55 @@ export default class bingx extends Exchange {
|
|
|
4457
4736
|
* @name bitget#closePositions
|
|
4458
4737
|
* @description closes open positions for a market
|
|
4459
4738
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#One-Click%20Close%20All%20Positions
|
|
4460
|
-
* @
|
|
4739
|
+
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Close%20all%20positions%20in%20bulk
|
|
4740
|
+
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
4461
4741
|
* @param {string} [params.recvWindow] request valid time window value
|
|
4462
|
-
* @returns {object[]} [
|
|
4742
|
+
* @returns {object[]} [a list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
4463
4743
|
*/
|
|
4464
4744
|
await this.loadMarkets();
|
|
4465
4745
|
const defaultRecvWindow = this.safeInteger(this.options, 'recvWindow');
|
|
4466
4746
|
const recvWindow = this.safeInteger(this.parseParams, 'recvWindow', defaultRecvWindow);
|
|
4467
4747
|
let marketType = undefined;
|
|
4468
4748
|
[marketType, params] = this.handleMarketTypeAndParams('closeAllPositions', undefined, params);
|
|
4749
|
+
let subType = undefined;
|
|
4750
|
+
[subType, params] = this.handleSubTypeAndParams('closeAllPositions', undefined, params);
|
|
4469
4751
|
if (marketType === 'margin') {
|
|
4470
4752
|
throw new BadRequest(this.id + ' closePositions () cannot be used for ' + marketType + ' markets');
|
|
4471
4753
|
}
|
|
4472
4754
|
const request = {
|
|
4473
4755
|
'recvWindow': recvWindow,
|
|
4474
4756
|
};
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4757
|
+
let response = undefined;
|
|
4758
|
+
if (subType === 'inverse') {
|
|
4759
|
+
response = await this.cswapV1PrivatePostTradeCloseAllPositions(this.extend(request, params));
|
|
4760
|
+
//
|
|
4761
|
+
// {
|
|
4762
|
+
// "code": 0,
|
|
4763
|
+
// "msg": "",
|
|
4764
|
+
// "timestamp": 1720771601428,
|
|
4765
|
+
// "data": {
|
|
4766
|
+
// "success": ["1811673520637231104"],
|
|
4767
|
+
// "failed": null
|
|
4768
|
+
// }
|
|
4769
|
+
// }
|
|
4770
|
+
//
|
|
4771
|
+
}
|
|
4772
|
+
else {
|
|
4773
|
+
response = await this.swapV2PrivatePostTradeCloseAllPositions(this.extend(request, params));
|
|
4774
|
+
//
|
|
4775
|
+
// {
|
|
4776
|
+
// "code": 0,
|
|
4777
|
+
// "msg": "",
|
|
4778
|
+
// "data": {
|
|
4779
|
+
// "success": [
|
|
4780
|
+
// 1727686766700486656,
|
|
4781
|
+
// 1727686767048613888
|
|
4782
|
+
// ],
|
|
4783
|
+
// "failed": null
|
|
4784
|
+
// }
|
|
4785
|
+
// }
|
|
4786
|
+
//
|
|
4787
|
+
}
|
|
4489
4788
|
const data = this.safeDict(response, 'data', {});
|
|
4490
4789
|
const success = this.safeList(data, 'success', []);
|
|
4491
4790
|
const positions = [];
|