How to get positions of your portfolio from Interactive Brokers with python IBPy?

How to get positions of your portfolio from Interactive Brokers with python IBPy?

Manage alerts

Loading saved threads...

Escachator · External communityPost link
External question — Quantitative Finance Stack Exchange Author: Escachator Original post: https://quant.stackexchange.com/questions/17371 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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.
Quote
Report
Castedo · External communityPost link
External answer — Quantitative Finance Stack Exchange Author: Castedo Original post: https://quant.stackexchange.com/a/17379 License: CC BY-SA 3.0 — https://creativecommons.org/licenses/by-sa/3.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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.
Quote
Report
hui · External communityPost link
External answer — Quantitative Finance Stack Exchange Author: hui Original post: https://quant.stackexchange.com/a/31588 License: CC BY-SA 3.0 — https://creativecommons.org/licenses/by-sa/3.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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.
Quote
Report

Post Reply

Checking account access…