简体   繁体   English

为什么我需要为 Coinbase Pro API 添加额外的时间才能与 Python cbpro 库成功交易?

[英]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.我正在使用@Dan Paquin GitHub 存储库上发布的 Python 库: https://github.com/danpaquin/coinbasepro-python该库写得很好而且很有用。 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.但是,我注意到如果我想在 for 循环中下订单,我需要添加 time.sleep(1.0) 这似乎太多了。 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.该错误基本上抱怨没有从 .get_order 方法中得到任何东西。

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.我对图书馆的细节了解不多,但我读到每个 IP 每秒只能发出 10 个请求,而我发出的请求远远少于这些请求。 Any suggestions?有什么建议么?

I am using coinbase pro,我正在使用coinbase pro,

Thanks谢谢

You didn't tell what error you're getting but I suspect it's 404?你没有告诉你得到了什么错误,但我怀疑它是 404? I'm using the Node.js implementation and I get the same problem.我正在使用 Node.js 实现,我遇到了同样的问题。

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} .这不是 python 或节点实现的问题,因为它们只是get交换 api 端点https://api.exchange.coinbase.com/orders/{order_id}

Coinbase get order docs if you're interested . 如果您有兴趣,Coinbase 可以获取订单文档

Sometimes the details are available right away, sometimes they aren't.有时可以立即获得详细信息,有时则不能。 I've tried throttling for 10 seconds and sometimes still get an error.我已经尝试限制 10 秒,但有时仍然会出现错误。 My solution has been to put the order details in a while/try loop.我的解决方案是将订单详细信息放在 while/try 循环中。 The most I've seen it fail is 3 times in a row so far.到目前为止,我看到它失败的次数最多的是连续 3 次。

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>
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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