I have some automated trading software that uses IB's ActiveX connection. If IB closes out one of your trades (due to lack of margin for example), is there any message sent back to the software through the orderStatus() event or some other event or does the software continue on not knowing that the trade has been closed out? Haven't asked IB yet. Was just hoping for a quick answer. Thanks for any help
There is an updatePortfolio() event that fires about once per minute to show what's open. If you monitor that, it should keep you informed.
Just ask IB if the orderStatus() event is fired when IB is closing out your trades. UpdatePortfolio() is one way. Another way is to have your program poll for the information by encapsulating IB's reqExecutions() method call in a Timer. Set the Timer at reasonable intervals. When you call the reqExecutions() method, the corresponding execDetails() event will be fired for each open position. You then compare these open positions with the ones your software recorded from your autotrading fill confirmations. Have your application send an alert when there's a mismatch.
The execution details message contains a field called m_liquidation which will be set to true if the execution happened as a result of a liquidation.