BingX has a "closePosition" param that is currently not handled by CCXT. I added a param parsing to see if the closePosition bool is true. If yes, no quantity is provided. The result is a TP/SL order closing the whole position whater the size is. Goal: being able to place both a full-position TP/SL and partial TP/SLs.
diff --git a/core/ccxt/ccxt/async_support/bingx.py b/core/ccxt/ccxt/async_support/bingx.py
index f623da6..536eb9d 100644
--- a/core/ccxt/ccxt/async_support/bingx.py
+++ b/core/ccxt/ccxt/async_support/bingx.py
@@ -3095,10 +3095,12 @@ class bingx(Exchange, ImplicitAPI):
else:
positionSide = 'BOTH'
request['positionSide'] = positionSide
- amountReq = amount
- if not market['inverse']:
- amountReq = self.parse_to_numeric(self.amount_to_precision(symbol, amount))
- request['quantity'] = amountReq # precision not available for inverse contracts
+ closePosition = self.safe_bool(params, 'closePosition', False)
+ if not closePosition:
+ amountReq = amount
+ if not market['inverse']:
+ amountReq = self.parse_to_numeric(self.amount_to_precision(symbol, amount))
+ request['quantity'] = amountReq # precision not available for inverse contracts
params = self.omit(params, ['hedged', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingType', 'takeProfit', 'stopLoss', 'clientOrderId'])
return self.extend(request, params)
(I run a local edited CCXT version, so don't trust the line numbers of that diff)
Operating System
Windows 11
Programming Language
Python
CCXT Version
No response
Description
https://bingx-api.github.io/docs-v3/#/en/Swap/Trades%20Endpoints/Place%20order
BingX has a "closePosition" param that is currently not handled by CCXT. I added a param parsing to see if the closePosition bool is true. If yes, no quantity is provided. The result is a TP/SL order closing the whole position whater the size is. Goal: being able to place both a full-position TP/SL and partial TP/SLs.
(I run a local edited CCXT version, so don't trust the line numbers of that diff)