Getting details about your portfolio
The IB API offers a comprehensive snapshot of portfolio data, returning 157 different portfolio values through a single API call. This data provides a detailed view of our portfolios, encompassing a wide range of metrics and data points. Account values delivered via updateAccountValue
can be classified in the following way:
- Commodities: Suffixed by
-C
- Securities: Suffixed by
-S
- Totals: No suffix
In this recipe, we’ll build the code to get those data points.
Getting ready
We assume you’ve created the client.py
, wrapper.py
, and app.py
files in the trading-app
directory. If not, do it now.
How to do it…
The first step is to incorporate the account number into our IBApp
class. While an account number is optional for requesting account-level data in a single account structure, it’s best practice to specify it in the case of multiple accounts. Then, we’ll add the callback to the IBWrapper...