Bracker Order Questions
I am trying to use bracket orders in my strategy and I can't grasp it enough to implement it.
Can anyone explain to me what is the strategy of the sample code?
What is this switching function in the sample code?
if self.p.switchp1p2: p1, p2 = p2, p1 valid1, valid2 = valid2, valid1
- What is transmit in the bracket argument?
mainside = self.buy(price=13.50, exectype=bt.Order.Limit, transmit=False)
run-out last edited by
p1, p2 = p2, p1
valid1, valid2 = valid2, valid1
Ignore this for now, the docs tend to try to provide all possibilties when entering at the terminal using args.parse.
Here is simple example of a bracket order.
order = self.buy_bracket( size=size, exectype=bt.Order.Market, stopprice=stop_price, stopexec=bt.Order.Stop, limitprice=limit_price, limitexec=bt.Order.Limit, )
Order will be a list containing the three orders like:
[entry_order, stop_order, limit_order]
What is transmit in the bracket argument?
Transmit gets used when you are entering the orders separately, not like my example above. Setting
transmit=Falsetells backtrader not to execute the first order by itself. Wait until all the orders are arranged, and then enter them (transmit) them together, so that the first order can be connected to later orders.