import requests
import time
import hashlib
import hmac
import json
apikey = 'your_api_key'
secret = 'your_api_secret'
nonce = str(int(time.time() * 1000))
uri = 'https://api.bittrex.com/v3/orders'
content_hash = hashlib.sha512(b'').hexdigest()
# The optional parameter for your request
parameter = {
'marketSymbol': 'BTC-USDT',
'direction': 'BUY',
'type': 'LIMIT',
'quantity': 1.0,
'limit': 30000.0,
'timeInForce': 'GOOD_TIL_CANCELLED',
'clientOrderId': None,
'useAwards': False
}
json_body = json.dumps(parameter)
signature = hmac.new(secret.encode(), (uri + nonce + json_body + content_hash).encode(), hashlib.sha512).hexdigest()
headers = {
'Api-Key': apikey,
'Api-Timestamp': nonce,
'Api-Content-Hash': content_hash,
'Api-Signature': signature
}
response = requests.post(uri, data=json_body, headers=headers)
如果上面的代码没有返回“Invalid signature”,则可以尝试使用类似的代码来解决问题。