Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SL/TP doesn't return in response of order query #8

Open
rikhtehgaran opened this issue Mar 5, 2024 · 0 comments
Open

SL/TP doesn't return in response of order query #8

rikhtehgaran opened this issue Mar 5, 2024 · 0 comments

Comments

@rikhtehgaran
Copy link

Hi I'm using this code to query orders. i have set TP on my limit order but it doesn't return in order response

import json
import time
import requests
import hmac
from hashlib import sha256

APIURL = "https://open-api-vst.bingx.com"
APIKEY = "----"
SECRETKEY = "----"

def demo():
    payload = {}
    path = '/openApi/swap/v2/trade/openOrders'
    method = "GET"
    paramsMap = {
    "symbol": "BTC-USDT",
    "timestamp": str(int(time.time() * 1000))
    }
    paramsStr = parseParam(paramsMap)
    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 parseParam(paramsMap):
    sortedKeys = sorted(paramsMap)
    paramsStr = "&".join(["%s=%s" % (x, paramsMap[x]) for x in sortedKeys])
    if paramsStr != "":
     return paramsStr+"&timestamp="+str(int(time.time() * 1000))
    else:
     return paramsStr+"timestamp="+str(int(time.time() * 1000))

if __name__ == '__main__':
    demo = json.loads(demo())
    print("demo:", demo)

Response is:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant