ricequant / rqalpha-mod-vnpy

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

在vnpy mod里如何做vnpy的交易呢 ? #15

Closed FallacyWalker closed 7 years ago

Cuizi7 commented 7 years ago

vnpy mod 现支持下单撤单等功能。可否详细描述一下您需要的功能?

FallacyWalker commented 7 years ago

目前只需要下单,撤单功能, 就是下单/撤单后,可以在vnpy的vntrader中看到;

Cuizi7 commented 7 years ago

如果 vnpy mod 和 vntrader 登录了同一个 CTP 账号的话是可以在 vntrader 中看到的。其实一个CTP 账号可以登录多个终端,所有终端都会收到 CTP 的回报,不仅仅局限于 vnpy mod 和 vntrader。

FallacyWalker commented 7 years ago

好的,但是怎样下单/撤单呢?

Cuizi7 commented 7 years ago

在策略中调用 rqalpha 的相关 API 即可。 参见此处 http://rqalpha.readthedocs.io/zh_CN/latest/api/base_api.html#buy-open

FallacyWalker commented 7 years ago

照着buy_and_hold写了一个简单的策略文件,但运行后vntrader里看不到交易信息; 我现在也无法确定策略文件是否被执行了,我在策略文件里加了logger.info("xxx"), 但是运行时并没有打出来;

Cuizi7 commented 7 years ago

策略运行前会有几分钟的时间从 CTP 同步数据。 您可以将 log-level 设置成 verbose,这样能看到一些更详细的 debug 信息。

FallacyWalker commented 7 years ago

