Thanks for your reply. But I would like these orders to be executed on the close, next day. So I currently send my orders as "CLOSE". Can we achieve the same behavior ?
Posts made by sebs29
Buy and Sell Orders Execution order
I'm starting using backtrader, and I am running into an issue with orders execution. Here's my strategy:
- I define a set of stocks I want to invest on
- I select the two best according to some indicators, and invest 50% of my available cash on each. Everything works well until this point.
- At some point, I determine that the stocks I have in positions are not the right ones anymore, and I want to change my position. So I send sell orders to close the 2 existing positions, and then 2 buy orders to invest on 2 new stocks. These orders are setup to be executed on next day close.
My issue is sometimes, one of the buy order is treated before the sell orders. Then the order gets rejected because I don't have the cash available.
Is there a way to work around this please ?
Thank you !