VeighNa量化社区
你的开源社区量化交易平台
Member
avatar
加入于:
帖子: 16
声望: 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
加入于:
帖子: 4502
声望: 322

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

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

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

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】