设置了log-level为verbose; 运行了大约20分钟,报错: CThostFtdcUserApiImplBase::OnSessionDisconnected[0x7f5b640008c8][-1461387263][ 0] Traceback (most recent call last): File "/home/RqalphaNew/rqalpha/rqalpha/main.py", line 191, in run mod_handler.start_up() └ <rqalpha.mod.ModHandler object at 0x7f5b7c71ded0> File "/home/RqalphaNew/rqalpha/rqalpha/mod/init.py", line 67, in start_up self._mod_dict[mod_name].start_up(self._env, mod_config) │ │ │ └ {'CTP': {'brokerID': '9999', 'mdAddress': 'tcp://180.168.146.187:10010', 'password': ‘000000’, 'tdAddress': 'tcp://180... │ │ └ <rqalpha.mod.ModHandler object at 0x7f5b7c71ded0> │ └ 'vnpy' └ <rqalpha.mod.ModHandler object at 0x7f5b7c71ded0> File "/home/RqalphaNew/rqalpha/rqalpha/mod/rqalpha_mod_vnpy/mod.py", line 54, in start_up port = VNPYBroker.get_portfolio() └ <class 'rqalpha.mod.rqalpha_mod_vnpy.vnpy_broker.VNPYBroker'> TypeError: unbound method get_portfolio() must be called with VNPYBroker instance as first argument (got nothing instead) 0000-00-00 ERROR unbound method get_portfolio() must be called with VNPYBroker instance as first argument (got nothing instead) [2017-04-24 15:49:35.546968] ERROR: system_log: 策略运行产生异常 Traceback (most recent call last): File "/home/RqalphaNew/rqalpha/rqalpha/main.py", line 191, in run mod_handler.start_up() File "/home/RqalphaNew/rqalpha/rqalpha/mod/init.py", line 67, in start_up self._mod_dict[mod_name].start_up(self._env, mod_config) File "/home/RqalphaNew/rqalpha/rqalpha/mod/rqalpha_mod_vnpy/mod.py", line 54, in start_up port = VNPYBroker.get_portfolio() TypeError: unbound method get_portfolio() must be called with VNPYBroker instance as first argument (got nothing instead) CThostFtdcUserApiImplBase::OnSessionDisconnected[0x7f5b500008c8][-1461256191][ 0]

Cuizi7 commented 7 years ago

麻烦更新一下代码,包括 vnpy 和 vnpy mod

FallacyWalker commented 7 years ago

最新的vnpy无法编译CTP接口 。

FallacyWalker commented 7 years ago

rqalpha 2.0.9 运行vnpy mod的配置对吗?: from rqalpha import run config_mod={ "base":{ "strategy_file" : "/home/RqalphaNew/rqalpha/rqalpha/examples/buy_and_hold.py", "start_date" : "2017-01-01", "end_date" : "2017-04-25”, "stock_starting_cash" : 100000, "benchmark" : "000300.XSHG", "strategy_type" : “securities”, "enabled" : "true", "frequency" : "tick" }, "mod": { "vnpy": { "gateway_type": "CTP",
"vn_trader_path": "/home/walker/Desktop/vnpy/vn.trader"
"all_day": True, "query_interval": 2, "CTP": { "userID": "userid, "password": “password”, "brokerID": "9999", "tdAddress": "tcp://180.168.146.187:10030", "mdAddress": "tcp://180.168.146.187:10031"
}, "enabled": “true”, “log-level”: “verbose” }, "sys_simulation":{ "enabled": "false" } } } run(config_mod)

FallacyWalker commented 7 years ago

都更新了: rqalpha: 2.1.2 vnpy: clone的最新的,开发者说目前无法查看版本; vnpy mod: 0.9.21 Ubuntu 16.04 LTS

运行vnpy mod几分钟后, 报错:“不支持撮合类型” 。 /usr/bin/python2.7 /home/walker/Desktop/Rqalpha212/rqalpha/startmod.py Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ltsGateway/init.py", line 4, in from ltsGateway import LtsGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ltsGateway/ltsGateway.py", line 10, in from vnltsmd import MdApi ImportError: libsecuritymduserapi.so: cannot open shared object file: No such file or directory Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/qdpGateway/init.py", line 4, in from qdpGateway import QdpGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/qdpGateway/qdpGateway.py", line 16, in from vnqdpmd import MdApi ImportError: No module named vnqdpmd Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/xspeedGateway/init.py", line 4, in from xspeedGateway import XspeedGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/xspeedGateway/xspeedGateway.py", line 12, in from vnxspeedmd import MdApi ImportError: No module named vnxspeedmd Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/femasGateway/init.py", line 4, in from femasGateway import FemasGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/femasGateway/femasGateway.py", line 13, in from vnfemasmd import MdApi ImportError: No module named vnfemasmd Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/shzdGateway/init.py", line 4, in from shzdGateway import ShzdGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/shzdGateway/shzdGateway.py", line 18, in from vnshzd import ShzdApi ImportError: No module named vnshzd Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ksotpGateway/init.py", line 4, in from ksotpGateway import KsotpGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ksotpGateway/ksotpGateway.py", line 11, in from vnksotpmd import MdApi ImportError: No module named vnksotpmd Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ibGateway/init.py", line 4, in from ibGateway import IbGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ibGateway/ibGateway.py", line 20, in from vnib import * ImportError: twsapi.so: cannot open shared object file: No such file or directory Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) 请先安装WindPy接口 File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/sgitGateway/init.py", line 4, in from sgitGateway import SgitGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/sgitGateway/sgitGateway.py", line 16, in from vnsgitmd import MdApi ImportError: No module named vnsgitmd Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ksgoldGateway/init.py", line 4, in from ksgoldGateway import KsgoldGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ksgoldGateway/ksgoldGateway.py", line 14, in from vnksgoldtd import TdApi ImportError: No module named vnksgoldtd [2017-04-25 15:25:24.532232] INFO: system_log: CTP行情服务器连接成功 [2017-04-25 15:25:24.591442] INFO: system_log: CTP行情服务器登录成功 [2017-04-25 15:25:25.532419] INFO: system_log: CTP交易服务器连接成功 [2017-04-25 15:25:25.567215] INFO: system_log: CTP交易服务器登录成功 [2017-04-25 15:25:26.530059] INFO: system_log: CTP交易服务器结算信息确认成功 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 0x7f1d268858d0> 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) │ │ │ └ {'commission_multiplier': 1, 'enabled': 'false', 'matching_type': MATCHING_TYPE.CURRENT_BAR_CLOSE, 'price_limit': True, 'sig... │ │ └ <rqalpha.mod.ModHandler object at 0x7f1d268858d0> │ └ 'sys_simulation' └ <rqalpha.mod.ModHandler object at 0x7f1d268858d0> File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/mod/rqalpha_mod_sys_simulation/mod.py", line 47, in startup raise RuntimeError(("Not supported matching type {}").format(mod_config.matching_type)) │ └ {'commission_multiplier': 1, 'enabled': 'false', 'matching_type': MATCHING_TYPE.CURRENT_BAR_CLOSE, 'price_limit': True, 'sig... └ <function gettext at 0x7f1d31de6668> RuntimeError: 不支持撮合类型: MATCHING_TYPE.CURRENT_BAR_CLOSE 0000-00-00 ERROR 不支持撮合类型: MATCHING_TYPE.CURRENT_BAR_CLOSE [2017-04-25 15:28:12.508754] 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) File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/mod/rqalpha_mod_sys_simulation/mod.py", line 47, in startup raise RuntimeError(("Not supported matching type {}").format(mod_config.matching_type)) RuntimeError: 不支持撮合类型: MATCHING_TYPE.CURRENT_BAR_CLOSE CThostFtdcUserApiImplBase::OnSessionDisconnected[0x7f1d0c0008c8][-102498303][ 0] CThostFtdcUserApiImplBase::OnSessionDisconnected[0x7f1cfc0008c8][-102432767][ 0]

Process finished with exit code 0

Cuizi7 commented 7 years ago

检查一下是不是你的配置没有被调用,因为报错信息显示 simulation mod 还是被触发了

FallacyWalker commented 7 years ago

这是我的配置,有什么问题吗? rqalpha 2.1.2 运行vnpy mod的配置对吗?: from rqalpha import run config_mod={ "base":{ "strategy_file" : "/home/walke/Desktop/Rqalpha212/rqalpha/rqalpha/examples/buy_and_hold.py", "start_date" : "2017-01-01", "end_date" : "2017-04-25”, "stock_starting_cash" : 100000, "benchmark" : "000300.XSHG", "strategy_type" : “securities”, "enabled" : "true", "frequency" : "tick" }, "mod": { "vnpy": { "gateway_type": "CTP", "vn_trader_path": "/home/walker/Desktop/VnpyNew/vnpy/vn.trader" "all_day": True, "query_interval": 2, "CTP": { "userID": "userid, "password": “password”, "brokerID": "9999", "tdAddress": "tcp://180.168.146.187:10030", "mdAddress": "tcp://180.168.146.187:10031" }, "enabled": “true”, “log-level”: “verbose” }, "sys_simulation":{ "enabled": "false" } } } run(config_mod)

Cuizi7 commented 7 years ago

使用 rqalpha mod list 命令查看 mod 的启用状态,使用 rqalpha mod disable/enable  XXX 开关闭和开启mod。 http://rqalpha.readthedocs.io/zh_CN/latest/development/mod.html#pypi-mod

FallacyWalker commented 7 years ago

simulation mod已经关闭: screen shot 2017-04-26 at 09 21 52

FallacyWalker commented 7 years ago

rqalpha_vnpy_mod必须要安装吗? 怎么不安装,在代码里运行呢 ?

Cuizi7 commented 7 years ago

在 setup.py 所在路径执行 pip install -e .

FallacyWalker commented 7 years ago

rqalpa和ralpha vnpy mod,我都执行了 pip install -e . ; 然后我把rqalpha_mod_vnpy文件夹复制到rqalpha/mod下了; 你看一下我的配置有什么问题吗?

Cuizi7 commented 7 years ago

