python-kucoin icon indicating copy to clipboard operation
python-kucoin copied to clipboard

Missing get all tickers

Open nielskool opened this issue 6 years ago • 5 comments

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

nielskool avatar Feb 23 '19 17:02 nielskool

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

sammchardy avatar Feb 25 '19 11:02 sammchardy

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'

nielskool avatar Mar 09 '19 22:03 nielskool

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)

LeKlex avatar Mar 13 '19 13:03 LeKlex

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 avatar Apr 17 '19 00:04 AndrewFarley

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.

AndrewFarley avatar Apr 17 '19 00:04 AndrewFarley