Open jgoggan opened 2 years ago
I experienced the same issue and I'm about to suggest an error handling for this combined with the possibility to get notified in such a case. I just raised a pull request to introduce other alert channels - notably Pushover so that one could get active notifications right on one's phone or wrist. Waiting for response from @queball99.
Had this error yesterday and today : while the order got through yesterday it did not so today(Correction: it got through in both cases). See logs:
Yesterday:
Traceback (most recent call last):
File "./recurring-buy.py", line 163, in <module>
schedule.run_pending()
File "/usr/local/lib/python3.7/site-packages/schedule/__init__.py", line 780, in run_pending
default_scheduler.run_pending()
File "/usr/local/lib/python3.7/site-packages/schedule/__init__.py", line 100, in run_pending
self._run_job(job)
File "/usr/local/lib/python3.7/site-packages/schedule/__init__.py", line 172, in _run_job
ret = job.run()
File "/usr/local/lib/python3.7/site-packages/schedule/__init__.py", line 661, in run
ret = self.job_func()
File "./recurring-buy.py", line 118, in recurring_buy
init_buy(crypto_settings, currency)
File "./recurring-buy.py", line 93, in init_buy
order_details = auth_client.get_order(order_id=order_id)
File "/usr/local/lib/python3.7/site-packages/coinbasepro/auth_client.py", line 579, in get_order
"get", "/orders/" + order_id, rate_limiter=self.a_rate_limiter
File "/usr/local/lib/python3.7/site-packages/coinbasepro/public_client.py", line 474, in _send_message
self._check_errors_and_raise(r)
File "/usr/local/lib/python3.7/site-packages/coinbasepro/public_client.py", line 437, in _check_errors_and_raise
raise CoinbaseAPIError(message)
coinbasepro.exceptions.CoinbaseAPIError: NotFound
Today:
Traceback (most recent call last):
File "./recurring-buy.py", line 163, in <module>
schedule.run_pending()
File "/usr/local/lib/python3.7/site-packages/schedule/__init__.py", line 780, in run_pending
default_scheduler.run_pending()
File "/usr/local/lib/python3.7/site-packages/schedule/__init__.py", line 100, in run_pending
self._run_job(job)
File "/usr/local/lib/python3.7/site-packages/schedule/__init__.py", line 172, in _run_job
ret = job.run()
File "/usr/local/lib/python3.7/site-packages/schedule/__init__.py", line 661, in run
ret = self.job_func()
File "./recurring-buy.py", line 118, in recurring_buy
init_buy(crypto_settings, currency)
File "./recurring-buy.py", line 93, in init_buy
order_details = auth_client.get_order(order_id=order_id)
File "/usr/local/lib/python3.7/site-packages/coinbasepro/auth_client.py", line 579, in get_order
"get", "/orders/" + order_id, rate_limiter=self.a_rate_limiter
File "/usr/local/lib/python3.7/site-packages/coinbasepro/public_client.py", line 474, in _send_message
self._check_errors_and_raise(r)
File "/usr/local/lib/python3.7/site-packages/coinbasepro/public_client.py", line 437, in _check_errors_and_raise
raise CoinbaseAPIError(message)
coinbasepro.exceptions.CoinbaseAPIError: NotFound
... logs are the same.
Please note: Line numbers refer to this commit on branch support-pushover-alerts
in apfelnutzer/CoinbasePro-Recurring-Buy. I got notified about the container restart at least :-).
As you can see from the logs (and the code) the error occurs when collecting the order details right upon placing a market order. Might be a timing issue. Maybe you just need to wait a little (more) for the order to be processed... I started working on this issue now.
The returned error code is 404 ("not found"). According to the API documentation:
If the order is canceled the response may have status code 404 if the order had no matches.
From my impression 404 seems to be sort of an intermediate state meaning the order has not been matched (yet). I added a pause of three seconds between placing the market order and getting the details to prevent the error (still testing).
I am using your Docker for this and having it do small buys every 3 days. Sometimes, they work fine. Other times, it dies during one of the buys. I have the config set to buy $20 of BTC-USD, then $5 of ETH-USD, then $5 of DOGE-USD. I commonly get something like this in the logs:
Note that, on the Coinbase side, the ETH-USD buy actually succeeds! So, it works, but something doesn't come back properly at the client side and it dies.