vn.py量化社区
By Traders, For Traders.
Member
avatar
加入于:
帖子: 23
声望: 2

老大你好,

在用OK的永续合约跑海龟策略的时候(将atr_rsi策略中1分钟改成5分钟,也是一样的效果),bar数据为1分钟的时候,可以持续运行。改成5分钟的,下了几次单以后,就报错了,一直不断地弹出一个提示框,直到界面挂掉。
终端下的日志信息如下:


(base) [root@centos7_6 my_vnpy]# python run.py 
2019-09-24 11:38:33.075804 BTC-USD-SWAP BTC-USD-SWAP.OKEX
2019-09-24 11:38:33.078024 ETH-USD-SWAP ETH-USD-SWAP.OKEX
[2019-09-24T12:08:18.757993]: Unhandled RestClient Error:<class 'requests.exceptions.MissingSchema'>
request:request : PUT /api/v1/userDataStream?listenKey= error because terminated: 
headers: {'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json', 'X-MBX-APIKEY': ''}
params: {}
data: {}
response:

Exception trace: 
Traceback (most recent call last):
  File "/opt/anaconda3/lib/python3.7/site-packages/vnpy/api/rest/rest_client.py", line 278, in _process_request
    proxies=self.proxies,
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/models.py", line 313, in prepare
    self.prepare_url(url, params)
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/models.py", line 387, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL '/api/v1/userDataStream?listenKey=': No schema supplied. Perhaps you meant http:///api/v1/userDataStream?listenKey=?
Traceback (most recent call last):
  File "/opt/anaconda3/lib/python3.7/site-packages/vnpy/api/rest/rest_client.py", line 278, in _process_request
    proxies=self.proxies,
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/models.py", line 313, in prepare
    self.prepare_url(url, params)
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/models.py", line 387, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL '/api/v1/userDataStream?listenKey=': No schema supplied. Perhaps you meant http:///api/v1/userDataStream?listenKey=?
QObject::startTimer: Timers cannot be started from another thread
[2019-09-24T12:08:19.758964]: Unhandled RestClient Error:<class 'requests.exceptions.MissingSchema'>
request:request : PUT /api/v1/userDataStream?listenKey= error because terminated: 
headers: {'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json', 'X-MBX-APIKEY': ''}
params: {}
data: {}
response:

Exception trace: 
Traceback (most recent call last):
  File "/opt/anaconda3/lib/python3.7/site-packages/vnpy/api/rest/rest_client.py", line 278, in _process_request
    proxies=self.proxies,
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/models.py", line 313, in prepare
    self.prepare_url(url, params)
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/models.py", line 387, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL '/api/v1/userDataStream?listenKey=': No schema supplied. Perhaps you meant http:///api/v1/userDataStream?listenKey=?
Traceback (most recent call last):
  File "/opt/anaconda3/lib/python3.7/site-packages/vnpy/api/rest/rest_client.py", line 278, in _process_request
    proxies=self.proxies,
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/models.py", line 313, in prepare
    self.prepare_url(url, params)
  File "/opt/anaconda3/lib/python3.7/site-packages/requests/models.py", line 387, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL '/api/v1/userDataStream?listenKey=': No schema supplied. Perhaps you meant http:///api/v1/userDataStream?listenKey=?
Administrator
avatar
加入于:
帖子: 4130
声望: 230

OKEX需要每隔30分钟重新申请一次WEBSOCKET推送的连接保持,否则会自动断开。

这里报错是说上述申请出现异常,但是这个MissingSchema查了Google后没有太详细的资料,请查看下是否网络稳定,最新SS出问题的很多,推荐用海外云服务器。

Member
avatar
加入于:
帖子: 23
声望: 2

用bitmex的测试网络跑2.0.7里面自带的布林策略,也是会出上面的错误的。
用的是阿里云香港的服务器。
如果换海外的服务器,老大有啥推荐的吗?

Administrator
avatar
加入于:
帖子: 4130
声望: 230

bitmex都没有这个函数的,出现报错请具体截图给我们看下吧

跑bitmex推荐爱尔兰的AWS

Member
avatar
加入于:
帖子: 23
声望: 2

这是在爱尔兰的AWS上,bitmex测试网络,跑的v2.0.7里面自带的布林策略,出错了。

跟操作系统应该没关系吧,我用的是centos,在v2.0.6版本的时候,没有出过问题。

description

Administrator
avatar
加入于:
帖子: 4130
声望: 230

不要连接OKEX接口看看呢

Member
avatar
加入于:
帖子: 23
声望: 2

OKEX没有连接。
现在不跑实盘策略,做回测的时候,用遗传算法优化运行了几个小时,也会像上面一样出错。

最新实验发现,运行v2.0.7里面自带的run.py不会出问题。

我是把run.py里面屏蔽掉的所有add_app全打开了,还打开了一些gate接口。具体是打开了哪些接口导致出现问题,还没有确定。

Administrator
avatar
加入于:
帖子: 4130
声望: 230

但以上错误的内容就是OKEX接口的问题,在run.py中把所有okex相关的内容全部删掉试试,或者vnstation不要加载okex的接口

Member
avatar
加入于:
帖子: 15
声望: 1

用2.0.7版本的CTA策略模块跑BitMex实盘出现了同样问题~~

Traceback (most recent call last):
  File "/home/para/anaconda3/lib/python3.7/site-packages/vnpy/api/rest/rest_client.py", line 278, in _process_request
    proxies=self.proxies,
  File "/home/para/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/home/para/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/home/para/anaconda3/lib/python3.7/site-packages/requests/models.py", line 313, in prepare
    self.prepare_url(url, params)
  File "/home/para/anaconda3/lib/python3.7/site-packages/requests/models.py", line 387, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL '/api/v1/userDataStream?listenKey=': No schema supplied. Perhaps you meant http:///api/v1/userDataStream?listenKey=?
Segmentation fault (core dumped)
Administrator
avatar
加入于:
帖子: 4130
声望: 230

请移除掉所有除了BitMEX以外的接口,再运行实盘看看

Administrator
avatar
加入于:
帖子: 4130
声望: 230

查了下这个问题是币安接口,不是OKEX接口的,之前记错函数了不好意思

Member
avatar
加入于:
帖子: 23
声望: 2

是的,我这边也实验了,将币安的接口打开,连接其它的例如bitmex接口,也会出错。

© 2015-2019 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号-3