vn.py官网
开源量化社区
Member
avatar
加入于:
帖子: 298
声望: 73

1. 升级后进入回测,界面如下:

description

2. 下载数据时遇到下面的错误

11:11:22 初始化CTA回测引擎
11:11:22 策略文件加载完成
11:12:26 ----------------------------------------
11:12:26 rb2201.SHFE-1m开始下载历史数据
11:12:26 数据下载失败,触发异常:
Traceback (most recent call last):
File "D:\ProgramFiles\VnStudio\lib\site-packages\vnpy_ctabacktester\engine.py", line 404, in run_downloading
data = self.datafeed.query_bar_history(req)
File "D:\ProgramFiles\VnStudio\lib\site-packages\vnpy_rqdata\rqdata_datafeed.py", line 164, in query_bar_history
adjust_type="none"
File "D:\ProgramFiles\VnStudio\lib\site-packages\rqdatac\decorators.py", line 150, in wrap
return func(args, **kwargs)
File "D:\ProgramFiles\VnStudio\lib\site-packages\rqdatac\services\get_price.py", line 103, in get_price
order_book_ids, market
File "D:\ProgramFiles\VnStudio\lib\site-packages\rqdatac\services\get_price.py", line 222, in classify_order_book_ids
ins_list = ensure_instruments(order_book_ids, market=market)
File "D:\ProgramFiles\VnStudio\lib\site-packages\rqdatac\validators.py", line 168, in ensure_instruments
all_instruments = _all_instruments_dict(market)
File "D:\ProgramFiles\VnStudio\lib\site-packages\rqdatac\decorators.py", line 129, in wrapper
value = user_function(
args, kwargs)
File "D:\ProgramFiles\VnStudio\lib\site-packages\rqdatac\services\basic.py", line 139, in _all_instruments_dict
ins = _all_cached_instruments_list(market)
File "D:\ProgramFiles\VnStudio\lib\site-packages\rqdatac\decorators.py", line 129, in wrapper
value = user_function(*args,
kwargs)
File "D:\ProgramFiles\VnStudio\lib\site-packages\rqdatac\services\basic.py", line 134, in _all_cached_instruments_list
return _all_instruments_list(market)
File "D:\ProgramFiles\VnStudio\lib\site-packages\rqdatac\services\basic.py", line 112, in _all_instruments_list
ins = [Instrument(i) for i in get_client().execute("all_instruments", market=market)]
File "D:\ProgramFiles\VnStudio\lib\site-packages\rqdatac\client.py", line 31, in execute
raise RuntimeError("rqdatac is not initialized")
RuntimeError: rqdatac is not initialized

3. 好像是说米筐数据没有初始化?

虽然说是整个删除以前的版本,然后重新安装的2.6版本,但是以前的设置一点也没有改变,难道是以前的米筐接口设置不可以在新版本中继续使用了吗?

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

我也遇到类似的问题,启动策略的时候,要接入Rqdata历史数据的时候发生异常,还不知道怎么解决?


"[Testing] 触发异常已停止
Traceback (most recent call last):
File ""C:\vnstudio\lib\site-packages\vnpy_ctastrategy\engine.py"", line 622, in call_strategy_func
func()
File ""C:\Users\Bo\strategies\Apollo_Viscount_15min_OrderControl.py"", line 87, in on_init
self.load_bar(10)
File ""C:\vnstudio\lib\site-packages\vnpy_ctastrategy\template.py"", line 306, in load_bar
use_database
File ""C:\vnstudio\lib\site-packages\vnpy_ctastrategy\engine.py"", line 577, in load_bar
bars = self.query_bar_from_datafeed(symbol, exchange, interval, start, end)
File ""C:\vnstudio\lib\site-packages\vnpy_ctastrategy\engine.py"", line 151, in query_bar_from_datafeed
data = self.datafeed.query_history(req)
AttributeError: 'RqdataDatafeed' object has no attribute 'query_history'
"

Member
avatar
加入于:
帖子: 3164
声望: 185

可以pip install --upgrade vnpy_ctastrategy试试

Member
avatar
加入于:
帖子: 298
声望: 73

1、命令执行pip install --update vnpy_ctastrategy

仍然不行,问题依旧。

