Python龙卷风发布请求错误

时间:2018-02-14 15:43:44

标签: python rest post tornado

我正在尝试构建一个交易机器人,为此我发送了以下帖子请求:

def binanceOrder(symbol, amount, price, buyorsell, orderType):
# curl -H "X-MBX-APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A" -X POST 'https://api.binance.com/api/v3/order?symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559&signature=c8db56825ae71d6d79447849e617115f4a920fa2acdcab2b053c4b2838bd6b71'
body = {
   "timestamp": int(time.mktime(datetime.datetime.today().timetuple())),
   "symbol": symbol,         #'BTCUSD',
   "quantity": amount,
   "price": price,  # Use random number for market orders.
   # exchange: 'bitfinex',
   "side": buyorsell,
   "type": orderType, # LIMIT
   # ocoorder: 'false'
   "timeInForce": "GTC",
   "recvWindow": 10000,
   "signature": BINANCE_SIGNATURE
}

headers = {
    'Content-Type': 'multipart/form-data',
    "X-MBX-APIKEY": BINANCE_API_KEY
}

http_client.fetch("https://api.binance.com/api/v3/order", binanceOrderResponse, method='POST', headers=urllib.urlencode(headers), body=urllib.urlencode(body))
if __name__ == "__main__":
    binanceOrder("LTCUSD", 1, 0, "buy", "MARKET")

为此我收到以下错误:

    traceback (most recent call last):
  File "asyncbot.py", line 263, in <module>
    binanceOrder("LTCUSD", 1, 0, "buy", "MARKET")
  File "asyncbot.py", line 67, in binanceOrder
    http_client.fetch("https://api.binance.com/api/v3/order", binanceOrderResponse, method='POST', headers=urllib.urlencode(headers), body=urllib.urlencode(body))
  File "/Users/adityasista/anaconda/envs/trading-bot/lib/python2.7/site-packages/tornado/httpclient.py", line 236, in fetch
    request.headers = httputil.HTTPHeaders(request.headers)
  File "/Users/adityasista/anaconda/envs/trading-bot/lib/python2.7/site-packages/tornado/httputil.py", line 145, in __init__
    self.update(*args, **kwargs)
  File "/Users/adityasista/anaconda/envs/trading-bot/lib/python2.7/_abcoll.py", line 571, in update
    for key, value in other:
ValueError: need more than 1 value to unpack

我在这里做错了什么?

0 个答案:

没有答案