python-kucoin
python-kucoin copied to clipboard
[V2] Incorrect keys to place orders
Placing orders does not work for me.
There appear to be some inconsistencies between the code and the API docs (https://docs.kucoin.com/#place-a-new-order)
- The endpoint should be
'/api/v1/orders'
but in the code it is currently'/api/v1/order'
- The body should contain "clientOid" and "size" instead of "orderOid" and "amount", respectively
However, even when doing these changes locally, I get a 401 error with b'{"code":"400005","msg":"Invalid KC-API-SIGN"}'
. There appears to be some other problem elsewhere, but I couldn't find what.
Are you sure you used the right keys and passphrase? You didnt swap your sandbox and normal keys?
I probably chose a bad issue title: "keys" refers to the Python dict keys for the request body, not for the API key.
A strange thing is that other authenticated endpoints worked fine, f.i. /api/v1/accounts
.
Hmm this breaks other stuff for me. I'll be back
File "/media/rasppi/rasppi/Python/bot/kucoin/client.py", line 1329, in get_fills
return self._get('fills', True, data=data)
File "/media/rasppi/rasppi/Python/bot/kucoin/client.py", line 193, in _get
return self._request('get', path, signed, **kwargs)
File "/media/rasppi/rasppi/Python/bot/kucoin/client.py", line 160, in _request
if signed and kwargs['data']:
KeyError: 'data'
I see. I updated it, this error should not happen again.
Hmm the one or two before your last fix did work for my cancel orders but get accounts didn't. Now get accounts works but cancel_all_orders not anymore.
File "<stdin>", line 1, in <module>
File "/media/rasppi/rasppi/Python/bot/kucoin/client.py", line 1095, in cancel_all_orders
return self._delete('orders', True, data=data)
File "/media/rasppi/rasppi/Python/bot/kucoin/client.py", line 202, in _delete
return self._request('delete', path, signed, **kwargs)
File "/media/rasppi/rasppi/Python/bot/kucoin/client.py", line 164, in _request
return self._handle_response(response)
File "/media/rasppi/rasppi/Python/bot/kucoin/client.py", line 174, in _handle_response
raise KucoinAPIException(response)
kucoin.exceptions.KucoinAPIException: KucoinAPIException 400005: Invalid KC-API-SIGN
Are you sure? Both work for me now.
Anyway... Tried another fix, maybe this will do it. Otherwise I'll give up :sweat_smile:
The last fix now works yea! i changed the cancel all so it accepts the optional symbol and without the optional it worked but not with the symbol but your last fix fixed that
Thanks @nielskool and @avaucher v2.1.0 should fix this now.
Works for me, thanks!
Hello, I updated to the latest version but I still can't get create_limit_order() to work. i copied it 100% from the docs and used to get Errorcode: 404000 Url Not Found -- The request resource could not be found
now I keep getting Errorcode: KucoinAPIException 400004: Invalid KC-API-PASSPHRASE
this is my code:
from kucoin.client import Client api_key = "" api_secret = "" api_passphrase = ""
client = Client(api_key, api_secret, api_passphrase)
order = client.create_limit_order('KCS-BTC', Client.SIDE_BUY, '0.000001', '1')
full error log:
C:\Users\Megaport\Desktop\kucoin>python testkucoin.py
Traceback (most recent call last):
File "testkucoin.py", line 19, in
help would be much appreciated, I really need to get this running! other calls to orderbook and currencies etc work just fine
@Fluuuk this function is a private function so you need to be authenticated. You will need to create an api_key, secret and passphrase to initialise the Client before calling create_limit_order
@Fluuuk this function is a private function so you need to be authenticated. You will need to create an api_key, secret and passphrase to initialise the Client before calling
create_limit_order
Thx for the quick reply. Isn't this the part where I initialize my Client and feed it the api_data?
api_key = "" api_secret = "" api_passphrase = ""
client = Client(api_key, api_secret, api_passphrase)
sorry I don't know how to proceed
I added .init to my code, am I doing this right? getting a whole bunch of new errors now
code:
api_key = "" api_secret = "" api_passphrase = ""
client = Client(api_key, api_secret, api_passphrase) client.init(client, api_key, api_secret, api_passphrase)
order = client.create_limit_order('KCS-BTC', Client.SIDE_BUY, '0.000001', '1')
error:
File "testkucoin.py", line 20, in