2. 用命令行启动python -m vnstation

启动的时候,报出下面的错误:

qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_ciphersuites
qt.network.ssl: QSslSocket: cannot resolve SSL_set_psk_use_session_callback
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_set_psk_use_session_callback
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_set_psk_use_session_callback
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_set_psk_use_session_callback
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_set_psk_use_session_callback
找不到数据服务驱动vnpy_,使用默认的RQData数据服务
js: Uncaught ReferenceError: c is not defined

查找了代码后与系统设置有关。

description

3. 图中三项应该怎么填写?

好像是说设置里面关于datafeed的name、username和password没有填写,
本人已经有米筐的账户,那么这三项应该怎么填写?

Member
avatar
加入于:
帖子: 298
声望: 73

问题解决啦,步骤如下!

(注:本人原来使用的是SQLite数据库。)

1 增加全局设置:

如上图把关于datafeed的
datafeed.name 为 rqdata
datafeed.username 为 米筐用户名称
datafeed.password 为 米筐用户密码
保存设置后退出vnpy软件。

2. 修改数据名称

进入个人目录,修改其中的.trader\database.db,为.trader\database-old.db。系统重新启动的时候会出现创建新的database.db,如果你database-old.db中还有你不能割舍的数据,日后再想办法重新编程序迁移数据。

3. 修改vnpy_ctastrategy\engine.py中第151行,这里有错误,修改如下:

    def query_bar_from_datafeed(
        self, symbol: str, exchange: Exchange, interval: Interval, start: datetime, end: datetime
    ):
        """
        Query bar data from datafeed.
        """
        req = HistoryRequest(
            symbol=symbol,
            exchange=exchange,
            interval=interval,
            start=start,
            end=end
        )
        # data = self.datafeed.query_history(req) # hxxjava
        data = self.datafeed.query_bar_history(req)   
        return data

4. 重新启动vnpy,下面的几个问题就解决了:

  1. 数据管理模块无法下载合约数据的问题
  2. CTA Backtester模块无法下载数据的问题
  3. CTA Strategy模块无法初始化和启动策略的问题

其他模块是否有问题还未可知!

Member
avatar
加入于:
帖子: 27
声望: 0

hxxjava wrote:

问题解决啦,步骤如下!

(注:本人原来使用的是SQLite数据库。)

1 增加全局设置:

如上图把关于datafeed的
datafeed.name 为 rqdata
datafeed.username 为 米筐用户名称
datafeed.password 为 米筐用户密码
保存设置后退出vnpy软件。

2. 修改数据名称

进入个人目录,修改其中的.trader\database.db,为.trader\database-old.db。系统重新启动的时候会出现创建新的database.db,如果你database-old.db中还有你不能割舍的数据,日后再想办法重新编程序迁移数据。

3. 修改vnpy_ctastrategy\engine.py中第151行,这里有错误,修改如下:

    def query_bar_from_datafeed(
        self, symbol: str, exchange: Exchange, interval: Interval, start: datetime, end: datetime
    ):
        """
        Query bar data from datafeed.
        """
        req = HistoryRequest(
            symbol=symbol,
            exchange=exchange,
            interval=interval,
            start=start,
            end=end
        )
        # data = self.datafeed.query_history(req) # hxxjava
        data = self.datafeed.query_bar_history(req)   
        return data

4. 重新启动vnpy,下面的几个问题就解决了:

  1. 数据管理模块无法下载合约数据的问题
  2. CTA Backtester模块无法下载数据的问题
  3. CTA Strategy模块无法初始化和启动策略的问题

其他模块是否有问题还未可知!

赞lz大神 这个错误能merge到代码库么

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

好像是强制使用米筐了,我下载币安数据也报米筐没初始化,解决办法是用2.5版前的米筐数据下载的代码替换下,因我没用米筐数据。

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

wrote:

好像是强制使用米筐了,我下载币安数据也报米筐没初始化,解决办法是用2.5版前的米筐数据下载的代码替换下,因我没用米筐数据。<

可以用ccxt的数据来代替米筐吗

Member
avatar
加入于:
帖子: 298
声望: 73

