How do you handle asynchronous nature of IB API?

Discussion in 'Automated Trading' started by Chronos.Phenomena, Oct 5, 2010.

  1. You must not rely on the account updates for automated trading. There are several reason why that is not advisable nor it is a general approach (for now just trust the statement :) and let's not dig on all the reasons).

    As already suggested, the way to do that is to keep the information about each order and as soon as any new piece of info is received (eg. a partial fill event, or a new status, or an error, etc.), immediately update the order info, and both position and all PNL computations.

    You also need to carefully monitor the "error messages" and a few other events for complete order management. Keep in mind that even when you receive a "rejected" status, the broker may still hold the orders and, for instance, if you continue submitting believing that the orders have been "removed", you may find yourself suddenly with an enormous position when you don't expect it and even bankrupt the account in seconds.
    (You will see that it takes a lot of time and thinking to get straight all the small details, even those you can't imagine at the moment.)
     
    Last edited: Sep 30, 2015
    #71     Sep 30, 2015