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

spot_client.ticker_price() doesn't work #5

Closed
KaiserPygit opened this issue Feb 2, 2024 · 2 comments
Closed

spot_client.ticker_price() doesn't work #5

KaiserPygit opened this issue Feb 2, 2024 · 2 comments

Comments

@KaiserPygit
Copy link

Hi,

I'm simply trying the following to get used to this library :

from pymexc import spot

api_key = 'abc'
api_secret = 'def'

spot_client = spot.HTTP(api_key = api_key, api_secret = api_secret)

print(spot_client.account_information())

print(spot_client.ticker_price())

Everything works fine until the last line. I have 2 problems here :

  • I didn't fully understand how to pass the arguments for a specific ticker, for example BTCUSDT

  • biggest problem : even if I try it with no argument, the doc says ":param symbol: (optional) If the symbol is not sent, all symbols will be returned in an array." So I should at least get an array as return, but instead I get the following error which I don't understand :

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/requests/models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/init.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pymexc/spot.py", line 290, in ticker_price
return self.call("GET", "/api/v3/ticker/price",
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pymexc/base.py", line 100, in call
return response.json()
^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

What's wrong ?

makarworld added a commit that referenced this issue Feb 2, 2024
…cker/bookTicker, /ticker/price, /ticker/24hr, /avgPrice, /klines, /aggTrades, /trades, /depth, /exchangeInfo, /defaultSymbols, /time, /ping. Solve issue #5.
@makarworld
Copy link
Owner

Fixed. Seems like when request sent to public endpoint with sign it return zero-content response.

@KaiserPygit
Copy link
Author

KaiserPygit commented Feb 2, 2024

Thanks, it works now :)
However I'm still struggling to pass the argument for a specific ticker.
For example I tried spot_client.ticker_price('symbol': 'BTCUSDT') but it says invalid syntax and if I try spot_client.ticker_price({'symbol': 'BTCUSDT'}) it says invalid symbol. What's the syntax to use ?
I also tried using '=' instead of ':' but nothing works.

EDIT : nevermind I found it, it's spot_client.ticker_price(symbol = 'BTCUSDT'), I was a bit stupid on this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants