VeighNa量化社区
你的开源社区量化交易平台 | vn.py | vnpy
Member
加入于:
帖子: 2
声望: 0

from vnpy_ctp import CtpGateway
from vnpy_scripttrader import init_cli_trading
from time import sleep

setting = {
"用户名": "xxxxxx",
"密码": "xxxxxxxxxx",
"经纪商代码": "9999",
"交易服务器": "180.168.146.187:10130",
"行情服务器": "180.168.146.187:10131",
"产品名称": "simnow_client_test",
"授权编码": "0000000000000000",
"产品信息": ""
}
engine = init_cli_trading([CtpGateway])
engine.connect_gateway(setting, "CTP")

sleep(10) # 等待初始化完成

tick = engine.get_tick("cu2507.SHFE")
p = tick.last_price
print(p)

上面代码报错如下:
AttributeError: 'MainEngine' object has no attribute 'get_tick'

Member
avatar
加入于:
帖子: 5465
声望: 333

这不是你的完整代码吧
init_cli_trading返回的engine实例是ScriptEngine,你报错的engine实例是MainEngine

Member
加入于:
帖子: 2
声望: 0

将vnpy降级到3.0.0,就不会报这个错误,但是获取到的tick是全为None的列表

Member
avatar
加入于:
帖子: 5465
声望: 333

你附上的代码没有subscribe

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

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】