我用的是30分的周期:需要拿之前几天的close或high,直接拿self.am30.close[-2],可以使用吗?
发现self.am30.close[0]和bar.close,不一致是什么原因啊?若是不能直接用,我是不是需要做个变量来保存每次的30m的k线值
我用的是30分的周期:需要拿之前几天的close或high,直接拿self.am30.close[-2],可以使用吗?
发现self.am30.close[0]和bar.close,不一致是什么原因啊?若是不能直接用,我是不是需要做个变量来保存每次的30m的k线值
def update_bar(self, bar: BarData) -> None:
"""
Update new bar data into array manager.
"""
self.count += 1
if not self.inited and self.count >= self.size:
self.inited = True
self.open_array[:-1] = self.open_array[1:]
self.high_array[:-1] = self.high_array[1:]
self.low_array[:-1] = self.low_array[1:]
self.close_array[:-1] = self.close_array[1:]
self.volume_array[:-1] = self.volume_array[1:]
self.turnover_array[:-1] = self.turnover_array[1:]
self.open_interest_array[:-1] = self.open_interest_array[1:]
self.open_array[-1] = bar.open_price
self.high_array[-1] = bar.high_price
self.low_array[-1] = bar.low_price
self.close_array[-1] = bar.close_price
self.volume_array[-1] = bar.volume
self.turnover_array[-1] = bar.turnover
self.open_interest_array[-1] = bar.open_interest
从这个代码上看应该是bar更新到了am30上了,但是值确不一样,什么原因?
如果要拿最新的K线收盘价,应该用am30.close[-1],你应该对下标方向理解反了
self.am30.close_array[-2]这样取才对
谢谢