Stop orders on interactive brokers
I have a strategy that I'm implementing using the IB broker to interface with for my test account. Everything works great except stop orders. In my backtest strategy I have:
stop_order = self.close(data_min, price=stop_price, exectype=bt.Order.Stop) self.orders.append(stop_order)
Where data_min is the minute data feed I'm using. When stop orders are placed this way using exectype=bt.Order.Stop, there is no stop loss order created. Either with IB or within the strategy itself, if the price moves through the stop price, it never exits.
All of the other entries and exits with BT work great with IB.
Is there a specific exectype for IB market stop loss orders?
self.close is a market order, it doesn't use price and order type. self.buy or self.sell with appropriate order type need to be used.
The result is the same if I use:
stop_order = self.close(data_min, price=stop_price, exectype=bt.Order.Stop) stop_order = self.buy(data_min, price=stop_price, exectype=bt.Order.Stop) stop_order = self.sell(data_min, price=stop_price, exectype=bt.Order.Stop)
My hopes to this being resolved are fading quick. It doesn't appear, based on this and my other post about the getposition() bugs in live IB trading, that anyone is using BT for live equities trading.
Using the standard test code available in the sources, by simply forcing a
It simply works. You may want to share with us things like a working sample, how you execute the code ...
My hopes to this being resolved are fading quick
How quick are you expecting things to get resolved?
@ard9000 Did you get this working?