BingX Api Issue - Limit trades #76996
Unanswered
MatiasGabrielPaz
asked this question in
Programming Help
Replies: 1 comment
|
i get this errot can some one help me { } |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Body
Hello,
My issue is the following:
Every time I try to place a "LIMIT" order (order that has to reach a certain price to be opened), the API instantly opens the order to market without reaching the price I indicate. As if the order was "MARKET" and not "LIMIT".
I did many tests with the code provided in the BINGX documentation both in C# and Python language and the result is the same.
Here is the code I am using in Python:
In this code the LIMIT order is set to be opened when the price touch the price 37400
import time
import requests
import hmac
from hashlib import sha256
APIURL = "https://open-api.bingx.com";
APIKEY = "AAAAAAAAAAAAAA1"
SECRETKEY = "AAAAAAAAAAAAAA2"
def demo():
payload = {}
path = '/openApi/swap/v2/trade/order'
method = "POST"
paramsMap = {
"symbol": "BTC-USDT",
"side": "BUY",
"positionSide": "LONG",
"type": "LIMIT",
"quantity": 5.426701542268578E-05,
"price": 37500,
}
paramsStr = praseParam(paramsMap)
print(paramsStr)
return send_request(method, path, paramsStr, payload)
def get_sign(api_secret, payload):
signature = hmac.new(api_secret.encode("utf-8"), payload.encode("utf-8"), digestmod=sha256).hexdigest()
print("sign=" + signature)
return signature
def send_request(method, path, urlpa, payload):
url = "%s%s?%s&signature=%s" % (APIURL, path, urlpa, get_sign(SECRETKEY, urlpa))
print(url)
headers = {
'X-BX-APIKEY': APIKEY,
}
response = requests.request(method, url, headers=headers, data=payload)
return response.text
def praseParam(paramsMap):
sortedKeys = sorted(paramsMap)
paramsStr = "&".join(["%s=%s" % (x, paramsMap[x]) for x in sortedKeys])
return paramsStr+"×tamp="+str(int(time.time() * 1000))
if name == 'main':
print("demo:", demo())
Guidelines
All reactions