我正在尝试遵循一些对我的python头不太有意义的指令。
我正在尝试发送名为3commas的加密货币API的POST请求: https://github.com/3commas-io/3commas-official-api-docs
他们还通过此pastebin向我发送了一个文档: https://pastebin.com/zFTfwFRG
def send_to_threecomma(signal):
three_comma_signal = {'marketplace_item_id': '100',
'pair': 'BTC_ETH',
'exchange': 'binance',
'direction': 'long',
'data_param': time.time(),
}
request = requests.Request('POST', 'https://3commas.io/signals/v1/publish_bot_signal',
data=three_comma_signal)
prepped = request.prepare()
sign = hmac.new(
b'A STRING OF MY SECRET API KEY',
prepped.body.encode('utf-8'),
hashlib.sha512)
prepped.body += '&sign={}'.format(sign.hexdigest())
with requests.Session() as session:
response = session.send(prepped)
一旦确定签名后,我不确定如何将“符号”放回请求正文中,也不确定hmac应该检查的字符串的确切格式?