4
$\begingroup$

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)
tws.reqAccountUpdates(True,'accountnumber')

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

$\endgroup$

2 Answers 2

3
$\begingroup$

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

tws.register(your_update_portfolio_handler,message.updatePortfolio)

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.

$\endgroup$
0
0
$\begingroup$

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.

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

Your Answer

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

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