假如您原来使用的是MySQL数据库,如何排除安装问题?

  1. 在cmd窗口中登录MYSQL server:
    mysql -uroot -p
    输入密码
    登录mysql server成功后,输入下面的命令删除dbbardata,dbbaroverview和dbtickdata三个表:

    mysql> use vnpy
    mysql> drop table dbbardata;
    mysql> drop table dbbaroverview;
    mysql> drop table dbtickdata;
  2. 其他步骤除了数据库的部分外和 问题解决啦,步骤如下! 相同;

  3. 重新启动vnpy,问题就解决。
  4. 如果你使用的是其他数据库,如:PostreSQL、MongoDB或DolphinDB,方法与此类似。
Member
avatar
加入于:
帖子: 298
声望: 73

假如您原来使用过SpreadTrading模块,如何排除安装问题?

2.6版本的vnpy在SpreadTrading模块改动也是比较大的,好像是已经可以支持价差的逻辑仓位。并且保持价差设置spread_trading_setting.json、价差策略spread_trading_strategy.json的文件格式已经变了,去掉了spread_trading_advanced.json,同时又增加了一个存价差个腿的持仓的json文件spread_trading_pos.json,所以如果不对这些文件做处理,在执行SpreadTrading模块的时候程序是会崩溃的!
所以干脆把你自己的用户目录下的这几个文件改名或者删除:

spread_trading_setting.json
spread_trading_strategy.json
spread_trading_advanced.json

改名或者删除这三个文件后,重新创建价差,价差策略,然后手动或启动策略自动对价差进行操作就可以了!

Member
avatar
加入于:
帖子: 9
声望: 0

老哥牛逼!我也是更新后出问题了,查了好久找到你的帖子,感谢老哥!

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

最新版本集成了tushare读取的策略,只是如果不填写datafeedname就会默认用RQDATA

Member
avatar
加入于:
帖子: 6
声望: 0

Traceback (most recent call last):
File "C:\vnstudio\lib\site-packages\vnpy_ctabacktester\engine.py", line 404, in run_downloading
data = self.datafeed.query_bar_history(req)
File "C:\vnstudio\lib\site-packages\vnpy_rqdata\rqdata_datafeed.py", line 164, in query_bar_history
adjust_type="none"
File "C:\vnstudio\lib\site-packages\rqdatac\decorators.py", line 150, in wrap
return func(args, **kwargs)
File "C:\vnstudio\lib\site-packages\rqdatac\services\get_price.py", line 103, in get_price
order_book_ids, market
File "C:\vnstudio\lib\site-packages\rqdatac\services\get_price.py", line 222, in classify_order_book_ids
ins_list = ensure_instruments(order_book_ids, market=market)
File "C:\vnstudio\lib\site-packages\rqdatac\validators.py", line 168, in ensure_instruments
all_instruments = _all_instruments_dict(market)
File "C:\vnstudio\lib\site-packages\rqdatac\decorators.py", line 129, in wrapper
value = user_function(
args, kwargs)
File "C:\vnstudio\lib\site-packages\rqdatac\services\basic.py", line 139, in _all_instruments_dict
ins = _all_cached_instruments_list(market)
File "C:\vnstudio\lib\site-packages\rqdatac\decorators.py", line 129, in wrapper
value = user_function(*args,
kwargs)
File "C:\vnstudio\lib\site-packages\rqdatac\services\basic.py", line 134, in _all_cached_instruments_list
return _all_instruments_list(market)
File "C:\vnstudio\lib\site-packages\rqdatac\services\basic.py", line 112, in _all_instruments_list
ins = [Instrument(i) for i in get_client().execute("all_instruments", market=market)]
File "C:\vnstudio\lib\site-packages\rqdatac\client.py", line 31, in execute
raise RuntimeError("rqdatac is not initialized")
RuntimeError: rqdatac is not initialized

按照楼主的提示操作了,依然回测下载RQData数据报错。

Member
avatar
加入于:
帖子: 3164
声望: 185

tonyhe6688 wrote:

