erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.84k stars 768 forks source link

positions() and portfolio() inconsistent #442

Closed marksandstrom closed 2 years ago

marksandstrom commented 2 years ago

For our live trading account, ib.positions() and ib.portfolio() return inconsistent results, per below:

from ib_insync import * util.startLoop() ib = IB() ib.connect('127.0.0.1', 7496, clientId=1) <IB connected to 127.0.0.1:7496 clientId=1> len(ib.positions()) 5 len(ib.portfolio()) 0

Why is len(ib.portfolio()) 0, while len(ib.positions()) is 5?

The true number of portfolio items is 5.

Thanks for advice!

image

erdewit commented 2 years ago

You probably have multiple accounts. portfolio is for the default account, positions is for all accounts.