In my broker when sending an order, I can set stop-loss and take-profit levels on it. Such that e.g. I can send a limit buy order, with stoploss and takeprofit levels and forget about it. It will either remain open, or close with profit/loss. Simulating this with backtrader appears to result in errors.
In order notification, if buy order is executed I execute two sell orders: one limit order with stop loss, and one stop order with take profit. This eventually fails and results in stategy executing both of the sell orders. Ideally if one of these sell orders is executed, i would like the other one to be instantly killed.
How should I code takeprofit/stoploss on my positions?
Should I extend the bbroker itself to support stoploss/takeprofit?