Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mercado Bitcoin BCH/BRL market missing #400

Closed
Felipe-Mangueira opened this issue Oct 25, 2017 · 22 comments
Closed

Mercado Bitcoin BCH/BRL market missing #400

Felipe-Mangueira opened this issue Oct 25, 2017 · 22 comments
Assignees

Comments

@Felipe-Mangueira
Copy link
Contributor

Felipe-Mangueira commented Oct 25, 2017

Hey,

I noticed the BCH/BTC market is missing in the Mercado Bitcoin exchange. Could you implement this routine to make trading in this market possible?
Also, I cannot make any request with the private API, cause the following error is always raising. Could you fix this issue as well?

Traceback (most recent call last):
File "C:/Users/me/example.py", line 92, in
x = mercado.create_order("BTC/BRL", 'limit', 'buy', 0.01, 10000)
File "C:\Program Files\Python36\lib\site-packages\ccxt\exchanges.py", line 16337, in create_order
response = getattr(self, method)(self.extend(order, params))
File "C:\Program Files\Python36\lib\site-packages\ccxt\exchanges.py", line 16389, in request
response = self.fetch2(path, api, method, params, headers, body)
File "C:\Program Files\Python36\lib\site-packages\ccxt\exchange.py", line 241, in fetch2
request = self.sign(path, api, method, params, headers, body)
File "C:\Program Files\Python36\lib\site-packages\ccxt\exchanges.py", line 16384, in sign
'TAPI-MAC': self.hmac(self.encode(auth), self.secret, hashlib.sha512),
File "C:\Program Files\Python36\lib\site-packages\ccxt\exchange.py", line 604, in hmac
h = hmac.new(secret, request, algorithm)
File "C:\Program Files\Python36\lib\hmac.py", line 144, in new
return HMAC(key, msg, digestmod)
File "C:\Program Files\Python36\lib\hmac.py", line 42, in init
raise TypeError("key: expected bytes or bytearray, but got %r" % type(key).name)
TypeError: key: expected bytes or bytearray, but got 'str'

@kroitor kroitor self-assigned this Oct 25, 2017
@kroitor
Copy link
Member

kroitor commented Oct 25, 2017

Hi, @Felipe-Mangueira ! Sure! Looks like they upgraded their public API at last, and now we can rewrite it a little. Will be there in very short time.

@Felipe-Mangueira
Copy link
Contributor Author

Ok, @kroitor. If you can put this task on your priority list, I will be very appreciatted, because I already trade in this exchanger. Does this upgrade takes a long time to be fulfilled?

@kroitor
Copy link
Member

kroitor commented Oct 25, 2017

@Felipe-Mangueira This issue has been solved in v.1.9.260. Don't forget to upgrade it. We will be happy if you report back if it works for you as expected or not. Cheers!

@Felipe-Mangueira
Copy link
Contributor Author

Thank you so much @kroitor. Sure, I'll report as soon as possible.

@Felipe-Mangueira
Copy link
Contributor Author

Hey @kroitor ,
Sorry for disturbing you again.
The functions of the class I usually use are fully functional, except the "fetch_balance ()" function, which is not returning the balance dictionary. Could you fix this issue for me, please?
Thanks again.

@kroitor
Copy link
Member

kroitor commented Oct 26, 2017

@Felipe-Mangueira , can you please paste your code + verbose output (without the keys) ?

@Felipe-Mangueira
Copy link
Contributor Author

Felipe-Mangueira commented Oct 26, 2017

Sure, @kroitor . Sorry for did not share it before.
That's a section of the code, like example:

mercado = ccxt.mercado({'nonce': lambda: int(time.time() * 1000)})
mercado.uid = 'MY USERID'
mercado.apiKey = 'MY APIKEY'
mercado.secret = 'MY SECRET'
mercado.password = 'MY PASSWORD'

x = mercado.fetch_balance()

This code returns something like that:

Traceback (most recent call last):
  File "C:/Users/myuser/Mycode.py", line 102, in <module>
    x = mercado.fetch_balance()
  File "C:\Program Files\Python36\lib\site-packages\ccxt\exchanges.py", line 16437, in fetch_balance
    balances = response['balance']
KeyError: 'balance'

If it helps you, the "response = self.privatePostGetAccountInfo()" line within the "fetch_balance" function from mercado class can read my balance but doesn't return the dictionary.

@kroitor
Copy link
Member

kroitor commented Oct 26, 2017

@Felipe-Mangueira sorry, but we need verbose output:

mercado = ccxt.mercado({'nonce': lambda: int(time.time() * 1000)})
mercado.verbose = True  # ←--------------- add this line before doing other calls

It will print much more output. Can you paste it here, plz? Remove your keys and passwords from there. Hope you understand...

P.S. Use triple backticks for pasting code and results:

```
your code or output
```

@Felipe-Mangueira
Copy link
Contributor Author

Sorry again, @kroitor

