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

一直报错
close = am.close pre_max = self.pre_max pre_min = self.pre_min if(close[-1]>=pre_max[-1] and close[-2] <=pre_max[-2]): if self.postion > 0: self.sell(bar.close_price,1)

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

File "c:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\backtesting.py", line 286, in run_backtesting
self.callback(data)
File "C:\Users\79119\strategies\pf.py", line 581, in on_bar
if(close[-1]>=pre_max[-1] and close[-2] <=pre_max[-2]):
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

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

请问有办法debug吗 或者打log

Member
avatar
加入于:
帖子: 936
声望: 47

应该是你在拿一列数和一个值相比较。你可以试着打印一下这几个变量或者打印它们的类型看看

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

xiaohe wrote:

应该是你在拿一列数和一个值相比较。你可以试着打印一下这几个变量或者打印它们的类型看看
怎么打印呢,self.write_log好像没用

Member
avatar
加入于:
帖子: 936
声望: 47

用print就行了,可以用run.py打开vnstation

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

xiaohe wrote:

用print就行了,可以用run.py打开vnstation
多谢

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

if(close[-1],这里的close,应该只是一个数值。ArrayManager里有close_array,用am.close_array[-1]试试

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