vn.py量化社区
By Traders, For Traders.
Member
avatar
加入于:
帖子: 8
声望: 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_backtester\ui\widget.py", line 50, in init
self.init_strategy_settings()
File "c:\vnstudio\lib\site-packages\vnpy\app\cta_backtester\ui\widget.py", line 57, in init_strategy_settings
setting = self.backtester_engine.get_default_setting(class_name)
File "c:\vnstudio\lib\site-packages\vnpy\app\cta_backtester\engine.py", line 240, in get_default_setting
return strategy_class.get_class_parameters()
File "c:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\template.py", line 60, in get_class_parameters
class_parameters[name] = getattr(cls, name)
AttributeError: type object 'DemoStrategy' has no attribute 'fast_windowslow_window'

已经对照视频课程仔细检查了代码,没写错,查不出问题原因?
请版主帮忙解答?谢谢!

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

description

策略文件strategies.demo_strategy加载失败,触发异常:
Traceback (most recent call last):
File "c:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 793, 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 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 860, in get_code
File "<frozen importlib._bootstrap_external>", line 791, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\linxizhiri\strategies\demo_strategy.py", line 40
def
init__(
^
IndentationError: unindent does not match any outer indentation level

请问这个问题出在哪里?

Administrator
avatar
加入于:
帖子: 4122
声望: 229

代码格式问题,缩进层次不对

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

用Python的交易员 wrote:

代码格式问题,缩进层次不对

已经解决了!谢谢。

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