你可以看一下 rqalpha 的源代码。 对于第三方mod,一般推荐执行 rqalpha mod install xxx , 这个命令主要会干两件事。第一是寻找该 mod 的安装包有没有被安装,如果没有的话调用 pip 进行安装;第二件事是将该mod的信息添加进配置文件中,之后执行 rqalpha mod list 就可以看到对应的信息。 如果你想通过代码运行,pip install -e . 相当于已经安装了 mod 包,下面还需要做的事就是将信息添加到 mod 配置文件中,此时执行 rqalpha mod install vnpy 就可以了。 顺利的话此时执行 rqalpha mod list 就可以在表格中看到 vnpy,并可以执行 rqalpha mod enable vnpy 启用该mod。 另外并不需要将代码复制到 rqalpha 目录下。

Cuizi7 commented 7 years ago

我把这个问题单独开了个issue,方便其他用户查看 https://github.com/ricequant/rqalpha-mod-vnpy/issues/18 如果针对通过代码运行的问题可以直接在那里回复。

wh1100717 commented 7 years ago

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

FallacyWalker commented 7 years ago

rqalpha下的vnpy mod文件夹删掉了,也找上面说的办法安装了,重新运行,还是报“不支持撮合类型”的错误: /usr/bin/python2.7 /home/walker/Desktop/Rqalpha212/rqalpha/startmod.py Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ltsGateway/init.py", line 4, in from ltsGateway import LtsGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ltsGateway/ltsGateway.py", line 10, in from vnltsmd import MdApi ImportError: libsecuritymduserapi.so: cannot open shared object file: No such file or directory Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/qdpGateway/init.py", line 4, in from qdpGateway import QdpGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/qdpGateway/qdpGateway.py", line 16, in from vnqdpmd import MdApi ImportError: No module named vnqdpmd Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/xspeedGateway/init.py", line 4, in from xspeedGateway import XspeedGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/xspeedGateway/xspeedGateway.py", line 12, in from vnxspeedmd import MdApi ImportError: No module named vnxspeedmd Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/femasGateway/init.py", line 4, in from femasGateway import FemasGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/femasGateway/femasGateway.py", line 13, in from vnfemasmd import MdApi ImportError: No module named vnfemasmd 请先安装WindPy接口 Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/shzdGateway/init.py", line 4, in from shzdGateway import ShzdGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/shzdGateway/shzdGateway.py", line 18, in from vnshzd import ShzdApi ImportError: No module named vnshzd Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ksotpGateway/init.py", line 4, in from ksotpGateway import KsotpGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ksotpGateway/ksotpGateway.py", line 11, in from vnksotpmd import MdApi ImportError: No module named vnksotpmd Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ibGateway/init.py", line 4, in from ibGateway import IbGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ibGateway/ibGateway.py", line 20, in from vnib import * ImportError: twsapi.so: cannot open shared object file: No such file or directory Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/sgitGateway/init.py", line 4, in from sgitGateway import SgitGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/sgitGateway/sgitGateway.py", line 16, in from vnsgitmd import MdApi ImportError: No module named vnsgitmd Traceback (most recent call last): File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/init.py", line 30, in module = importlib.import_module(moduleName) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ksgoldGateway/init.py", line 4, in from ksgoldGateway import KsgoldGateway as gateway File "/home/walker/Desktop/VnpyNew/vnpy/vn.trader/gateway/ksgoldGateway/ksgoldGateway.py", line 14, in from vnksgoldtd import TdApi ImportError: No module named vnksgoldtd [2017-04-27 19:16:50.318307] INFO: system_log: CTP行情服务器连接成功 [2017-04-27 19:16:50.379870] INFO: system_log: CTP行情服务器登录成功 [2017-04-27 19:16:51.303359] INFO: system_log: CTP交易服务器连接成功 [2017-04-27 19:16:51.375967] INFO: system_log: CTP交易服务器登录成功 [2017-04-27 19:16:52.319344] INFO: system_log: CTP交易服务器结算信息确认成功 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 0x7f01d6378a90> 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) │ │ │ └ {'commission_multiplier': 1, 'enabled': 'false', 'matching_type': MATCHING_TYPE.CURRENT_BAR_CLOSE, 'price_limit': True, 'sig... │ │ └ <rqalpha.mod.ModHandler object at 0x7f01d6378a90> │ └ 'sys_simulation' └ <rqalpha.mod.ModHandler object at 0x7f01d6378a90> File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/mod/rqalpha_mod_sys_simulation/mod.py", line 47, in startup raise RuntimeError(("Not supported matching type {}").format(mod_config.matching_type)) │ └ {'commission_multiplier': 1, 'enabled': 'false', 'matching_type': MATCHING_TYPE.CURRENT_BAR_CLOSE, 'price_limit': True, 'sig... └ <function gettext at 0x7f01e18ce668> RuntimeError: 不支持撮合类型: MATCHING_TYPE.CURRENT_BAR_CLOSE 0000-00-00 ERROR 不支持撮合类型: MATCHING_TYPE.CURRENT_BAR_CLOSE [2017-04-27 19:19:38.742995] 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) File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/mod/rqalpha_mod_sys_simulation/mod.py", line 47, in startup raise RuntimeError(("Not supported matching type {}").format(mod_config.matching_type)) RuntimeError: 不支持撮合类型: MATCHING_TYPE.CURRENT_BAR_CLOSE CThostFtdcUserApiImplBase::OnSessionDisconnected[0x7f01bc0008c8][-752746495][ 0] CThostFtdcUserApiImplBase::OnSessionDisconnected[0x7f01ac0008c8][-752680959][ 0]

