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/

    How to prevent multiple submission of limit / bracket orders?

    General Discussion
    3
    6
    1836
    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.
    • T
      Taewoo Kim last edited by

      How would you prevent BT from submitting the same limit or bracket order with same limitprice , price, and/or stopprice? Do i need to keep an internal list in the strategy and delete accordingly in notify_order/trade?

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        The platform cannot know if the order has the same prices because you made an error or because you want to be matched with two different orders to achieve a 2 x size position.

        Sending consecutive orders with the same parameters is far from uncommon and is used for example to avoid showing the actual size of your trade to those watching the order book. If you send one order with 100 contracts, people may understand you have a strong interest in entering the market and move away from your price, forcing you to chase the price.

        You need to keep control of what you send.

        1 Reply Last reply Reply Quote 0
        • T
          Taewoo Kim last edited by

          that's a good point. Thanks. I thought there was some BT api that I missed.

          Random note: that's interesting.. are there any good references / books that show examples of how people exploit volume in order book (both from offensive and defensive measures)?

          1 Reply Last reply Reply Quote 0
          • B
            backtrader administrators last edited by

            You'll probably have more luck in a larger audience forum (a subreddit about trading may do) The approach is not limited to algorithmic trading.

            T 1 Reply Last reply Reply Quote 0
            • T
              Taewoo Kim @backtrader last edited by

              @backtrader Good point. Thank you

              1 Reply Last reply Reply Quote 0
              • X
                xnox last edited by

                I do keep a simple set of my order levels, add working orders to the set, and remove them when they are fully closed or expire. That way in next I can check what I need to reopen.

                I have tried to write a custom fill order function which would reject duplicate orders, but it felt a lot more error prone than simply tracking state and not submitting duplicates.

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