Do I need to reset my IB connection to complete the cancellation of an order left open by a previous IB session? #126
Unanswered
6nc0r6-1mp6r0
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Have you tried with |
Beta Was this translation helpful? Give feedback.
1 reply
-
you should not call reqOpenOrders like that, just call it once after you create the connection. and this is not even needed because it's done for you automatically. sometimes somehow things get out of wack, and seems to be your case. reqOpenOrders should give you previously created orders by that clientId. connect to IB, if your order is not there, call reqOpenOrders and pray. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to cancel an order left open by a previous IB session (which could happen in the event of a power outage, bug in my code, IB-caused disconnect, etc.).
However, verifying that this order is indeed canceled appears to require that I disconnect from IB, reset the API object
ib
, then reconnect to IB with the newib
. For example, suppose that I start with an paper account that has one open limit order with an unrealistically low limit, and I try to cancel this limit order with the following code.This gives the following output:
A similar change from
LimitOrder
toOrder
occurs in theib.openOrders()
object when I disconnect from IB, reset the API objectib
, and reconnect to IB with the newib
, which seems to suggest that placement or submission of an order is similarly completed only after a full connection reset.From the Jupyter notebooks in the documentation, I might have imagined that I could do various operations like placing and canceling orders without this full disconnect and reset. Am I doing everything correctly here? Is there some way to "commit changes" such as cancellations without disconnecting from IB, or is the disconnection process itself the way that such changes are committed?
Beta Was this translation helpful? Give feedback.
All reactions