sammchardy / python-kucoin

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

Missing get all tickers #45

Open nielskool opened 5 years ago

nielskool commented 5 years ago

The function get_ticker has the optional variable symbol but doesnt work when symbol is not set.

def get_ticker(self, symbol):
data = {
            'symbol': symbol
        }
        return self._get('market/orderbook/level1', False, data=data)

might chance to:??

def get_ticker(self, symbol=None):
    if symbol:
        data = {
            'symbol': symbol
        }

        return self._get('market/orderbook/level1', False, data=data)
    else:
        return self._get('market/allTickers', False)

source: https://docs.kucoin.com/#get-ticker

sammchardy commented 5 years ago

Thanks for your help @nielskool can you check if this is now fixed in v2.1.0

nielskool commented 5 years ago

it is now always at market/allTickers but that is only the case when symbol=None.

so move tick_path = 'market/allTickers' into the if and else: tick_path = 'market/orderbook/level1'

LeKlex commented 5 years ago

it is now always at market/allTickers but that is only the case when symbol=None.

so move tick_path = 'market/allTickers' into the if and else: tick_path = 'market/orderbook/level1'

I can confirm this. For a quick fix, i changed the client library to:

data = {}
tick_path = 'market/allTickers'
if symbol is not None:
    tick_path = 'market/orderbook/level1'
    data = {
        'symbol': symbol
    }
    return self._get(tick_path, False, data=data)
AndrewFarley commented 5 years ago

This issue is still existing, the patch from LeKlex works, I'm going to submit a pull request so this functionality is no longer broken. PR incoming...

AndrewFarley commented 5 years ago

It looks like someone else tried to fix it, but missed a line and made the opposite functionality broken (aka, made #54 happen again). The PR above should fix it, blatantly copied from @LeKlex above, so no credit for me really.