This repository has been archived by the owner on Mar 14, 2024. It is now read-only.
Adjusting Orders within an OCA group #512
Unanswered
TradingData684
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I am trying to change the auxPrice and lmtPrice of a Stop & Limit Order within an OCA Order. The documentation suggests that this is easly done with ib.placeorder, but in my case this creates two new orders instead of modifying the old ones. What am I doing wrong?
The contract info is pulled from somwhere else, here it can be assumed that it is correct, since it places the order for the rigth contract
for order in ib.openOrders():
if order.orderType == 'STP':
stp_price = order.auxPrice
oca_group = order.ocaGroup
if order.orderType == 'LMT':
lmt_price = order.lmtPrice
contract = Option(symbol, current_date, strike, right, 'CBOE', 100, 'USD')
ib.qualifyContracts(contract)
stp_price -= 0.2
lmt_price += 0.2
TakeProfitOrder = StopOrder("BUY", quantity, stp_price)
StoppLossOrder = LimitOrder("BUY", quantity, lmt_price)
oca_order = ib.oneCancelsAll([TakeProfitOrder, StoppLossOrder], oca_group, 1)
for order in oca_order:
ib.placeOrder(contract, order)
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions