简体   繁体   中英

Child orders (target and stop loss) in bracket order does not get sent to IB TWS using python code

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)

在此处输入图片说明

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM