I am trying to create a perpetual limit order using ccxt on okex exchange version 5. The API is successfully placing orders(both limit and market) on spot exchange but not on perpetual exchange. Here is what I am trying -
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)
Error message-
ccxt.base.errors.BadRequest: okex5 {"code":"1","data":[{"clOrdId":"","ordId":"","sCode":"51000","sMsg":"Parameter posSide error ","tag":""}],"msg":""}
After searching about this error I found this in their documentation-
Error message Http status code Error code
Parameter {0} error. 400 51000
Documentation link - Okex v5
P.S - I am able to place this via trading dashboard on okex but not through the API. I have enough balance to create this order.
Entire error message is this-
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":""}