简体   繁体   中英

Why do I need to add extra time for Coinbase Pro API to get a succesful transaction with Python cbpro library?

I am using the Python library posted on @Dan Paquin GitHub repository: https://github.com/danpaquin/coinbasepro-python The library is very well written and useful. However, I noticed that if I want to place orders in a for loop I need to add time.sleep(1.0) which seems too much. Otherwise, I got an error when I am trying to check the status of the order with:

status = self.cb_pro_client.get_order(self.OrderID)

This error only happens in production, with the sandbox version I cannot reproduce the error. The error basically complaints about not getting anything from the.get_order method.

I do not know much about the details about the library, but I read that you can only make 10 requests per second per IP, and I was making far less than those requests. Any suggestions?

I am using coinbase pro,

Thanks

You didn't tell what error you're getting but I suspect it's 404? I'm using the Node.js implementation and I get the same problem.

This isn't a problem with the python or node implementations as they are simply get wrappers to the exchange api endpoint https://api.exchange.coinbase.com/orders/{order_id} .

Coinbase get order docs if you're interested .

Sometimes the details are available right away, sometimes they aren't. I've tried throttling for 10 seconds and sometimes still get an error. My solution has been to put the order details in a while/try loop. The most I've seen it fail is 3 times in a row so far.

node psudocode:

buyResult = <place buy order>;
let done = false;
while(!done){
    try{
        orderDetails = <get order details>; 
        done = true; 
    }catch(e){
        <output: e.message + " ...waiting 3 seconds">
        <sleep for 3 seconds before trying again>
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM