I am using IBPy to get the positions of my portfolio. I understand that I can do:

from ib.opt import ibConnection
tws = ibConnection( host = 'localhost',port= 7496, clientId = 123)

and then I am supposed to use updatePortfolio() in some way, but I don't know how.


2 Answers 2


The IB API calls your code asynchronously when there are account updates after you have called reqAccountUpdates. But you have to provide a callback function (handler) for the IB API to call.

Looks like from the [ibPy documentation example] (https://code.google.com/p/ibpy/wiki/IbPyOptional) and how the Java IB API is defined, you want to call


where your_update_handler is a function you define to handle account updates.

You probably need to look through the ibPy code to confirm 'updatePortfolio' is indeed what should be passed to tws.register.


Interactive Brokers posted a recorded webinar at youtube on Dec 13 2016. https://www.youtube.com/watch?v=hogXB07OJ_I The topic is to use IBridgePy, a flexiable and easy-to-use python tool to trade at IB. You can easily get the positions in IBridgePy.

  • 1
    $\begingroup$ The least you could do is add a disclaimer indicating you are the author of IBridgePy $\endgroup$
    – mementum
    Commented Dec 22, 2016 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.