sammchardy / python-kucoin

Kucoin REST and Websocket API python implementation
https://python-kucoin.readthedocs.io/en/latest/
MIT License
352 stars 148 forks source link

UNAUTH: Signature Verification Failed #8

Closed ghost closed 6 years ago

ghost commented 6 years ago

Thank you for writing this package, it's great.

I am running into an issue when trying to use certain order cancellation functions. Cancel_all_orders alone works well.

I run into issues when adding a symbol parameter to the function (ie. 'NULS-ETH') or when using the cancel_order function.

Traceback (most recent call last):
  File "C:/Users/tyler/Google Drive/Crypto/python/kucoin_order.py", line 52, in <module>
    client.cancel_all_orders(symbol=buy_pair)
  File "C:\Python27\lib\site-packages\kucoin\client.py", line 1295, in cancel_all_orders
    return self._post(path, True, data=data)
  File "C:\Python27\lib\site-packages\kucoin\client.py", line 171, in _post
    return self._request('post', path, signed, **kwargs)
  File "C:\Python27\lib\site-packages\kucoin\client.py", line 138, in _request
    return self._handle_response(response)
  File "C:\Python27\lib\site-packages\kucoin\client.py", line 147, in _handle_response
    raise KucoinAPIException(response)
kucoin.exceptions.KucoinAPIException: KucoinAPIException UNAUTH: Signature verification failed
sammchardy commented 6 years ago

Hi @tcollins590 just checking are you using the latest version v0.1.6?

ghost commented 6 years ago

@sammchardy Looks like I am using 0.1.6

ghost commented 6 years ago

Also using python 2.7

mcgalvao commented 6 years ago

Same issue here. Btw, thanks for the great work!!

sammchardy commented 6 years ago

It's strange, those calls keep changing their details on me. As far as I can tell I have them implemented how they should be.

https://kucoinapidocs.docs.apiary.io/#reference/0/trading/cancel-orders https://kucoinapidocs.docs.apiary.io/#reference/0/trading/cancel-all-orders

So just to confirm cancel_all_orders works without a symbol. If you check their docs it seems to indicate symbol is required.

For cancel_order I do have symbol as required, but think I need to change it as all I really feel needs to be passed for this called would be the orderOid, let me make a branch with that option for you to test.

I'm trying to get some clarification from the Kucoin devs around it, but they reply when they feel like it, to questions they feel like answering.

ghost commented 6 years ago

Thank you for looking into this.

Yeah when i run cancel_all_order alone it works fine. When I add a symbol I get the error.

For cancel_order I am passing the 3 arguments symbol, orderOid, type. Getting the error with that.

sammchardy commented 6 years ago

Testing it locally cancel_order returns Not Found if symbol not passed, and then Signature verification failed once you add symbol in.

They are the only calls that use query string parameters and the signature generation doesn't say what to do with those, I'd say that may be the issue.

Would definitely encourage both of you to email product@kucoin.com about this, see if we can get a resolution.

mcgalvao commented 6 years ago

I managed to get the cancel_all_orders(symbol) to work. Just had to send the symbol parameter along with the order_type. I don't have time to try the other cancel methods right now, but I believe the same fix should work.

My cancel_all_orders method: ` def cancel_all_orders(self, symbol=None, order_type=None): """Cancel all orders

    https://kucoinapidocs.docs.apiary.io/#reference/0/trading/cancel-all-orders

    :param symbol: Name of symbol e.g. KCS-BTC
    :type symbol: string
    :param order_type: Order type
    :type order_type: string

    .. code:: python

        # cancel all active orders
        client.cancel_all_orders()

        # cancel all KCS-BTC Buy orders
        client.cancel_all_orders('KCS-BTC', 'BUY')

    :returns: None

    :raises: KucoinResponseException, KucoinAPIException

    """

    data = {}
    if order_type:
        data['type'] = order_type

    path = 'order/cancel-all'
    if symbol:
        data['symbol'] = symbol

    return self._post(path, True, data=data)` 
sammchardy commented 6 years ago

Ok, I've pushed v0.1.7 to fix the cancel_order and cancel_all_order functions. Thanks for your help.