Group orders with transmit but with 2 orders instead of 3?
-
So this will work:
self.E1 = self.buy(price=entry_price, size=size, exectype=bt.Order.Stop, transmit=False) self.SL1 = self.sell(price=stoploss_price, size=size, exectype=bt.Order.Stop, transmit=False, parent=self.E1) self.TP1 = self.sell(price=TP1_price, size=size, exectype=bt.Order.Limit, transmit=True, parent=self.E1)
This will not:
self.E1 = self.buy(price=entry_price, size=size, exectype=bt.Order.Stop, transmit=False) self.SL1 = self.sell(price=stoploss_price, size=size, exectype=bt.Order.Stop, transmit=True, parent=self.E1)
It gives an error saying
self.SL1 = self.sell(price=stoploss_price, size=size, exectype=bt.Order.Stop, transmit=True)
doesn't work because it is unpacked intoparent, stop
so it's expecting likeparent, stop = self.sell(price=stoploss_price, size=size, exectype=bt.Order.Stop, transmit=True, parent=self.E1)
for some reason, which is not the case if you had 3 likeTP1
.But I just want to group the entry with a stop, without take profit. How should this be done?
-
@booboothefool said in Group orders with transmit but with 2 orders instead of 3?:
elf.E1 = self.buy(price=entry_price, size=size, exectype=bt.Order.Stop, transmit=False)
self.SL1 = self.sell(price=stoploss_price, size=size, exectype=bt.Order.Stop, transmit=True, parent=self.E1)I'm not sure why you are experiencing an error. I've copied your code and working for me.
-
Oh, forgot to mention. It works perfectly fine in backtesting but craps out live.
-
This would create a one sided bracket order, while bt expects both sides. Not really sure why it worked for @run-out but bt broker will pop both sides and fail because only one order is available.
-
I fixed the issue with oanda broker. It will now assume, there is no stopside