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

回测停止单被错误触发 #3521

Closed
cloudseasail opened this issue Mar 22, 2024 · 1 comment
Closed

回测停止单被错误触发 #3521

cloudseasail opened this issue Mar 22, 2024 · 1 comment
Labels

Comments

@cloudseasail
Copy link

环境

  • 操作系统: Debian
  • Python版本: 3.10
  • VeighNa版本: V3.9.0

Issue类型

Bug

重现步骤

回测的时候,在用limit_order 开单成功后,在 on_trade() 里面新下一个止损的停止单。
这个停止单会被当前bar 触发成交,这是不合理的

问题分析

backtesting 的执行逻辑如下,cross_limit_order() 里面触发 on_trade(), 然后新发出一个止损的stop_order。
这个stop_order 会被下面的 cross_stop_order() 触发成交,当前bar 已经走完,这里触发成交是不合理的。

` def new_bar(self, bar: BarData) -> None:
""""""
self.bar = bar
self.datetime = bar.datetime

    self.cross_limit_order()
    self.cross_stop_order()
    self.strategy.on_bar(bar)

`

@vnpy vnpy added the invalid label Mar 22, 2024
@vnpy
Copy link
Owner

vnpy commented Mar 22, 2024

请在这里开issue:https://github.com/vnpy/vnpy_ctastrategy

@vnpy vnpy closed this as completed Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants