Order execution issue
I'm stuck with the following situation:
I have 3 bars (OHLC):
I make a sell_bracket order at the first bar with the params:
self.sell_bracket( size=size, price=65, exectype=bt.Order.Market, stopprice=70, stopexec=bt.Order.StopLimit, limitprice=None, limitexec=None )
Both orders from the bracket are accepted at the next bar, and the sell order is completed. But my buy order is not triggered at the second bar., and this order won't be triggered at the third bar also. This issue can be solved by adding data feed filter BarReplayer_Open, but the time for one run rises 4x. Is there any other way to make this order status Completed at the second bar?
I don't see any issues here. Bracket order is issued on the 1st bar, broker notified, then main order is executed on the 2nd bar, broker notified, now stop order is active starting from the 3rd bar.
To get quicker notofications move to lower timeframe.
I managed to achieve my goal by dividing bracket order and using
next_openmethod to issue stop-loss order.
But when you use bracket order, it's assumed that you notify broker about these 2 or 3 orders at the same time. It would be great to have something like
process_orders_on_close=True, because i have my time for one run increased 2x with this solution.
But when you use bracket order, it's assumed that you notify broker about these 2 or 3 orders at the same time.
There are number of notifications sent. Some of them such as
acceptedgoes at the same time. Notifications like
completedcan't go at the same time by
bracketorder idea. Your
mainorder can be executed only on the 2nd bar and (logically) you will know this only at the end of the 2nd bar. How do you plan to know at the end of the first bar that it is executed?
It would be great to have something like process_orders_on_close=True, because i have my time for one run increased 2x with this solution.
Sure, but time machine is not invented yet.
How do you plan to know at the end of the first bar that it is executed?
I can know that cause I place an order with
exectype=bt.Order.Market, not with
Limitone, so I assume that my stop-loss order should be ready to catch the price change from the moment my
Jeffrey C F Wong last edited by
@Anton-Kozin I am trying to do something similar where I failed using cheat-on-open and quicknotify unfortunately. Would it be possible for you to share your solution on how you used next_open?