How to prevent multiple submission of limit / bracket orders?



  • 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?


  • administrators

    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.



  • 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)?


  • administrators

    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.



  • @backtrader Good point. Thank you



  • 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.


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.