Skip to content

BingX: Full-position TP/SL orders not handled [FIX PROVIDED] #28709

@MaxSxB

Description

@MaxSxB

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.

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions