2
$\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.

Thanks

$\endgroup$
2
$\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$
  • $\begingroup$ That's correct. I have edited your answer to put the correct field: message.updatePortfolio, for future reference. Thanks a lot! $\endgroup$ – Escachator Apr 15 '15 at 14:20
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$
  • $\begingroup$ The least you could do is add a disclaimer indicating you are the author of IBridgePy $\endgroup$ – mementum Dec 22 '16 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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