尽管有很多关于Poloniex/Python交易api访问的帖子,但我仍然不知道如何在python3.6上实现这一点。在我看来,有一个版本应该说得很完美,但却没有:
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/机密代码运行上面的代码,就会得到一个“无效命令”错误。在
有趣的是,如果我把请求.post具有以下功能:
^{pr2}$然后我没有得到错误,只得到一个空的字节数组(在res.读取())
任何关于如何使这项工作的建议将不胜感激。在
解决方案包括:
在页眉中,即:
^{pr2}$奇怪的是,我所看到的其他解决方案都没有包含这个额外的字段,但是我们开始了。在
另一种用法urllib.请求仍然只返回一个空字节字符串。在
相关问题 更多 >
编程相关推荐