VeighNa量化社区
你的开源社区量化交易平台
Member
加入于:
帖子: 39
声望: 0

遇到从由 tick 数据合成 分钟 bar 时,bar 数据没有成功取得最高价的问题
从 vnpy.trader.utility.py 中提取的代码
if new_minute:
self.bar = BarData(
symbol=tick.symbol,
exchange=tick.exchange,
interval=Interval.MINUTE,
datetime=tick.datetime,
gateway_name=tick.gateway_name,
open_price=tick.last_price,
high_price=tick.last_price,
low_price=tick.last_price,
close_price=tick.last_price,
open_interest=tick.open_interest
)
else:
self.bar.high_price = max(self.bar.high_price, tick.last_price)
if tick.high_price > self.last_tick.high_price:
self.bar.high_price = max(self.bar.high_price, tick.high_price)

        self.bar.low_price = min(self.bar.low_price, tick.last_price)
        if tick.low_price < self.last_tick.low_price:
            self.bar.low_price = min(self.bar.low_price, tick.low_price)

        self.bar.close_price = tick.last_price
        self.bar.open_interest = tick.open_interest
        self.bar.datetime = tick.datetime

按当前算法,当第一个 tick的 last_price < high_price ,并且该high_price是一分钟内最大值时,
合成的分钟 bar 的 high_price 将会小于 该一分钟内实际的最大值

同理,当第一个 tick 的 last_price < low_price ,并且该low_price是一分钟内的最小值时,
合成的分钟 bar 的 low_price 将会大于该一分钟内实际的最小值

Administrator
avatar
加入于:
帖子: 4502
声望: 321

收到,我们来排查下

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

沪公网安备 31011502017034号

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