Traceback (most recent call last):
File "C:\vnstudio\lib\site-packages\vnpy_ctabacktester\engine.py", line 404, in run_downloading
data = self.datafeed.query_bar_history(req)
File "C:\vnstudio\lib\site-packages\vnpy_rqdata\rqdata_datafeed.py", line 164, in query_bar_history
adjust_type="none"
File "C:\vnstudio\lib\site-packages\rqdatac\decorators.py", line 150, in wrap
return func(args, **kwargs)
File "C:\vnstudio\lib\site-packages\rqdatac\services\get_price.py", line 103, in get_price
order_book_ids, market
File "C:\vnstudio\lib\site-packages\rqdatac\services\get_price.py", line 222, in classify_order_book_ids
ins_list = ensure_instruments(order_book_ids, market=market)
File "C:\vnstudio\lib\site-packages\rqdatac\validators.py", line 168, in ensure_instruments
all_instruments = _all_instruments_dict(market)
File "C:\vnstudio\lib\site-packages\rqdatac\decorators.py", line 129, in wrapper
value = user_function(
args, kwargs)
File "C:\vnstudio\lib\site-packages\rqdatac\services\basic.py", line 139, in _all_instruments_dict
ins = _all_cached_instruments_list(market)
File "C:\vnstudio\lib\site-packages\rqdatac\decorators.py", line 129, in wrapper
value = user_function(*args,
kwargs)
File "C:\vnstudio\lib\site-packages\rqdatac\services\basic.py", line 134, in _all_cached_instruments_list
return _all_instruments_list(market)
File "C:\vnstudio\lib\site-packages\rqdatac\services\basic.py", line 112, in _all_instruments_list
ins = [Instrument(i) for i in get_client().execute("all_instruments", market=market)]
File "C:\vnstudio\lib\site-packages\rqdatac\client.py", line 31, in execute
raise RuntimeError("rqdatac is not initialized")
RuntimeError: rqdatac is not initialized

按照楼主的提示操作了,依然回测下载RQData数据报错。
请问你参考2.6.0发布公告配置米筐账号了吗?

Member
avatar
加入于:
帖子: 298
声望: 73

xiaohe wrote:

tonyhe6688 wrote:

Traceback (most recent call last):
File "C:\vnstudio\lib\site-packages\vnpy_ctabacktester\engine.py", line 404, in run_downloading
data = self.datafeed.query_bar_history(req)
File "C:\vnstudio\lib\site-packages\vnpy_rqdata\rqdata_datafeed.py", line 164, in query_bar_history
adjust_type="none"
File "C:\vnstudio\lib\site-packages\rqdatac\decorators.py", line 150, in wrap
return func(args, **kwargs)
File "C:\vnstudio\lib\site-packages\rqdatac\services\get_price.py", line 103, in get_price
order_book_ids, market
File "C:\vnstudio\lib\site-packages\rqdatac\services\get_price.py", line 222, in classify_order_book_ids
ins_list = ensure_instruments(order_book_ids, market=market)
File "C:\vnstudio\lib\site-packages\rqdatac\validators.py", line 168, in ensure_instruments
all_instruments = _all_instruments_dict(market)
File "C:\vnstudio\lib\site-packages\rqdatac\decorators.py", line 129, in wrapper
value = user_function(
args, kwargs)
File "C:\vnstudio\lib\site-packages\rqdatac\services\basic.py", line 139, in _all_instruments_dict
ins = _all_cached_instruments_list(market)
File "C:\vnstudio\lib\site-packages\rqdatac\decorators.py", line 129, in wrapper
value = user_function(*args,
kwargs)
File "C:\vnstudio\lib\site-packages\rqdatac\services\basic.py", line 134, in _all_cached_instruments_list
return _all_instruments_list(market)
File "C:\vnstudio\lib\site-packages\rqdatac\services\basic.py", line 112, in _all_instruments_list
ins = [Instrument(i) for i in get_client().execute("all_instruments", market=market)]
File "C:\vnstudio\lib\site-packages\rqdatac\client.py", line 31, in execute
raise RuntimeError("rqdatac is not initialized")
RuntimeError: rqdatac is not initialized

按照楼主的提示操作了,依然回测下载RQData数据报错。
请问你参考2.6.0发布公告配置米筐账号了吗?

错误提示你是米筐账户的用户名或者密码错误了,除了datafeed的三项之外还要配置米筐账号和密码。

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

沪公网安备 31011502017034号