vn.py官网
你的开源社区量化交易平台
Member
avatar
加入于:
帖子: 8
声望: 1

错误提示:
触发异常已停止
Traceback (most recent call last):
File ""c:\vnstudio\lib\site-packages\vnpy_ctastrategy\engine.py"", line 609, in call_strategy_func
func(params)
File ""C:\Users\lxero-VV\strategies\divo_X.py"", line 83, in on_tick
self.bg_5min.update_tick(tick)
File ""c:\vnstudio\lib\site-packages\vnpy\trader\utility.py"", line 224, in update_tick
self.on_bar(self.bar)
File ""C:\Users\lxero-VV\strategies\divo_X.py"", line 90, in on_bar
self.bg_5min.update_bar(bar)
File ""c:\vnstudio\lib\site-packages\vnpy\trader\utility.py"", line 268, in update_bar
self.update_bar_minute_window(bar)
File ""c:\vnstudio\lib\site-packages\vnpy\trader\utility.py"", line 308, in update_bar_minute_window
self.on_window_bar(self.window_bar)
File ""C:\Users\lxero-VV\strategies\divo_X.py"", line 119, in on_5min_bar
self.short(fall_trader_price, self.fixed_size)
File ""c:\vnstudio\lib\site-packages\vnpy_ctastrategy\template.py"", line 211, in short
net
File ""c:\vnstudio\lib\site-packages\vnpy_ctastrategy\template.py"", line 250, in send_order
self, direction, offset, price, volume, stop, lock, net
TypeError: send_order() takes 8 positional arguments but 9 were given
"

部分代码:
if self.pos == 0:
if self.rise_up:
self.buy(bar.close_price + 2, self.fixed_size)
elif self.fall_down:
self.short(bar.close_price - 2, self.fixed_size)
else:
pass

    if self.pos > 0:
        if self.fall_down:
            self.sell(bar.close_price - 2, abs(self.pos))
            self.short(bar.close_price - 2, self.fixed_size)
        else:
            pass

    if self.pos < 0:
        if self.rise_up:
            self.cover(bar.close_price + 2, abs(self.pos))
            self.buy(bar.close_price + 2, self.fixed_size)
        else:
            pass

多谢~~

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

求高手帮忙看下,多谢~~
description

Administrator
avatar
加入于:
帖子: 129
声望: 14

111行,改成self.buy(bar.close_price, self.fixed_size, stop=True)试试,不太清楚你这个True是指哪个参数,如果是lock或者net的话,把stop换掉

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

郭易燔 wrote:

111行,改成self.buy(bar.close_price, self.fixed_size, stop=True)试试,不太清楚你这个True是指哪个参数,如果是lock或者net的话,把stop换掉
多谢,我再试下

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

还是一样的。。。但是如果把 site-packages\vnpy_ctastrategytemplate.py 替换为 vnpy-2.1.8 版本的,就能开单。。有点奇怪
description

description

Administrator
avatar
加入于:
帖子: 129
声望: 14

试一下2.5.0版本的示例策略,看一下是否有问题

Administrator
avatar
加入于:
帖子: 129
声望: 14

如果还是不行,在template.py中203行的short函数中打印一下Direction.SHORT, Offset.OPEN, price, volume, stop, lock, net,看一下是多加了哪个参数

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

感谢解答,我再研究研究~~
郭易燔 wrote:

如果还是不行,在template.py中203行的short函数中打印一下Direction.SHORT, Offset.OPEN, price, volume, stop, lock, net,看一下是多加了哪个参数

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

沪公网安备 31011502017034号