Conditional Orders with Interactive Brokers API using IB-Insync in Python

preview_player
Показать описание
Conditional Orders with Interactive Brokers API using IB-Insync

Orders conditional on price, time, volume,margin, etc..
Рекомендации по теме
Комментарии
Автор

Hi there, your channel is by far the best out there for people using ib_insync in general. I had a doubt on how to place a stoploss order for an iron condor after we enter using combo legs, bag type
Thanks again

usdgod
Автор

Your series is so excellent! Do you have any material on Execution Condition? I'm trying to submit the second leg of a spread after the first leg is filled, and I'd like a way to do that without callbacks. Is this possible? I can't find much on Execution Condition orders. Thanks!

ShameelArafin
Автор

This is very useful for me. I see this as a way to place an options limit order for a breakout based on the underlying price. Is there a way to change the conditions without canceling the order and resubmitting it? I know there is a modify conditions only as each bar is updated? And then modify just an attached stop loss after the main one executes? I read there is a soft limit of 20 cancelled and resubmitted orders per fill before IBKR starts to get unhappy.

To give context: I'm specifically thinking of a breakout entry when the price rises above the highest of the last 3 bars. And a stop loss based on the lowest of the last 3 bars minus an ATR. Both the entry and stop would need to change as price progresses on the underlying.

I have this working in my paper account with an on_bar_update call back that dynamically updates the strike to the ATM strike, but the entry and exits are based on if statements that are only triggered once per bar, so lag real time of where a stock limit order or stock stoploss would execute. I think that an expansion of this video about conditions would fix that. It would leave a live order on the server to be filled as soon as the underlying passes the condition triggers. Also, if the stop loss is attached, it would prevent an issue in the event of an internet outage.

I could also see doing this with two different bar sizes with reqRealTimeBars, but I'm inclined to the conditions, especially for the stop loss.

This might make a good future video (please forgive me if you made one) - how to submit a combo or bag order and then modify the remaining order as price progresses.

mattHibbs
Автор

In this video around minute 24, you explain how to create a call back that will update the lmtPrice of an order. I am using ib.poistions() to determine if I need to place a stop loss or new entry and using >0 and <0 to decide if that stop loss needs to be for a short entry or a long entry. I'm running into issues where I have disconnected the program and reconnected - my self.orderLong.order.lmtPrice variable disappears. Is there a way to reload the variable with the information in ib.openOrders() or some similar function in case of disconnect?

I'm trying self.futuresShortStop = self.ib.openTrades()[0], but this don't know if there is a more elegant way. I recognize this only works because I only have one order in place at a time. I'd somehow need to short though the openTrades if there were more than one. Thanks for your help!

mattHibbs
Автор

do you have or know any discord communities that discuss ibkr APIs, as you know the ibkr APIs are clunky :(

stockjanitor
visit shbcf.ru