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.

Yobit fetch_balance()

See original GitHub issue

Hi, with this code

yobit = ccxt.yobit({
    'apiKey': xx
    'secret': xx
    'verbose': True,
})
yobit.fetch_balance()

I am seeing this KeyError

C:\Users\Administrator\AppData\Local\Programs\Python\Python36\python.exe C:/Users/Administrator/PycharmProjects/ccxt/bal_test.py
https://yobit.net/api/3/info GET https://yobit.net/api/3/info 
Request: {'User-Agent': 'ccxt/1.9.162 (+https://github.com/ccxt-dev/ccxt) Python/3.6.3', 'Accept-Encoding': 'gzip, deflate'} None
GET https://yobit.net/api/3/info 
Response: Date: Tue, 17 Oct 2017 13:22:19 GMT
Content-Type: text/html; charset=utf8
Transfer-Encoding: chunked
Connection: close
Set-Cookie: __cfduid=d178935b912903a9d0d99c4ac0048833b1508246539; expires=Wed, 17-Oct-18 13:22:19 GMT; path=/; domain=.yobit.net; HttpOnly
Set-Cookie: locale=en; expires=Sun, 17-Oct-2027 13:22:19 GMT; path=/
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block;
x-download-options: noopen
Server: cloudflare-nginx
CF-RAY: 3af390e57b506abb-LHR
Content-Encoding: gzip

https://yobit.net/tapi POST https://yobit.net/tapi 
Request: {'Content-Type': 'application/x-www-form-urlencoded', 'Key':x , 'Sign'x: , 'User-Agent': 'ccxt/1.9.162 (+https://github.com/ccxt-dev/ccxt) Python/3.6.3', 'Accept-Encoding': 'gzip, deflate'} nonce=1508246537&method=getInfo
POST https://yobit.net/tapi 
Response: Date: Tue, 17 Oct 2017 13:22:20 GMT
Content-Type: text/html; charset=utf8
Transfer-Encoding: chunked
Connection: close
Set-Cookie: __cfduid=d888716512d8b5464e465d93be316aefd1508246539; expires=Wed, 17-Oct-18 13:22:19 GMT; path=/; domain=.yobit.net; HttpOnly
Set-Cookie: locale=en; expires=Sun, 17-Oct-2027 13:22:19 GMT; path=/
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block;
x-download-options: noopen
Server: cloudflare-nginx
CF-RAY: 3af390e828d869f5-LHR
Content-Encoding: gzip

 {"success":1,"return":{"rights":{"info":1,"trade":1,"deposit":1,"withdraw":0},"funds":{"btc":0,"eth":0},"funds_incl_orders":{"btc":0,"eth":0},"transaction_count":0,"open_orders":0,"server_time":1508246540}}
Traceback (most recent call last):
  File "C:/Users/Administrator/PycharmProjects/ccxt/bal_test.py", line 11, in <module>
    yobit.fetch_balance()
  File "C:\Users\Administrator\PycharmProjects\ccxt\ccxt\exchanges.py", line 18900, in fetch_balance
    account = self.extend(self.account(), result[currency])
KeyError: 'BTC'

Process finished with exit code 1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
md0101commented, Oct 18, 2017

@kroitor whilst the code throws no errors, it seems there is an inconsistency with the output.

I have no bids, offers or open trades in my account, just a balance in BTC and ETH

BTC shows the correct ‘free’ balance and 0.0 for ‘used’ but 0.0 for ‘total’ ETH shows the correct ‘total’ balance and 0.0 for ‘used’ but 0.0 for ‘free’

‘funds’ and ‘funds_incl_orders’ is reporting correctly

{'info': {'rights': {'info': 1, 'trade': 1, 'deposit': 1, 'withdraw': 0}, 'funds': {'btc': x.xx 'eth': x.xx}, 'funds_incl_orders': {'btc': x.xx, 'eth': x.xx}, 'transaction_count': 0, 'open_orders': 0, 'server_time': 1508301557}, 'BTC': {'free': x.xx, 'used': 0.0, 'total': 0.0}, 'ETH': {'free': 0.0, 'used': 0.0, 'total': x.xx}, 'free': {'BTC': x.xx, 'ETH': 0.0}, 'used': {'BTC': 0.0, 'ETH': 0.0}, 'total': {'BTC': 0.0, 'ETH': x.xx}}
0reactions
md0101commented, Oct 18, 2017

@kroitor yep that did it, thanks as always

Read more comments on GitHub >

github_iconTop Results From Across the Web

Yobit.net fetchbalance used always zero · Issue #2741 · ccxt/ccxt ...
On Yobit.net fetchBalance() .used values are all zero, despite API returns correct values. I think used should be calculated funds_incl_orders - funds ....
Read more >
Exchanges — ccxt 2.4.71 documentation
the current state of the user's account balance can be obtained with the fetchBalance() method as described in the Account Balance section ...
Read more >
ccxt Documentation - Read the Docs
ccxt Documentation, 1.13.142. () pprint(exchange.fetch_ticker('ETH/BTC')). 4.1.2 Python 3.5+ asyncio/aiohttp proxy.
Read more >
teatien-ccxt - CryptoCurrency eXchange Trading Library - PyPI
id name ver doc acx ACX 2 API anxpro ANXPro * API aofex AOFEX * API
Read more >
CCXT – CryptoCurrency eXchange Trading Library - npm
fetchBalance ()) // sell 1 BTC/USD for market price, sell a bitcoin for dollars ... ccxt.bitmex() huobipro = ccxt.huobipro() exmo = ccxt.exmo({ 'apiKey': ......
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