Clarifying parent-child order behavior
I'm looking to attach child
Stoporders to my main
Limitorders for downside protection. Like this (from example here):
o1 = self.buy(data=d, exectype=bt.Order.Limit, price=p, valid=valid, transmit=False) o2 = self.sell(data=d, exectype=bt.Order.Stop, price=pstp, size=o1.size, transmit=True, parent=o1)
Note that only the main
o1, has a
I'd like to clarify three points:
1. When the main
Limitorder is only partially filled, are
This post in the Multi Example thread:
The stop-loss and take-profit orders are created but... Are created inactive and will only become active (available for execution) if the parent is Completed
suggests that the
Stoporders are inactive if parent is not Completed.
So, that means that while the main
Limitorder is being filled, there is no protection even though a
Stoporder was submitted with the main
2. When the main
Limitorder expires (not canceled), does the child
Stoporder expire too?
Per the strategy docs:
parent (default: None)
Controls the relationship of a group of orders, for example a buy which is bracketed by a high-side limit sell and a low side stop sell. The high/low side orders remain inactive until the parent order has been either executed (they become active) or is canceled/expires (the children are also canceled) bracket orders have the same size
The Stop trading docs here https://www.backtrader.com/blog/posts/2018-02-01-stop-trading/stop-trading.html say:
If the parent order is cancelled, the child order will also be cancelled
But do not mention expiry.
It seems very counter intuitive that the
Stopwould not protect against size filled by the
Limitorder (esp. since the
Stopdid not have an expiry set on it), but would love clarification. And, it would be very helpful to describe that explicitly in the
3. Does Backtrader's Interactive Brokers implementation support "manual" parent-child relationships?
I believe bracket orders are implemented, but if we submit a parent-child manually per above, does IB see this as a parent-child pair? Since the OCO docs state:
This is only implemented in backtesting and there isn’t yet an implementation for live brokers
I'd like to clarify since this seems to be a way to achieve implicit OCO behavior for a live broker.
Thank you very much!