Ccxt: okex超时的Fetch_ohlcv(符号,“ 1m”)

创建于 2018-03-22  ·  3评论  ·  资料来源: ccxt/ccxt

问题:
我大约30分钟后跑了,超时的问题是交换问题,还是ccxt问题,如何解决。

  • 操作系统:win10
  • 编程语言版本:python 3.6
  • CCXT版本:ccxt-1.11.137
  • 交易所:okex
  • 方法:exchange.fetch_ohlcv(self.symbol,'1m')

代码:

 def get_close_prices(self):
        close_prices = []
        bar_data = np.array(self.exchange.fetch_ohlcv(symbol, '1m'))
        for element in bar_data:
            close_prices.append(float(element[4]))
        return close_prices

if __name__ == '__main__':
while true:
        close_prices = self.get_close_prices()
        time.sleep(1 * 60)

错误:

在handle_bar中的文件“ E:/work/test/test.py”,第44行
close_prices = np.array(self.get_close_prices())
在get_close_prices中的文件“ E:/work/test/test.py”,第24行
bar_data = np.array(self.exchange.fetch_ohlcv(self.symbol,'1m'))
fetch_ohlcv中的第348行的文件“ E:\ sorfware \ anaconda3.5 \ lib \ site-packages \ ccxt \ okcoinusd.py”
响应= getattr(self,method)(self.extend(request,params))
请求中的文件“ E:\ sorfware \ anaconda3.5 \ lib \ site-packages \ ccxt \ base \ exchange.py”,行298
返回self.fetch2(path,api,method,params,headers,body)
fetch2中的第295行的文件“ E:\ sorfware \ anaconda3.5 \ lib \ site-packages \ ccxt \ base \ exchange.py”
返回self.fetch(request ['url'],request ['method'],request ['headers'],request ['body'])
提取中的文件“ E:\ sorfware \ anaconda3.5 \ lib \ site-packages \ ccxt \ base \ exchange.py”,行359
self.raise_error(RequestTimeout,method,url,e)
文件“ E:\ sorfware \ anaconda3.5 \ lib \ site-packages \ ccxt \ base \ exchange.py”,第280行,在raise_error中
引发exception_type(输出)
ccxt.base.errors.RequestTimeout:okex GET https://www.okex.com/api/v1/kline.do?symbol=bch_btc&type=1min&since=1521547087487 HTTPSConnectionPool(host ='www.okex.com',port = 443 ): 读取超时。 (读取超时= 10)

duplicate question

所有3条评论

我大约30分钟后跑了,超时的问题是交换问题,还是ccxt问题

这是交换的问题,任何交换有时都会用RequestTimeout答复,您只需要适当地处理它即可。

如何解决。

只要捕获异常,然后再重试即可。

希望能帮助到你。

非常感谢,我根据您的指示解决了问题,那就是捕获异常。

@nashse thx举报!

此页面是否有帮助?
0 / 5 - 0 等级