vn.py量化社区
By Traders, For Traders.
Member
avatar
加入于:
帖子: 5
声望: 0

File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\backtesting.py", line 304, in run_backtesting
func(data)
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\backtesting.py", line 750, in new_bar
self.strategy.on_bar(bar)
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\strategies\cuatro_strategy.py", line 116, in on_bar
self.bg5.update_bar(bar)
File "C:\vnstudio\lib\site-packages\vnpy\trader\utility.py", line 282, in update_bar
self.on_window_bar(self.window_bar)
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\strategies\cuatro_strategy.py", line 154, in on_5min_bar
self.cover(self.short,abs(self.pos),stop=True)
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\template.py", line 173, in cover
return self.send_order(Direction.LONG, Offset.CLOSE, price, volume, stop, lock)
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\template.py", line 189, in send_order
self, direction, offset, price, volume, stop, lock
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\backtesting.py", line 954, in send_order
price = round_to(price, self.pricetick)
File "C:\vnstudio\lib\site-packages\vnpy\trader\utility.py", line 124, in round_to
value = Decimal(str(value))
decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]

请教老师,这个报错是什么回事呢?怎么解决呢,谢谢指导!

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

这里感觉是你的价格数据有问题了,Decimal库是用来做小数精确转化的。。。请问用的什么数据?

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

检查了一次发现有些代码敲错了,改正了.另外我看视频中的代码,请问这里是不是错了呢?
description

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

我也遇到这个问题了,lz解决了吗?

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

ax植敏锋 wrote:

检查了一次发现有些代码敲错了,改正了.另外我看视频中的代码,请问这里是不是错了呢?
description

确实是敲错了,应该是short_stop

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