Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Closing parent orders (bracket orders) - what to do with child orders?

    General Discussion
    1
    2
    160
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      kfeeeeee last edited by

      Hi,
      Please forgive me if this is an already answered questions I couldn't find this specific information.

      I created a parent order with a child order being some kind of stop loss. Now, the parent order is executed and the child limit order is submitted/accepted as expected.

      self.buy_order = self.buy(transmit=False)
      
      stop_price = self.data.close[0] - 30
      
      self.buy_stop = self.sell(exectype=bt.Order.Stop, price=stop_price,
                              parent=self.buy_order)
      

      In some cases, I need to close my positions by some logic and my question is if I have to cancel the child orders manually, e.g.

      self.close()
      if self.buy_stop:
          self.cancel(self.buy_stop)
      

      or if there is a better approach to this?

      The same question applies for buy_bracket orders. If I close my positions, do I need to manually clean/cancel any associated child_orders stemming from the bracket order?

      Thanks!

      1 Reply Last reply Reply Quote 0
      • K
        kfeeeeee last edited by

        Differently put, is there a logic invoked if a parent order is closed regarding its child orders?

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors