Bracker Order Questions
-
Hii,
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)
https://www.backtrader.com/docu/order-creation-execution/bracket/bracket/#sample-code
-
-
@gleetche said in Bracker Order Questions:
if self.p.switchp1p2:
p1, p2 = p2, p1
valid1, valid2 = valid2, valid1Ignore 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]
@gleetche said in Bracker Order Questions:
What is transmit in the bracket argument?
Transmit gets used when you are entering the orders separately, not like my example above. Setting
transmit=False
tells 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.