For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Children order in Bracket Order can no be executed in the day
-
I have a question about the execution of the children order (the take profit order) in a bracket order.
Each day, I place a parent order to buy at 74.70 and its child to take profit at 75.18.
At 2020-02-03, the buy order (74.70) is successfully executed during the day. Then the day is closed at 76.26, which means the price has certainly go through the take-profit order's price (at 75.18) before the day is closed. However, it has not been executed.
Here is the log:
2020-01-31, Open: 79.29, High: 79.72, Low: 76.17, Close: 76.47 2020-02-03, ORDER Accepted, Price: 74.70, isbuy True 2020-02-03, ORDER Accepted, Price: 75.18, isbuy False 2020-02-03, BUY EXECUTED, Price: 74.70, Cost: 747.00, Comm 0.75 2020-02-03, Open: 75.18, High: 77.45, Low: 74.67, Close: 76.26 2020-02-04, ORDER Accepted, Price: 74.70, isbuy True 2020-02-04, ORDER Accepted, Price: 75.18, isbuy False 2020-02-04, SELL EXECUTED, Price: 77.90, Cost: 747.00, Comm 0.78 2020-02-04, OPERATION PROFIT, GROSS 32.00, NET 30.47 2020-02-04, Open: 77.90, High: 78.97, Low: 77.49, Close: 78.78 2020-02-04, (MA Period 20) Ending Value 10030.47
And the next() function in my strategy:
def next(self): # Simply log the closing price of the series from the reference self.log('Open: %.2f, High: %.2f, Low: %.2f, Close: %.2f' % (self.dataopen[0], self.datahigh[0], self.datalow[0], self.dataclose[0])) self.define_orders_for_next_day() def stop(self): self.log('(MA Period %2d) Ending Value %.2f' % (self.params.maperiod, self.broker.getvalue()), doprint=True) def define_orders_for_next_day(self): this_long = self.buy(price=74.70, exectype=bt.Order.Limit, transmit=False, size= 10) limit_long = self.sell(price=75.18, exectype=bt.Order.Limit, transmit=True, parent=this_long, size= this_long.size)
Since the parent order has been executed, why the child order can not be executed even if its trigger price has been hit?
Thanks for your responses !