Reputation: 51
I have the code below - python code using ib_insync to connect and place a bracket order for a ticker. However, only the first order, the parent order, gets submitted. The child orders (target and stop loss) don't get submitted. I am a bit stumped and not sure where/what the error is?
from ib_insync import*
#create connection
ib = IB()
ib.connect(host='xxx.x.x.x', port=xxxx, clientId=1)
ticker_symbol = "CAN"
ticker_contract = Stock(ticker_symbol,'SMART','USD')
ib.qualifyContracts(ticker_contract)
ticker_bracket_order = ib.bracketOrder('BUY',100,8.51,8.68,4.26)
#place bracket order
for ord in ticker_bracket_order:
ib.placeOrder(ticker_contract, ord)
Upvotes: 0
Views: 1533
Reputation: 51
I have managed to get a resolution to the problem from some kind individual on another forum/group. In case, some other person encounters this same problem in future, what resolved it was inserting " ib.sleep(1)" right after "ib.placeOrder(ticker_contract,ord)
Upvotes: 2