Kucoin / kucoin-python-sdk

MIT License
40 stars 11 forks source link

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

Open ShoaibZahoor opened 11 months ago

ShoaibZahoor commented 11 months ago

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('my@gmail.com', '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 ............

zannen commented 6 months ago

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)