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

ImportError: cannot import name 'Client' from 'kucoin.client' (/home/pi/venv/lib/python3.9/site-packages/kucoin/client.py)

Open ShoaibZahoor opened this issue 1 year ago • 1 comments

Can any one help me please!

this is the error msg i am getting

(venv) pi@raspberrypi:~/workspace/usdtNAKA $ python3 naka.py Traceback (most recent call last): File "/home/pi/workspace/usdtNAKA/naka.py", line 2, in from kucoin.client import Client ImportError: cannot import name 'Client' from 'kucoin.client' (/home/pi/venv/lib/python3.9/site-packages/kucoin/client.py)

this is the code

import time from kucoin.client import Client from kucoin.ws_token.token import GetToken # You may need to fix this import if necessary from gmail import GMail, Message

Initialize Gmail

gmail = GMail('[email protected]', 'xxxxxxxxxx')

KuCoin API key and secret

api_key = 'xxxxxxxxxxxxxxxx' api_secret = 'xxxxxxxxxxxxxxx' api_passphrase = 'xxxxxxxxx'

Amount to invest per interval

invest = 100

Interval time in hours

interval_time = 24

Initialize KuCoin client

client = Client(api_key, api_secret, api_passphrase)

Rest of the code ............

ShoaibZahoor avatar Aug 19 '23 17:08 ShoaibZahoor

There is no class called Client in kucoin.client. See kucoin/client.py. Try:

import kucoin.client as kcc
print("\n".join(dir(kcc)))  # print a list of module contents

and you'll get User, Trade, Market, Margin, WsToken (and some other things).

Then I use:

# Market:
market = kcc.Market(
    key="012345678901234567890123",
    secret="deadbeef-dead-beef-dead-beefdeadbeef",
    passphrase="super-strong-password",
    is_sandbox=False,
)
ticker = market.get_ticker("SOMETOKEN-USDT")
print(ticker)

day_stats = market.get_24h_stats("SOMETOKEN-USDT")
print(day_stats)

# User
usr = kcc.User(...)  # same kwargs as for Market
acc = usr.get_account_list(account_type="trade")
print(acc)

zannen avatar Jan 18 '24 09:01 zannen

As described by @zannen , please try updating to the latest version of the SDK and modify your code to try again. If you encounter any issues, feel free to provide feedback.

ISAAC-XXYYZZ avatar Jul 29 '24 08:07 ISAAC-XXYYZZ