-
Notifications
You must be signed in to change notification settings - Fork 23
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
is it possible to open position on Perpetual Futures with VST token? #26
Comments
Hi
For VST you can use open-api-vst.bingx.com<http://open-api-vst.bingx.com> domain
From: ***@***.***>
Date: Wed, Feb 14, 2024, 16:01
Subject: [BingX-API/BingX-swap-api-doc] is it possible to open position on Perpetual Futures with VST token? (Issue #26)
To: ***@***.***>
Cc: ***@***.***>
Hi, I want to open a position to test a bot on a demo account using VST token on Perpetual Futures market. is it possible to that with API?
Something like this:
defdemo():
payload= {}
path='/openApi/swap/v2/trade/order'method="POST"paramsMap= {
"symbol": "BTC-USDT",
"side": "BUY",
"positionSide": "LONG",
"type": "MARKET",
"quantity": 0.5
}
paramsStr=praseParam(paramsMap)
returnsend_request(method, path, paramsStr, payload)
defget_sign(api_secret, payload):
signature=hmac.new(api_secret.encode("utf-8"), payload.encode("utf-8"), digestmod=sha256).hexdigest()
print("sign="+signature)
returnsignaturedefsend_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)
returnresponse.textdefpraseParam(paramsMap):
sortedKeys=sorted(paramsMap)
paramsStr="&".join(["%s=%s"% (x, paramsMap[x]) forxinsortedKeys])
returnparamsStr+"×tamp="+str(int(time.time() *1000))
if__name__=='__main__':
demo=demo()
print("demo:",demo )
… —
Reply to this email directly, view it on GitHub<#26>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BFJFFAV4RKAILP7BPDGS4PDYTRVN5AVCNFSM6AAAAABDH2GSUGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGEZTGNZWGY4DGMY>.
You are receiving this because you are subscribed to this thread.[image: https://github.com/notifications/beacon/BFJFFAUJMJVK4YEFSYKYBF3YTRVN5A5CNFSM6AAAAABDH2GSUGWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHH6LVSWE.gif]Message ID: ***@***.***>
|
Hi I did it i tried this code as you said: APIURL = "http://open-api-vst.bingx.com"
def demo():
payload = {}
path = '/openApi/swap/v2/trade/order'
method = "POST"
paramsMap = {
"symbol": "BTC-USDT",
"side": "BUY",
"positionSide": "LONG",
"type": "MARKET",
"quantity": 0.5,
}
paramsStr = praseParam(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 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__':
demo=demo()
print("demo:",demo ) And I get this error:
Maybe it's better to update documents because I copy paste example code from there so I changed demo() method to below and append clientOrderID with real unique id: def demo():
payload = {}
path = '/openApi/swap/v2/trade/order'
method = "POST"
paramsMap = {
"symbol": "BTC-USDT",
"side": "BUY",
"positionSide": "LONG",
"type": "MARKET",
"quantity": 0.5,
"clientOrderID": str(uuid.uuid4())
} So my code changed to this: APIURL = "http://open-api-vst.bingx.com"
def demo():
payload = {}
path = '/openApi/swap/v2/trade/order'
method = "POST"
paramsMap = {
"symbol": "BTC-USDT",
"side": "BUY",
"positionSide": "LONG",
"type": "MARKET",
"quantity": 0.5,
"clientOrderID": str(uuid.uuid4())
}
paramsStr = praseParam(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 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__':
demo=demo()
print("demo:",demo ) But I got this error:
|
Hi
May i have your UID ?
From: ***@***.***>
Date: Fri, Feb 16, 2024, 13:44
Subject: Re: [BingX-API/BingX-swap-api-doc] is it possible to open position on Perpetual Futures with VST token? (Issue #26)
To: ***@***.***>
Cc: ***@***.***>, ***@***.***>
Hi I did it i tried this code as you said:
APIURL="http://open-api-vst.bingx.com"defdemo():
payload= {}
path='/openApi/swap/v2/trade/order'method="POST"paramsMap= {
"symbol": "BTC-USDT",
"side": "BUY",
"positionSide": "LONG",
"type": "MARKET",
"quantity": 0.5,
}
paramsStr=praseParam(paramsMap)
returnsend_request(method, path, paramsStr, payload)
defget_sign(api_secret, payload):
signature=hmac.new(api_secret.encode("utf-8"), payload.encode("utf-8"), digestmod=sha256).hexdigest()
print("sign="+signature)
returnsignaturedefsend_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)
returnresponse.textdefpraseParam(paramsMap):
sortedKeys=sorted(paramsMap)
paramsStr="&".join(["%s=%s"% (x, paramsMap[x]) forxinsortedKeys])
returnparamsStr+"×tamp="+str(int(time.time() *1000))
if__name__=='__main__':
demo=demo()
print("demo:",demo )
And I get this error:
> demo: {"code":80014,"msg":"Invalid parameters, err: Cannot have both orderId and clientOrderID fields empty,one must be filled in","data":{}}
Maybe it's better to update documents because I copy paste example code from there so I changed demo() method to below and append clientOrderID with real unique id:
defdemo():
payload= {}
path='/openApi/swap/v2/trade/order'method="POST"paramsMap= {
"symbol": "BTC-USDT",
"side": "BUY",
"positionSide": "LONG",
"type": "MARKET",
"quantity": 0.5,
"clientOrderID": str(uuid.uuid4())
}
So my code changed to this:
APIURL="http://open-api-vst.bingx.com"defdemo():
payload= {}
path='/openApi/swap/v2/trade/order'method="POST"paramsMap= {
"symbol": "BTC-USDT",
"side": "BUY",
"positionSide": "LONG",
"type": "MARKET",
"quantity": 0.5,
"clientOrderID": str(uuid.uuid4())
}
paramsStr=praseParam(paramsMap)
returnsend_request(method, path, paramsStr, payload)
defget_sign(api_secret, payload):
signature=hmac.new(api_secret.encode("utf-8"), payload.encode("utf-8"), digestmod=sha256).hexdigest()
print("sign="+signature)
returnsignaturedefsend_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)
returnresponse.textdefpraseParam(paramsMap):
sortedKeys=sorted(paramsMap)
paramsStr="&".join(["%s=%s"% (x, paramsMap[x]) forxinsortedKeys])
returnparamsStr+"×tamp="+str(int(time.time() *1000))
if__name__=='__main__':
demo=demo()
print("demo:",demo )
… But I got this error:
> demo: {"code":80016,"msg":"order not exist","data":{}}
—
Reply to this email directly, view it on GitHub<#26 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BFJFFATYDMHF6V34CM7IXTDYT3W5LAVCNFSM6AAAAABDH2GSUGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBXG44TIMJYHE>.
You are receiving this because you commented.[image: https://github.com/notifications/beacon/BFJFFAW2ODOYDCUHXQ6VNKDYT3W5LA5CNFSM6AAAAABDH2GSUGWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTUDD5Q2.gif]Message ID: ***@***.***>
|
18257026 |
Any update? |
Hi
I saw you did the request by method:GET?
Not POST
… From: ***@***.***>
Date: Sun, Feb 18, 2024, 14:26
Subject: Re: [BingX-API/BingX-swap-api-doc] is it possible to open position on Perpetual Futures with VST token? (Issue #26)
To: ***@***.***>
Cc: ***@***.***>, ***@***.***>
Any update?
—
Reply to this email directly, view it on GitHub<#26 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BFJFFARJSUOITIQHKOCXIR3YUGNKJAVCNFSM6AAAAABDH2GSUGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJQHE3TONBUGE>.
You are receiving this because you commented.[image: https://github.com/notifications/beacon/BFJFFASF6G644ZXXSIWLVM3YUGNKJA5CNFSM6AAAAABDH2GSUGWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTUJGG2C.gif]Message ID: ***@***.***>
|
I just run the example code and the code you give it to me as you can see in my code the method is POST APIURL = "http://open-api-vst.bingx.com"
def demo():
payload = {}
path = '/openApi/swap/v2/trade/order'
method = "POST" # HEEEEERREEEEE
paramsMap = {
"symbol": "BTC-USDT",
"side": "BUY",
"positionSide": "LONG",
"type": "MARKET",
"quantity": 0.5,
"clientOrderID": str(uuid.uuid4())
}
paramsStr = praseParam(paramsMap)
return send_request(method, path, paramsStr, payload) |
Hi, I want to open a position to test a bot on a demo account using VST token on Perpetual Futures market. is it possible to that with API?
Something like this:
The text was updated successfully, but these errors were encountered: