ricequant / rqalpha-mod-vnpy

RQAlpha 对接 vnpy 的扩展 Mod。通过启用该 Mod 来实现期货策略的实盘交易
Apache License 2.0
298 stars 59 forks source link

如何通过代码运行 rqalpha-mod-vnpy? #18

Closed Cuizi7 closed 7 years ago

Cuizi7 commented 7 years ago

对于第三方mod,一般推荐执行 rqalpha mod install xxx , 这个命令主要会干两件事。第一是寻找该 mod 的安装包有没有被安装,如果没有的话调用 pip 进行安装;第二件事是将该mod的信息添加进配置文件中,之后执行 rqalpha mod list 就可以看到对应的信息。

rqalpha 支持 rqalpha mod install -e . 你如果mod 本地开发的话 建议直接使用rqlapha install mod install -e . 来安装需要开发和编辑的Mod。

顺利的话此时执行 rqalpha mod list 就可以在表格中看到 vnpy,并可以执行 rqalpha mod enable vnpy 启用该mod。

另外并不需要将代码复制到 rqalpha 目录下。

FallacyWalker commented 7 years ago

好了,是init里的的“vnpy”没删掉 我把rqalpha_mod_vnpy删了,在rqalpha_mod_vnpy目录下执行了pip install -e .,也执行了rqalpha mod install vnpy 然后运行vnpy mod,报错:

/usr/bin/python2.7 /home/walker/Desktop/Rqalpha212/rqalpha/startmod.py [2017-04-27 19:05:19.057934] ERROR: system_log: ** [2017-04-27 19:05:19.058139] ERROR: system_log: Mod Import Error: [2017-04-27 19:05:19.058236] ERROR: system_log: No module named rqalpha_mod_vnpy [2017-04-27 19:05:19.058322] ERROR: system_log: ** Traceback (most recent call last): File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/main.py", line 191, in run mod_handler.start_up() └ <rqalpha.mod.ModHandler object at 0x7ff4610f6a90> File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/mod/init.py", line 68, in start_up self._mod_dict[mod_name].start_up(self._env, mod_config) │ │ │ └ {'enabled': True} │ │ └ <rqalpha.mod.ModHandler object at 0x7ff4610f6a90> │ └ 'sys_progress' └ <rqalpha.mod.ModHandler object at 0x7ff4610f6a90> KeyError: 'sys_progress' 0000-00-00 ERROR 'sys_progress' [2017-04-27 19:05:19.180070] ERROR: system_log: 策略运行产生异常 Traceback (most recent call last): File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/main.py", line 191, in run mod_handler.start_up() File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/mod/init.py", line 68, in start_up self._mod_dict[mod_name].start_up(self._env, mod_config) KeyError: 'sys_progress' Traceback (most recent call last): File "/home/walker/Desktop/Rqalpha212/rqalpha/startmod.py", line 43, in run(config_mod) │ └ {'base': {'frequency': 'tick', 'strategy_file': '/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/examples/buy_and_hold.py', 'end... └ <function run at 0x7ff4619b2488> File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/init.py", line 45, in run return main.run(parse_config(config, click_type=False, source_code=source_code), source_code=source_code) │ │ │ │ └ None │ │ │ └ None │ │ └ {'base': {'frequency': 'tick', 'strategy_file': '/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/examples/buy_and_hold.py', 'end... │ └ <function parse_config at 0x7ff461c5c488> └ <module 'rqalpha.main' from '/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/main.pyc'> File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/main.py", line 323, in run mod_handler.tear_down(code, user_exc) │ │ └ CustomException() │ └ EXIT_CODE.EXIT_INTERNAL_ERROR └ <rqalpha.mod.ModHandler object at 0x7ff4610f6a90> File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/mod/init.py", line 73, in tear_down ret = self._mod_dict[mod_name].tear_down(*args) │ │ └ (EXIT_CODE.EXIT_INTERNAL_ERROR, CustomException()) │ └ 'sys_risk' └ <rqalpha.mod.ModHandler object at 0x7ff4610f6a90> KeyError: 'sys_risk'

Process finished with exit code 1

Cuizi7 commented 7 years ago

这个应该是 rqalpha 报的错;你先试着把rqalpha 运行起来?然后把 sys_simulation 关掉,打开 vnpy mod 。