danpaquin / coinbasepro-python

The unofficial Python client for the Coinbase Pro API
MIT License
1.82k stars 734 forks source link

Authenticated Client Will Sometimes Fail When Placing Order - JSON Error? #225

Open ghost opened 6 years ago

ghost commented 6 years ago

I cannot replicate this error but it happens randomly when I am connecting to api via authenticated client, perhaps a couple times a day. I have run this code on my local computer and on a remote server and so far it has only occurred on the remote server, don't know if that matters or not. Here is the relevant traceback, the first line being my sell order:

order = auth_client.sell(price=str(adjPrice), size = size, product_id=product + '-USD')

File "/usr/local/lib/python3.4/site-packages/gdax/authenticated_client.py", line 80, in sell return r.json() File "/usr/local/lib/python3.4/site-packages/requests/models.py", line 866, in json return complexjson.loads(self.text, **kwargs) File "/usr/lib64/python3.4/json/init.py", line 318, in loads return _default_decoder.decode(s) File "/usr/lib64/python3.4/json/decoder.py", line 343, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib64/python3.4/json/decoder.py", line 361, in raw_decode raise ValueError(errmsg("Expecting value", s, err.value)) from None ValueError: Expecting value: line 1 column 1 (char 0)

smalbadger commented 6 years ago

I've also run into this problem when making various requests to the API and it's quite frustrating. I thought that the thread #231 gave a nice answer.

ghost commented 6 years ago

Thanks for the heads up. I actually decided to just connect to the API using requests package instead. It's still a bit buggy but is way less error-prone then this package, though it does take a bit more work.

robinglis commented 6 years ago

Hi stefanlopez, I appreciate you raising this point. Please can you provide some example code for placing orders with the requests package? Did you have this same issue with other API requests? Many thanks.

ghost commented 6 years ago

Check out this link: https://cryptostag.com/basic-gdax-api-trading-with-python/

Ultimately whichever route you go down, you will need error handling whenever you connect to the GDAX api, so that should be your biggest focus moving forward.

robinglis commented 6 years ago

Thanks a lot stefanlopez. That's much appreciated. Out of interest, have you experimented with ccxt (https://github.com/ccxt/ccxt) ? It looks like a reliable alternative.

danpaquin commented 6 years ago

Please follow PR #260 for error handling coming soon.