It follows the response:

Connected to pydev debugger (build 172.3544.46)
https://www.mercadobitcoin.net/tapi/v3/ POST https://www.mercadobitcoin.net/tapi/v3/ 
Request: {'Content-Type': 'application/x-www-form-urlencoded', 'TAPI-ID': 'code', 'TAPI-MAC': 'code', 'User-Agent': 'ccxt/1.9.265 (+https://github.com/ccxt-dev/ccxt) Python/3.6.2', 'Accept-Encoding': 'gzip, deflate'} tapi_method=get_account_info&tapi_nonce=1509023304642
Traceback (most recent call last):
POST https://www.mercadobitcoin.net/tapi/v3/ 
Response: Content-Type: application/json
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.1\helpers\pydev\pydevd.py", line 1599, in <module>
Date: Thu, 26 Oct 2017 13:08:25 GMT
Server: Apache
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.1\helpers\pydev\pydevd.py", line 1026, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.1\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/myuser/mycode.py", line 104, in <module>
    x = mercado.fetch_balance()
  File "C:\Program Files\Python36\lib\site-packages\ccxt\exchanges.py", line 16437, in fetch_balance
    balances = response['balance']
KeyError: 'balance'
Vary: Cookie
X-Frame-Options: SAMEORIGIN
Set-Cookie: visid_incap_619276=murZgy/KRlmoQpbE3y3gYkne8VkAAAAAQUIPAAAAAACFToWzQqJE3Qh/q6aOg5Py; expires=Fri, 26 Oct 2018 09:47:13 GMT; path=/; Domain=.mercadobitcoin.net
Set-Cookie: nlbi_619276=KMVBKCRVHggSHV2j+vqauAAAAADVSBsDKFkhx5yT53vjjUus; path=/; Domain=.mercadobitcoin.net
Set-Cookie: incap_ses_468_619276=6bxiQOXp1gIBZF82KKx+Bkne8VkAAAAAIDss8cymozUpqN7cHuiSOg==; path=/; Domain=.mercadobitcoin.net
Set-Cookie: ___utmvmKEulzpm=fYfbLDdNIei; path=/; Max-Age=900
Set-Cookie: ___utmvaKEulzpm=cFq�qzIJ; path=/; Max-Age=900
Set-Cookie: ___utmvbKEulzpm=tZh
    XFKOTalO: gtk; path=/; Max-Age=900
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Iinfo: 9-2366563-2357898 PNNN RT(1509023304784 867) q(0 0 0 -1) r(3 3) U6
X-CDN: Incapsula
Content-Encoding: gzip
X-Cache: MISS from omne3.tejofran.br
Via: 1.1 omne3.tejofran.br (squid/3.5.10-20151001-r13933)
Connection: close

 {"response_data": {"balance": {"brl": {"available": "0", "total": "0", "amount_open_orders": 0}, "btc": {"available": "0", "total": "0", "amount_open_orders": 0}, "ltc": {"available": "0", "total": "0", "amount_open_orders": 0}, "bch": {"available": "0", "total": "0", "amount_open_orders": 0}}, "withdrawal_limits": {"brl": {"available": "20000.00", "total": "20000.00"}, "btc": {"available": "25.00000000", "total": "25.00000000"}, "ltc": {"available": "500.00000000", "total": "500.00000000"}, "bch": {"available": "25.00000000", "total": "25.00000000"}}}, "status_code": 100, "server_unix_timestamp": "1509023306"}

Process finished with exit code 1

@kroitor
Copy link
Member

kroitor commented Oct 26, 2017

@Felipe-Mangueira ok, no problem, now i see the cause of it, I will fix it right away and will get back to you shortly.

kroitor added a commit that referenced this issue Oct 26, 2017
@kroitor
Copy link
Member

kroitor commented Oct 26, 2017

Ok, this should be completely fixed in 1.9.269. Can you please update and report if it works normally for you now? I tested it on my side and it should. Standing by for your reply. Thx!

@Felipe-Mangueira
Copy link
Contributor Author

Thank you, @kroitor !! Waiting.

@kroitor
Copy link
Member

kroitor commented Oct 26, 2017

@Felipe-Mangueira it's there, does it work for you? Let us know, plz.

@Felipe-Mangueira
Copy link
Contributor Author

Hey, @kroitor . It's working properly right now. Thank you so much once again.
If i notice anything else strange, may I report you?

@kroitor
Copy link
Member

kroitor commented Oct 26, 2017

@Felipe-Mangueira cool! Thx! Sure, feel free to ask your questions or open issues if you have any difficulties with it. Your feedback is very welcome! Thx again!

@Felipe-Mangueira
Copy link
Contributor Author

Felipe-Mangueira commented Oct 31, 2017

Hi, @kroitor,

Sorry for disturbing you again with this issue, but I think there is still something wrong with the BCH/BTC market, because all my limit orders (with the function ccxt.mercado.create_order(args)) in this market are not being placed, regardless the amount or the price or the side. Could you please take a look in your code?

