1

我正在尝试在 okex 交易所版本 5 上使用 ccxt 创建一个永久限价订单。该 API 已成功在现货交易所下订单(限价和市场订单),但不是在永续交易上。这是我正在尝试的 -

exchange_swap = ccxt.okex5({
'apiKey': credentials['okex']['apikey'],
'secret': credentials['okex']['secretkey'],
'password': credentials['okex']['password'],
'options': {
    'defaultType': 'swap', 
      }
})
params =  {
   "test":True
}
order = exchange_swap.createLimitBuyOrder('XRP-USDT-SWAP',100,0.7)

错误信息-

ccxt.base.errors.BadRequest: okex5 {"code":"1","data":[{"clOrdId":"","ordId":"","sCode":"51000","sMsg":"Parameter posSide  error ","tag":""}],"msg":""}

在搜索了这个错误之后,我在他们的文档中发现了这个 -

Error message           Http status code     Error code
Parameter {0} error.    400                  51000

文档链接 - Okex v5

PS - 我可以通过 okex 上的交易仪表板而不是通过 API 来放置它。我有足够的余额来创建这个订单。

整个错误信息是这样的——

Traceback (most recent call last):
File "C:\Users\ishaa\Desktop\trading\Crypto Vibhor\Testing Files\ccxt_test.py", line 70, in 
 <module>
  order = exchange_swap.createLimitBuyOrder('XRP-USDT-SWAP',100,0.7)
  File "C:\Users\ishaa\Desktop\trading\tradingenv\lib\site-packages\ccxt\base\exchange.py", line 1983, in create_limit_buy_order
return self.create_order(symbol, 'limit', 'buy', amount, price, params)
 File "C:\Users\ishaa\Desktop\trading\tradingenv\lib\site-packages\ccxt\okex5.py", line 1287, in create_order
response = self.privatePostTradeOrder(self.extend(request, params))
File "C:\Users\ishaa\Desktop\trading\tradingenv\lib\site-packages\ccxt\base\exchange.py", line 461, in inner
return entry(_self, **inner_kwargs)
File "C:\Users\ishaa\Desktop\trading\tradingenv\lib\site-packages\ccxt\base\exchange.py", line 
 486, in request
  return self.fetch2(path, api, method, params, headers, body)
  File "C:\Users\ishaa\Desktop\trading\tradingenv\lib\site-packages\ccxt\base\exchange.py", line 482, in fetch2
  return self.fetch(request['url'], request['method'], request['headers'], request['body'])
  File "C:\Users\ishaa\Desktop\trading\tradingenv\lib\site-packages\ccxt\base\exchange.py", line 634, in fetch
  self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
  File "C:\Users\ishaa\Desktop\trading\tradingenv\lib\site-packages\ccxt\okex5.py", line 2230, in handle_errors
  self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, feedback)
  File "C:\Users\ishaa\Desktop\trading\tradingenv\lib\site-packages\ccxt\base\exchange.py", line 500, in throw_exactly_matched_exception
   raise exact[string](message)
   ccxt.base.errors.BadRequest: okex5 {"code":"1","data": 
   [{"clOrdId":"","ordId":"","sCode":"51000","sMsg":"Parameter posSide  error 
    ","tag":""}],"msg":""}
4

0 回答 0