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

1、添加策略至\vnstudio\Lib\site-packages\vnpy\app\cta_strategy\
2、进行cta回测,出现错误
3、删除策略
4、重启vnstation,
5、还是出现错误log
6、输出的log如下:
15:16:33 初始化CTA回测引擎
15:16:33 策略文件strategies.atr_demo_1加载失败,触发异常:
Traceback (most recent call last):
File "c:\vnstudio\lib\site-packages\vnpy\app\cta_backtester\engine.py", line 110, in load_strategy_class_from_module
module = importlib.import_module(module_name)
File "c:\vnstudio\lib\importlib__init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Andy\strategies\atr_demo_1.py", line 7, in <module>
class AtrThreeDemo(CtaTemplate):
File "C:\Users\Andy\strategies\atr_demo_1.py", line 43, in AtrThreeDemo
def
init__(self, cta_engine: Any, strategy_name: str, vt_symbol: str, setting: dict):
NameError: name 'Any' is not defined

15:16:33 策略文件加载完成
15:16:33 RQData数据接口初始化成功

Member
avatar
加入于:
帖子: 3033
声望: 174

可以在文件顶部添加代码from typing import Any试试看

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

xiaohe wrote:

可以在文件顶部添加代码from typing import Any试试看
您好,问题是我把策略文件删了,删除之后还是输出这个log;加上from typing import Any还是输出这个log

Member
avatar
加入于:
帖子: 3033
声望: 174

那请贴一下报错截图了

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

xiaohe wrote:

那请贴一下报错截图了
您好,就是下面这种情况

description

Administrator
avatar
加入于:
帖子: 4997
声望: 292

这里明显报错你的策略种用了Any这个对象,但是没有import

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

沪公网安备 31011502017034号