Thank you again for your patience.

This is the verbose output:

https://www.mercadobitcoin.net/tapi/v3/ POST https://www.mercadobitcoin.net/tapi/v3/ 
Request: {'Content-Type': 'application/x-www-form-urlencoded', 'TAPI-ID': 'code', 'TAPI-MAC': 'another_code', 'User-Agent': 'ccxt/1.9.269 (+https://github.com/ccxt-dev/ccxt) Python/3.6.2', 'Accept-Encoding': 'gzip, deflate'} tapi_method=place_sell_order&tapi_nonce=1509474019127&coin_pair=BCHBTC&quantity=2.00&limit_price=1499.95
Traceback (most recent call last):
POST https://www.mercadobitcoin.net/tapi/v3/ 
Response: Content-Type: application/json
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.1\helpers\pydev\pydevd.py", line 1599, in <module>
Date: Tue, 31 Oct 2017 18:20:19 GMT
    globals = debugger.run(setup['file'], None, None, is_module)
Server: Apache
Vary: Cookie
X-Frame-Options: SAMEORIGIN
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.1\helpers\pydev\pydevd.py", line 1026, in run
Set-Cookie: visid_incap_619276=uQFIzrYNTmG4TBUBgx3/weO++FkAAAAAQUIPAAAAAAArAuR2OeeTniKJJLKhUPBa; expires=Wed, 31 Oct 2018 02:15:44 GMT; path=/; Domain=.mercadobitcoin.net
    pydev_imports.execfile(file, globals, locals)  # execute the script
Set-Cookie: nlbi_619276=QvdZHMaS4zs9MSmB+vqauAAAAADHXDpifD+UxhxuXjXFB6U7; path=/; Domain=.mercadobitcoin.net
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.2.1\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
Set-Cookie: incap_ses_469_619276=zsbrTAef/2cZjZopIjmCBuO++FkAAAAAF4bDCa0Iwv7s06sRa/XZBQ==; path=/; Domain=.mercadobitcoin.net
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
Set-Cookie: ___utmvmyEulzpm=WylvtzloMHX; path=/; Max-Age=900
  File "C:/Users/myuser/mycode.py", line 101, in <module>
Set-Cookie: ___utmvayEulzpm=vEz�FVvC; path=/; Max-Age=900
    x = mercado.create_order("BCH/BRL", "limit", "sell", 2.00, 1499.95)
Set-Cookie: ___utmvbyEulzpm=PZU
  File "C:\Program Files\Python36\lib\site-packages\ccxt\exchanges.py", line 16479, in create_order
    XJiOLalB: Pto; path=/; Max-Age=900
    response = getattr(self, method)(self.extend(order, params))
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
  File "C:\Program Files\Python36\lib\site-packages\ccxt\exchanges.py", line 16533, in request
X-Iinfo: 8-43754272-43754376 NNNN CT(0 0 0) RT(1509474018864 351) q(0 0 0 -1) r(1 1) U6
X-CDN: Incapsula
Content-Encoding: gzip
X-Cache: MISS from omne3.tejofran.br
Via: 1.1 omne3.tejofran.br (squid/3.5.10-20151001-r13933)
Connection: close

 {"status_code": 205, "error_message": "Valor do *coin_pair* inv\u00e1lido.", "server_unix_timestamp": "1509474019"}
    raise ExchangeError(self.id + ' ' + self.json(response))
ccxt.errors.ExchangeError: mercado {"status_code":205,"error_message":"Valor do *coin_pair* inv\u00e1lido.","server_unix_timestamp":"1509474019"}

Process finished with exit code 1

@kroitor
Copy link
Member

kroitor commented Oct 31, 2017

@Felipe-Mangueira sure, I'll take a look into it asap.

@Felipe-Mangueira
Copy link
Contributor Author

Thank you! I'll be waiting for your reply.

kroitor added a commit that referenced this issue Oct 31, 2017
@kroitor
Copy link
Member

kroitor commented Oct 31, 2017

@Felipe-Mangueira this should be completely fixed in 1.9.292

@Felipe-Mangueira Felipe-Mangueira changed the title Mercado Bitcoin BCH/BTC market missing Mercado Bitcoin BCH/BRL market missing Oct 31, 2017
@Felipe-Mangueira
Copy link
Contributor Author

Thx again, @kroitor!

@kroitor
Copy link
Member

kroitor commented Oct 31, 2017

@Felipe-Mangueira sorry, we're having an issue with publishing to PyPI, the new version will be there right away. Thx!

@Felipe-Mangueira
Copy link
Contributor Author

Ok @kroitor. Sorry for late reply. I noticed you have uploaded the updated version of ccxt library and I already have installed the package. Thanks for your concern.

academe-01 pushed a commit to academe-01/ccxt that referenced this issue Oct 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants