Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix: 如果BarGenerator在初始化的时候, 没有设置X分钟线, 就会出现除0错误 #1732

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
2 participants
@guo9310
Copy link

commented May 22, 2019

Solution: 先判断X > 0

@vnpy

This comment has been minimized.

Copy link
Owner

commented May 23, 2019

没有设置的情况下,不应该调用updateBar去更新K线,这里触发报错是正常的预期,而不应该通过判断给过滤掉(更没法查)

@vnpy vnpy closed this May 23, 2019

@guo9310

This comment has been minimized.

Copy link
Author

commented May 23, 2019

了解了,确实没有设置X分钟线,就不应该调用updateBar去更新X分钟线。

现在的累计K线流程是:

strategy.updateTick -> bg.updateTick -> strategy.onBar-> bg.updateBar ->Strategy.onXBar

是不是应该通过bg.updateTick来同时更新strategy.onBar和bg.updateBar,这样把所有K线更新逻辑封装起来,更清晰,而且不容易犯错误。

累计K线流程变成:

strategy.updateTick -> bg.updateTick -> strategy.onBar
                                     -> bg.updateBar -> strategy.onXBar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.