hyperliquid-dex / hyperliquid-python-sdk

SDK for Hyperliquid API trading with Python.
MIT License
238 stars 97 forks source link

Example code breaks due to missing dep: requests #2

Closed AlliedToasters closed 1 year ago

AlliedToasters commented 1 year ago

just need to add the requests library into deps, maybe: PR1?

lasource18 commented 1 year ago

I am also getting an error running the example code even after adding the dep. See below:

Traceback (most recent call last): File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen httplib_response = self._make_request( File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 449, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 444, in _make_request httplib_response = conn.getresponse() File "/usr/local/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1374, in getresponse response.begin() File "/usr/local/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 318, in begin version, status, reason = self._read_status() File "/usr/local/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 287, in _read_status raise RemoteDisconnected("Remote end closed connection without" http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/requests/adapters.py", line 489, in send resp = conn.urlopen( File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen retries = retries.increment( File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/urllib3/util/retry.py", line 550, in increment raise six.reraise(type(error), error, _stacktrace) File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/urllib3/packages/six.py", line 769, in reraise raise value.with_traceback(tb) File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen httplib_response = self._make_request( File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 449, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 444, in _make_request httplib_response = conn.getresponse() File "/usr/local/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1374, in getresponse response.begin() File "/usr/local/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 318, in begin version, status, reason = self._read_status() File "/usr/local/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 287, in _read_status raise RemoteDisconnected("Remote end closed connection without" urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/lsrc/hyperliquid/test.py", line 16, in user_state = info.user_state("0xcd5051944f780a621ee62e39e493c489668acf4d") File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/hyperliquid/info.py", line 56, in user_state return self.post("/info", {"type": "clearinghouseState", "user": address}) File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/hyperliquid/api.py", line 36, in post response = self.session.post(url, json=payload) File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/requests/sessions.py", line 635, in post return self.request("POST", url, data=data, json=json, kwargs) File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/requests/sessions.py", line 587, in request resp = self.send(prep, send_kwargs) File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/requests/sessions.py", line 701, in send r = adapter.send(request, **kwargs) File "/Users/lsrc/hyperliquid/venv/lib/python3.10/site-packages/requests/adapters.py", line 547, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

AlliedToasters commented 1 year ago

@lasource18 this looks like an issue with the hyperliquid API, not the SDK. Could be an outage since the platform is still on early alpha.. Did you try on testnet?

lasource18 commented 1 year ago

@lasource18 this looks like an issue with the hyperliquid API, not the SDK. Could be an outage since the platform is still on early alpha.. Did you try on testnet?

You were correct it seems like the issue was with the API. I was actually trying to run the code on testnet which seemed to be lagging/down at the time. The API is working now and the code is running thank you.

traderben commented 1 year ago

Thanks for the bug report, I'm going to close this issue as the PR was merged