You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please put a demo python code for using this version
I used the code that belong to spot api but it didn't work.
I get this response:
{"code":100001,"msg":"","success":false,"timestamp":1674818924644}
This is the code i use:
`
import urllib.request
import json
import base64
import hmac
import time
import json
after all your program has two main problem:
first, "body" hasn't used in "def post"
def post(url, body ):
req = urllib.request.Request(url, ***data=body.encode("utf-8") ******,headers={'User-Agent': 'Mozilla/5.0','X-BX-APIKEY': APIKEY,}, method="POST")
return urllib.request.urlopen(req).read()
and second, How much do you want to BUY?
tradeOrder("BTC-USDT", "BUY", "MARKET", ***QUANTITY)
Please put a demo python code for using this version
I used the code that belong to spot api but it didn't work.
I get this response:
{"code":100001,"msg":"","success":false,"timestamp":1674818924644}
This is the code i use:
`
import urllib.request
import json
import base64
import hmac
import time
import json
APIURL = "https://open-api.bingx.com"
APIKEY = "MyApiKEY"
SECRETKEY = "MySecretKey"
def genSignature(paramsStr):
return hmac.new(SECRETKEY.encode("utf-8"),
paramsStr.encode("utf-8"), digestmod="sha256").digest()
def post(url, body):
req = urllib.request.Request(url, headers={
'User-Agent': 'Mozilla/5.0',
'X-BX-APIKEY': APIKEY,
}, method="POST")
return urllib.request.urlopen(req).read()
def tradeOrder(symbol, side, tradeType):
paramsMap = {
"symbol": symbol,
"side": side,
"type": tradeType,
"timestamp": int(time.time()*1000),
}
paramsStr = "&".join(["%s=%s" % (k, paramsMap[k]) for k in paramsMap])
paramsStr += "&signature=" + genSignature(paramsStr).hex()
url = "%s/openApi/swap/v2/trade/order?%s" % (APIURL, paramsStr)
return post(url, paramsStr)
def main():
tradeOrder("BTC-USDT", "BUY", "MARKET")
if name == "main":
main()
`
The text was updated successfully, but these errors were encountered: