vn.py官网
开源量化社区
Member
avatar
加入于:
帖子: 32
声望: 1

amplitude_volatility_strategy.py

def on_bars(self, bars: Dict[str, BarData]):
        """"""
    self.cancel_all()
    for vt_symbol, bar in bars.items():
        am: ArrayManager = self.ams[vt_symbol]
        am.update_bar(bar)
        amplitude = (am.high() - am.low()) / am.open()

backtesting.py

show_result(AmplitudeVolatilityStrategy)

2021-09-03 12:59:53.723812 触发异常,回测终止
2021-09-03 12:59:53.725859 Traceback (most recent call last):
File "c:\vnstudio\lib\site-packages\vnpy\app\portfolio_strategy\backtesting.py", line 192, in run_backtesting
self.new_bars(dt)
File "c:\vnstudio\lib\site-packages\vnpy\app\portfolio_strategy\backtesting.py", line 521, in new_bars
self.strategy.on_bars(bars)
File "C:\zwrk\vnpy\dev\amplitude_volatility_strategy.py", line 119, in on_bars
amplitude = (am.high() - am.low()) / am.open()
TypeError: 'numpy.ndarray' object is not callable

ArrayManager中有high函数呀,怎么回事?

Administrator
avatar
加入于:
帖子: 4997
声望: 292

这里因为high/low/open使用了@property装饰器,所以无需后面的(),写成这样即可:

amplitude = (am.high - am.low) / am.open

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

沪公网安备 31011502017034号