ccxt icon indicating copy to clipboard operation
ccxt copied to clipboard

Order side invalid error on Kucoin

Open duncanmcl opened this issue 1 year ago • 3 comments

Operating System

Windows

Programming Languages

Python

CCXT Version

4.3.42

Description

I am getting {"msg":"Order side invalid.","code":"400100"} errors on kucoin. They started yesterday. I could not find this error code in the documentation. How can I fix it? Is there a problem in ccxt?

The failing code is : exchange.createLimitOrder(symbol, trade_type, trade_amount, limit_price)

The output of verbose for the failing code is as follows:

fetch Request: kucoin POST https://api.kucoin.com/api/v1/orders RequestHeaders: {'KC-API-KEY-VERSION': '2', 'KC-API-KEY': 'secret', 'KC-API-TIMESTAMP': 'secret', 'Content-Type': 'application/json', 'KC-API-PASSPHRASE': 'secret', 'KC-API-SIGN': 'secret', 'KC-API-PARTNER-SIGN': 'secret', 'KC-API-PARTNER': 'ccxt', 'KC-API-PARTNER-VERIFY': 'true', 'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '/', 'Connection': 'keep-alive'} RequestBody: {"clientOid":"22b232b5-26d4-4a22-a3e7-34c3ae82638f","side":"SELL","symbol":"ENA-USDT","type":"limit","size":"79.32","price":"0.4096"}

fetch Response: kucoin POST https://api.kucoin.com/api/v1/orders 200 ResponseHeaders: {'Date': 'Mon, 10 Jun 2024 03:31:12 GMT', 'Content-Type': 'application/json', 'Content-Length': '45', 'Connection': 'keep-alive', 'Set-Cookie': 'secret; Expires=Mon, 17 Jun 2024 03:31:12 GMT; Path=/, secret; Expires=Mon, 17 Jun 2024 03:31:12 GMT; Path=/; SameSite=None; Secure, __cf_bm=4_8.xCaZ55jxMzhDG5wLQYKuq9mGeHSV4wz.2Mt1fX0-1717990272-1.0.1.1-Qcbpykg8yHxEZIdGsxfz9QSUpe9pIxBQwvqfM9aRcbRjKyjkh5Z_XQkc8vs3U.dBc_WynbojotGwARbG0Oc1BA; path=/; expires=Mon, 10-Jun-24 04:01:12 GMT; domain=.kucoin.com; HttpOnly; Secure; SameSite=None, _cfuvid=lOx8v8SH3t8v5Vv72keJWXZOX_E64TYIBc8olZGk5M8-1717990272340-0.0.1.1-604800000; path=/; domain=.kucoin.com; HttpOnly; Secure; SameSite=None', 'gw-ratelimit-remaining': '3998', 'gw-ratelimit-limit': '4000', 'gw-ratelimit-reset': '29992', 'Strict-Transport-Security': 'max-age=9800; includeSubDomains; preload', 'CF-Cache-Status': 'DYNAMIC', 'Server': 'cloudflare', 'CF-RAY': '89164981de01965a-KIX'} ResponseBody: {"msg":"Order side invalid.","code":"400100"}

Code

  

duncanmcl avatar Jun 10 '24 03:06 duncanmcl

@duncanmcl It works for me. Have you checked your balance?

kucoin.createLimitOrder (ENA/USDT, SELL, 1, 1.5)
fetch Request:
 kucoin POST https://api.kucoin.com/api/v1/orders 
RequestHeaders:
 {
} 
RequestBody:
 {"clientOid":"7a89c940-a7b1-49eb-9c57-91f0a5be3999","side":"SELL","symbol":"ENA-USDT","type":"limit","size":"1","price":"1.5"} 

handleRestResponse:
 kucoin POST https://api.kucoin.com/api/v1/orders 200 OK 
ResponseHeaders:
 {
} 
ResponseBody:
 {"code":"200000","data":{"orderId":"6666955670ad3800070e559f"}} 

{
  info: { orderId: '6666955670ad3800070e559f' },
  id: '6666955670ad3800070e559f',
  symbol: 'ENA/USDT',
  fee: {},
  trades: [],
  fees: [ {} ]
}

sc0Vu avatar Jun 10 '24 05:06 sc0Vu

I found the reason. It looks like SELL command became case sensitive in Kucoin (at least for me).

This python code is giving error {"msg":"Order side invalid.","code":"400100"}:

response = exchange.createLimitOrder("ENA/USDT", "SELL",1,1.5)

Verbose output of the uppercase "SELL" code is:

RequestBody: {"clientOid":"2624adef-cbde-4caa-9bbc-27a30496cf58","side":"SELL","symbol":"ENA-USDT","type":"limit","size":"1","price":"1.5"}

However, this code is working:

response = exchange.createLimitOrder("ENA/USDT", "sell",1,1.5)

Verbose output of the lower case "sell" code is

RequestBody: {"clientOid":"7ee965cd-803c-4e4f-a2eb-6fb8b98a853a","side":"sell","symbol":"ENA-USDT","type":"limit","size":"1","price":"1.5"}

Uppercase SELL command was also working until this Sunday on Kucoin. I did not change anthing in the code, but the command stopped working on Sunday. Maybe, the api server that serves my account has been updated with new software.

duncanmcl avatar Jun 11 '24 18:06 duncanmcl

I found the reason. It looks like SELL command became case sensitive in Kucoin (at least for me).

This python code is giving error {"msg":"Order side invalid.","code":"400100"}:

response = exchange.createLimitOrder("ENA/USDT", "SELL",1,1.5)

Verbose output of the uppercase "SELL" code is:

RequestBody: {"clientOid":"2624adef-cbde-4caa-9bbc-27a30496cf58","side":"SELL","symbol":"ENA-USDT","type":"limit","size":"1","price":"1.5"}

However, this code is working:

response = exchange.createLimitOrder("ENA/USDT", "sell",1,1.5)

Verbose output of the lower case "sell" code is

RequestBody: {"clientOid":"7ee965cd-803c-4e4f-a2eb-6fb8b98a853a","side":"sell","symbol":"ENA-USDT","type":"limit","size":"1","price":"1.5"}

Uppercase SELL command was also working until this Sunday on Kucoin. I did not change anthing in the code, but the command stopped working on Sunday. Maybe, the api server that serves my account has been updated with new software.

It's worked and solve my problem in node.js too, thanks

timursevimli avatar Jun 20 '24 00:06 timursevimli

@duncanmcl It looks like the side should be either sell or buy according to their documentation (https://www.kucoin.com/docs/rest/spot-trading/orders/place-order).

Now it works for both uppercase and lowercase.

sc0Vu avatar Aug 14 '24 11:08 sc0Vu