question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Kucoin ExchangeError

See original GitHub issue

Hello, i have this probllems with Kucoin. Stopped shopping through api.

ССXT version 1.22.44 Python 3.7

My error log:

Traceback (most recent call last):
  File "/app/singlebuy/task/trade.py", line 95, in pre_buy
    balances = exchange.fetchBalance()
  File "/usr/local/lib/python3.7/dist-packages/ccxt/kucoin.py", line 1355, in fetch_balance
    response = self.privateGetAccounts(self.extend(request, params))
  File "/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py", line 440, in inner
    return entry(_self, **inner_kwargs)
  File "/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py", line 463, in request
    return self.fetch2(path, api, method, params, headers, body)
  File "/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py", line 459, in fetch2
    return self.fetch(request['url'], request['method'], request['headers'], request['body'])
  File "/usr/local/lib/python3.7/dist-packages/ccxt/base/exchange.py", line 574, in fetch
    raise ExchangeError(method + ' ' + url)
ccxt.base.errors.ExchangeError: GET https://openapi-v2.kucoin.com/api/v1/accounts

My function:

def pre_buy(self, buytask_id):
	"""Prepare buy: fetch task data, price and balance before"""
	try:
		buy_task = db.session.query(BuyTask.pair.label('pair'), BuyTask.amount.label('amount'),
									Exchange.exchange_id.label('exchange_id'), Exchange.user_id.label('user_id'),
									Exchange.name.label('exchange_name'), Exchange.key.label('key'),
									Exchange.secret.label('secret'), Exchange.password.label('password')).\
			select_from(BuyTask).\
			join(Exchange, BuyTask.exchange_id == Exchange.exchange_id).\
			filter(BuyTask.buytask_id == buytask_id, BuyTask.valid == True, Exchange.valid == True).\
			one()
	except NoResultFound:
		return
	except SQLAlchemyError as e:
		logger.exception('Retrive BuyTask')
		raise self.retry(exc=e)
 
	with Redis.from_url(current_app.config['REDIS_EXCHANGES_TICKER_URI']) as redis:
		tickers = redis.get(buy_task.exchange_name)
	if tickers is None:
		logger.warning('Not have ticker for exchange')
		raise self.retry()
	tickers = json.loads(tickers.decode())
	price = tickers.get(buy_task.pair, None)
	if price is None:
		logger.warning('Not have price for pair')
		raise self.retry()
   
	decoded_secret = fernet.decrypt(buy_task.secret.encode()).decode()  # Tryna decrypt all this stuff
	exchange = getattr(ccxt, buy_task.exchange_name)({'apiKey': buy_task.key,
													  'secret': decoded_secret,
													  'password': buy_task.password})
	try:
		balances = exchange.fetchBalance()
	except ccxt.AuthenticationError:
		invalid_text = 'Authentication error'
		signature('singlebuy.task.invalidate_exchange', app=self.app).delay(buy_task.exchange_id, invalid_text)
		return
	except Exception as e:
		logger.exception('Retrive balance')
		raise self.retry(exc=e)
	quote_name, base_name = buy_task.pair.split('/')
	quote = str(balances.get(quote_name, {}).get('total', 0.0))
	base = str(balances.get(base_name, {}).get('total', 0.0))
	actual_base = buy_task.amount
	signature('singlebuy.task.buy', app=self.app).delay(buytask_id, buy_task.user_id, buy_task.exchange_id,
														buy_task.exchange_name, buy_task.pair,
														buy_task.key, decoded_secret, buy_task.password,
														buy_task.amount, price, quote, base, actual_base)

Please help. Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
rdbrcommented, Dec 30, 2020

Maybe this issue was forgotten because it was closed already? Just a friendly reminder. Thanks! 👍

1reaction
rdbrcommented, Dec 15, 2020

Check out this commit in the Kucoin API docs: https://github.com/Kucoin/kucoin-api-docs/commit/a76cb94a5d2ec93a8a46fb9ab298209263950640 So while CCXT does support v2 of the API, it doesn’t support v2 of the API Key. v2 needs a new header: KC-API-KEY-VERSION

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kucoin down? Current problems and outages - Downdetector
User reports indicate no current problems at Kucoin. Kucoin is a digital asset exchange for trading in cryptocurrencies like Bitcoin and Ethereum.
Read more >
Get 24/7 Customer Service from KuCoin Support Team
Looking for support on KuCoin? Get your problems solved quickly through the help center. Our customer service is available 24/7 all year round....
Read more >
KuCoin Outage—KuCoin Crypto Exchange Suffers Temporary ...
The website of the KuCoin cryptocurrency exchange suffered a temporary outage, with users complaining on social media about being unable to ...
Read more >
Connection with the kucoin exchange - javascript
I am trying to establish a connection with the kucoin exchange through the 'kucoin-api' dependency. But it shows me this error if someone ......
Read more >
Bot stopped on kucoin exchange after error #6374 - GitHub
Describe your environment Operating system: windows Python Version: 3.7.4 (python -V) CCXT version: 1.65.25 (pip freeze | grep ccxt) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found