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

AttributeError Traceback (most recent call last)

<ipython-input-53-aff6de7ed614> in <module>
1 dfp = df1 + df2
2 dfp =dfp.dropna()
----> 3 show_portafolio(dfp)

<ipython-input-52-9b0c05b4f9b4> in show_portafolio(df)
20 def show_portafolio(df):
21 engine = BacktestingEngine()
---> 22 engine.calculate_statistics(df)
23 engine.show_chart(df)

c:\vnstudio\lib\site-packages\vnpy_ctastrategy\backtesting.py in calculate_statistics(self, df, output)
394
395 total_return = (end_balance / self.capital - 1) 100
--> 396 annual_return = total_return / total_days
self.annual_days
397 daily_return = df["return"].mean() 100
398 return_std = df["return"].std()
100

AttributeError: 'BacktestingEngine' object has no attribute 'annual_days'

源码我没有改,我看源码应该是有annual_days的,不知道为啥报错??vnpy版本为最新

Member
avatar
加入于:
帖子: 2788
声望: 189

在vnpy_ctastrategy.backtesting下的第56行加上self.annual_days: int = 240的定义试试看吧

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

沪公网安备 31011502017034号