It works perfectly!
But my question was how do I get the settled cash in the account representing how much more can be bought?
Thankyou.
./rationalIMatstackoverflow.py
Testing IB's API as an imported library:
Waiting for IB's API response for accounts positions requests...
Symbol Quantity Average Cost Sec Type
Account
REDACTED SPY 23.0 423.203478 STK
REDACTED QQQ 29.0 338.424483 STK
Waiting for IB's API response for NAVs requests...
Empty DataFrame
Columns: [reqId, Account, Tag, Value, Currency]
Index: []
toggle quoted message
Show quoted text
On Jun 11, 2021, at 10:36 AM, Rational-IM <ds@...> wrote:
I made a few adjustments on the connection method - check back Stackoverflow. I hope it works for you. If you copy the main code and add at the bottom something like:
print("Testing IB's API as an imported library:")
all_positions = read_positions()
print(all_positions)
print()
all_navs = read_navs()
print(all_navs)
You should see your accounts positions and NAVs printed on your console. Make sure your TWS set-up is correct (e.g. that you are using port 7496 etc).