danpaquin / coinbasepro-python

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

any ideas for get_fills timeout / no response handling? #346

Closed noah222 closed 5 years ago

noah222 commented 5 years ago

A lagging response on authenticated requests can kill most any kind of high frequency trading strategy. Several times in the last week, get_fills has stalled, stopping my simple program loop, causing issues with my strategy by causing the subsequent commands from processing at the right moments.

So my question / issue is related to how would we specify a timeout for a response from cppro servers for these requests. I would ideally like to back out of the request if no response is made within .5 or 1 second.

Can I do something with kwargs (dict): Additional HTTP request parameters. ? Since I am not sure of the exact architecture being used I am not sure what kind of timeout argument could be supplied?

Right now I am not interested in running multiple threads and would like to keep the program as simple as possible. Ideally I could specify a timeout at each call to the function and something in the function would facilitate a dummy response and return a timeout error that could be dealt with gracefully. And help / pointers, or fix ideas would be appreciated.

kkuette commented 5 years ago

If your working on a high frequency strategy, it's better to use the orderbook directly. Just grab 'done' order with 'filled' type and compare it with your current order, else it will take alot more time to get your fills.

Hope it help.

noah222 commented 5 years ago

Thanks, this could be a good solution to try. I think I will also start experimenting with getting a timeout working because other interactions with the coinbase server have lagged too. Just to have a condition that stops trying to trade after a few lags, then waits a few minutes to try again or something.

kkuette commented 5 years ago

Check this

noah222 commented 5 years ago

Check this

Wow, thanks. I've been working on my own grassroots AI with brute force combinations of trading variables but this looks quite refined. Can't wait to dig into it.