[Mod]增加BarGenerator计算成交量时对tick成交量的负值过滤

This commit is contained in:
vn.py 2018-05-07 23:08:38 +08:00
parent a89d64dc32
commit a2180e48ee

View File

@ -398,7 +398,8 @@ class BarGenerator(object):
self.bar.openInterest = tick.openInterest
if self.lastTick:
self.bar.volume += (tick.volume - self.lastTick.volume) # 当前K线内的成交量
volumeChange = tick.volume - self.lastTick.volume # 当前K线内的成交量
self.bar.volume += max(volumeChange, 0) # 避免夜盘开盘lastTick.volume为昨日收盘数据导致成交量变化为负的情况
# 缓存Tick
self.lastTick = tick