VeighNa量化社区
你的开源社区量化交易平台
Member
加入于:
帖子: 31
声望: 0

这个错误不知道什么原因。。。代码没有编译错误

Traceback (most recent call last):
File "C:\vnstudio\lib\site-packages\vnpy\trader\ui\mainwindow.py", line 278, in open_widget
widget = widget_class(self.main_engine, self.event_engine)
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\ui\widget.py", line 37, in init
self.cta_engine.init_engine()
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 107, in init_engine
self.load_strategy_class()
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 756, in load_strategy_class
self.load_strategy_class_from_folder(path2, "strategies")
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 771, in load_strategy_class_from_folder
self.load_strategy_class_from_module(strategy_module_name)
UnboundLocalError: local variable 'strategy_module_name' referenced before assignment

Administrator
avatar
加入于:
帖子: 4502
声望: 321

请升级到2.1.0版本试试

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

我使用的是 2.4.7 版本

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

和楼主一样的问题,VNPY 2.1.0 版本,ubuntu 18.04。

CTA回测使用正常。

点击 功能=>CTA策略,弹出窗口, 内容如下:

Traceback (most recent call last):
File "/home/zorin/miniconda3/lib/python3.7/site-packages/vnpy/trader/ui/mainwindow.py", line 278, in open_widget
widget = widget_class(self.main_engine, self.event_engine)
File "/home/zorin/miniconda3/lib/python3.7/site-packages/vnpy/app/cta_strategy/ui/widget.py", line 37, in init
self.cta_engine.init_engine()
File "/home/zorin/miniconda3/lib/python3.7/site-packages/vnpy/app/cta_strategy/engine.py", line 107, in init_engine
self.load_strategy_class()
File "/home/zorin/miniconda3/lib/python3.7/site-packages/vnpy/app/cta_strategy/engine.py", line 756, in load_strategy_class
self.load_strategy_class_from_folder(path2, "strategies")
File "/home/zorin/miniconda3/lib/python3.7/site-packages/vnpy/app/cta_strategy/engine.py", line 771, in load_strategy_class_from_folder
self.load_strategy_class_from_module(strategy_module_name)
UnboundLocalError: local variable 'strategy_module_name' referenced before assignment

Administrator
avatar
加入于:
帖子: 4502
声望: 321

请不要在strategies目录下放置除了py/pyd以外的文件

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

用Python的交易员 wrote:

请不要在strategies目录下放置除了py/pyd以外的文件

谢谢,有个正写的策略进入回测报告有问题,改了文件名后缀,移走就OK了。

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

沪公网安备 31011502017034号

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