1
尽管有关Poloniex/Python交易API访问的帖子数量,我仍然无法弄清楚如何使Python 3.6的这项工作。这里是一个版本,它在我看来,这个词应该完美,但并不:Python - Poloniex交易API问题
req['command'] = 'requestBalances'
req['nonce'] = int(time.time() * 1000)
post_data = urllib.parse.urlencode(req).encode('utf-8')
hmac_key = self.Secret.encode('utf-8')
sign = hmac.new(hmac_key, post_data, hashlib.sha512)
sign = sign.hexdigest()
headers = {
'Sign': sign,
'Key': self.APIKey
}
res = requests.post('https://poloniex.com/tradingApi', data=post_data, headers=headers)
如果我运行上面,用正确的API /暗号,我得到一个“无效的命令”的错误。
有趣的是,如果我替换requests.post功能:
req = urllib.request.Request(url='https://poloniex.com/tradingApi', data=post_data, headers=headers)
res = urllib.request.urlopen(req,timeout=5)
然后我没有得到一个错误,但只是一个空字节数组(res.read后())
任何提示如何使这项工作将不胜感激。
您能分享您收到的完整回溯吗? – etemple1
通过纯粹的运气,我设法找到了解决方案。请参阅下面的答案 –