写了一个跨周期MACD策略,用到了5分钟和1小时k线数据。1小时数据已经下载到数据库,但是,回测时提示没有self.close
策略源代码贴在这里 http://paste.debian.net/1227590/
回测错误如下:
10:02:03 触发异常,回测终止
10:02:03 Traceback (most recent call last):
File "/home/yinxiuqu/anaconda3/envs/vnpy2.8/lib/python3.7/site-packages/vnpy_ctastrategy/backtesting.py", line 228, in run_backtesting
self.callback(data)
File "/home/yinxiuqu/strategies/multi_timeframe_macd.py", line 71, in on_bar
self.bg1h.update_bar(bar)
File "/home/yinxiuqu/anaconda3/envs/vnpy2.8/lib/python3.7/site-packages/vnpy/trader/utility.py", line 268, in update_bar
self.update_bar_hour_window(bar)
File "/home/yinxiuqu/anaconda3/envs/vnpy2.8/lib/python3.7/site-packages/vnpy/trader/utility.py", line 383, in update_bar_hour_window
self.on_hour_bar(finished_bar)
File "/home/yinxiuqu/anaconda3/envs/vnpy2.8/lib/python3.7/site-packages/vnpy/trader/utility.py", line 388, in on_hour_bar
self.on_window_bar(bar)
File "/home/yinxiuqu/strategies/multi_timeframe_macd.py", line 111, in on_1hour_bar
self.dif1h, self.dea1h, self.hist1h = self.am1h.macd(self.close, self.fast_period, self.slow_period, self.signal_period)
AttributeError: 'MultiTimeframeMacd' object has no attribute 'close'