Process finished with exit code 0

Cuizi7 commented 7 years ago

File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/mod/rqalpha_mod_sys_simulation/mod.py", line 47, in start_up raise RuntimeError(("Not supported matching type {}").format(mod_config.matching_type)) RuntimeError: 不支持撮合类型: MATCHING_TYPE.CURRENT_BAR_CLOSE

这个错误确实是 sys_simulation 报出来的。你可以看到 CTP 已经成功连接上了,但是这个报错终止了程序导致 CTP 断连。一般来说 sys_simulation 已经 disable 了是不会启动的,您可否帮忙查看一下是什么原因导致了 sys_simulation 启动?如果关掉了 vnpy mod 这个现象还是否会复现?可以着重看一下 rqalpha 中的 ModHandler 部分。

FallacyWalker commented 7 years ago

"sys_simulation":{ "enabled": "false" } 这个错误解决了, 把配置里的这一段删掉就好了,但是重新运行几分钟后,又报错了:

Traceback (most recent call last): File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/main.py", line 289, in run Executor(env).run(bar_dict) │ │ └ BarMap(ZN1804) │ └ <rqalpha.environment.Environment object at 0x7ffbc317fa10> └ <class 'rqalpha.core.executor.Executor'> File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/core/executor.py", line 58, in run event_bus.publish_event(PRE_TICK) │ └ event_type:EVENT.PRE_TICK └ <rqalpha.events.EventBus object at 0x7ffbc317f950> File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/events.py", line 43, in publish_event if l(event): File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/model/account/benchmark_account.py", line 50, in _on_tick tick = event.tick └ event_type:EVENT.PRE_TICK AttributeError: 'Event' object has no attribute 'tick' 2017-04-28 14:13:27.00 ERROR 'Event' object has no attribute 'tick' [2017-04-28 14:13:30.746903] ERROR: system_log: 策略运行产生异常 Traceback (most recent call last): File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/main.py", line 289, in run Executor(env).run(bar_dict) File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/core/executor.py", line 58, in run event_bus.publish_event(PRE_TICK) File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/events.py", line 43, in publish_event if l(event): File "/home/walker/Desktop/Rqalpha212/rqalpha/rqalpha/model/account/benchmark_account.py", line 50, in _on_tick tick = event.tick AttributeError: 'Event' object has no attribute 'tick' CThostFtdcUserApiImplBase::OnSessionDisconnected[0x7ffba80008c8][-589823999][ 0] CThostFtdcUserApiImplBase::OnSessionDisconnected[0x7ffba40008c8][-589758463][ 0]

Process finished with exit code 0                                                                                                                                                                                                                                                                                                                   

Cuizi7 commented 7 years ago

develop 分支已修复

Cuizi7 commented 7 years ago

master 分支已修复。