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.

negociecoins: 'bytes' object has no attribute 'encode'

See original GitHub issue
  • OS: Windows
  • CCXT version: 1.8.375
  • Exchange: negociecoins
  • Method: fetch_balance

I get the following error then trying to fetch_balance()

Traceback (most recent call last):
  File "main.py", line 10, in <module>
    print(neg.fetch_balance())
  File "/home/user/.local/lib/python3.5/site-packages/ccxt/negociecoins.py", line 174, in fetch_balance
    balances = self.privateGetUserBalance(params)
  File "/home/user/.local/lib/python3.5/site-packages/ccxt/base/exchange.py", line 388, in inner
    return entry(_self, **inner_kwargs)
  File "/home/user/.local/lib/python3.5/site-packages/ccxt/base/exchange.py", line 417, in request
    return self.fetch2(path, api, method, params, headers, body)
  File "/home/user/.local/lib/python3.5/site-packages/ccxt/base/exchange.py", line 412, in fetch2
    request = self.sign(path, api, method, params, headers, body)
  File "/home/user/.local/lib/python3.5/site-packages/ccxt/negociecoins.py", line 316, in sign
    signature = self.hmac(self.encode(payload), self.encode(secret), hashlib.sha256, 'base64')
  File "/home/user/.local/lib/python3.5/site-packages/ccxt/base/exchange.py", line 962, in encode
    return string.encode()
AttributeError: 'bytes' object has no attribute 'encode'

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
agemaniac82commented, Mar 19, 2019

Hi @kroitor.

Im getting the following error with the new version (im new to all of this, so sorry if its a newbie error):

Request: GET https://broker.negociecoins.com.br/tradeapi/v1/user/balance {'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'python-requests/2.21.0', 'Authorization': 'amx ca101a18126b4cf7a071e860b841b4ee:1whNyMO/82FBqOhFPFy3dqTvVRas+rKTkYhaja3sYYE=:1552998124817:1552998124'} 

Response: GET https://broker.negociecoins.com.br/tradeapi/v1/user/balance 200 {'Server': 'cloudflare', 'Connection': 'keep-alive', 'Pragma': 'no-cache', 'Transfer-Encoding': 'chunked', 'Date': 'Tue, 19 Mar 2019 12:22:05 GMT', 'x-frame-options': 'SAMEORIGIN', 'X-Powered-By': 'ASP.NET', 'Set-Cookie': '__cfduid=d1beaf94fa50ec2efbeddc2fd6203ce1a1552998124; expires=Wed, 18-Mar-20 12:22:04 GMT; path=/; domain=.negociecoins.com.br; HttpOnly', 'CF-RAY': '4b9f68e83981c1a9-IAD', 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'no-cache', 'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Content-Encoding': 'gzip', 'Expires': '-1'} {"coins":[{"name":"BRL","available":0.0,"openOrders":0.0,"withdraw":0.0,"total":0.0},{"name":"BTC","available":0.0,"openOrders":0.0,"withdraw":0.0,"total":0.0},{"name":"BCH","available":0.0,"openOrders":0.0,"withdraw":0.0,"total":0.0},{"name":"BTG","available":0.0,"openOrders":0.0,"withdraw":0.0,"total":0.0},{"name":"Dash","available":0.0,"openOrders":0.0,"withdraw":0.0,"total":0.0},{"name":"DOGE","available":0.0,"openOrders":0.0,"withdraw":0.0,"total":0.0},{"name":"LEAX","available":0.0,"openOrders":0.0,"withdraw":0.0,"total":0.0},{"name":"LTC","available":0.0,"openOrders":0.0,"withdraw":0.0,"total":0.0},{"name":"B2X","available":0.0,"openOrders":0.0,"withdraw":0.0,"total":0.0}]}
Traceback (most recent call last):
  File "main.py", line 10, in <module>
    print(neg.fetch_balance())
  File "/home/user/.local/lib/python3.5/site-packages/ccxt/negociecoins.py", line 182, in fetch_balance
    'free': float(balance['total']),
TypeError: list indices must be integers or slices, not str
0reactions
kroitorcommented, Mar 19, 2019

fetch_orders doesnt seen to be working also, but maybe im missing something.

It requires a symbol argument (first positional argument to fetchOrders), more about it here: https://github.com/ccxt/ccxt/wiki/Manual#querying-orders

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError:'bytes' object has no attribute 'encode'
chr returns a string that gets multiplied and encoded as bytes. · Python2 strings are implicitly bytes objects while Python3 strings are unicode....
Read more >
13391 (AttributeError: 'bytes' object has no attribute 'encode')
How to Reproduce. While doing a GET operation on /prefs/localization , Trac issued an internal error. The issue in ticket:13378 is related to...
Read more >
Sending mails with attachment results in 'bytes' object has no ...
When trying to send a EMail with attachment, it always failed with the following Exception: 'bytes' object has no attribute 'encode'.
Read more >
git-review on MacOS fails with 'bytes' object has no attribute ...
"GET https://vraikov@bellevue-ci-gerrit.eng.vmware.com:443/a/changes/?q=169795&o=CURRENT_REVISION". 'bytes' object has no attribute 'encode'.
Read more >
AttributeError: 'bytes' object has no attribute 'encode'
The Python AttributeError: 'bytes' object has no attribute 'encode' occurs when we call the `encode()` method on a bytes object. To solve the...
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