Appearance
Account & Portfolio
Account Summary
python
account = client.get_account()
# or
account = client.get_account_summary() # AliasReturns: Account dataclass
python
Account(
account_id='DUO903441',
net_liquidation=1004242.125,
available_funds=1002600.0625,
buying_power=6684000.5
)| Field | Type | Description |
|---|---|---|
account_id | str | IBKR account ID |
net_liquidation | float | Net liquidation value |
available_funds | float | Available funds for trading |
buying_power | float | Total buying power |
Account ID
python
account_id = client.get_account_id() # Returns strAccount Values
python
values = client.get_account_values()
net_liq = client.get_account_value("NetLiquidation")
buying_power = client.get_account_value("buying_power")Returns: Dict[str, Any] with both original and normalized keys.
This is the migration-friendly equivalent of ib.accountValues().
P&L
python
pnl = client.get_pnl()Returns: Dict with daily_pnl, unrealized_pnl, realized_pnl, total_pnl, net_liquidation.
Position P&L
python
pnl = client.get_position_pnl("AAPL")Margin
python
margin = client.get_margin()Returns: Dict with buying_power, available_funds, and margin requirements.
Positions
python
positions = client.get_positions()Returns: List[Position]
python
Position(
conid=265598,
symbol='AAPL',
position=7.0,
avg_cost=279.90,
market_value=1784.07,
unrealized_pnl=-175.24,
asset_class='STK'
)| Field | Type | Description |
|---|---|---|
conid | int | Contract ID |
symbol | str | Ticker symbol |
position | float | Quantity (negative = short) |
avg_cost | float | Average cost basis |
market_value | float | Current market value |
unrealized_pnl | float | Unrealized P&L |
asset_class | str | Asset class (STK, OPT, etc.) |
Position Caching
get_positions() uses a 1-second in-memory cache. Rapid consecutive calls return cached data.
python
client.invalidate_position_cache() # Clear cache after placing orders
positions = client.get_positions(force_refresh=True) # Force fresh fetchSingle Position
python
position = client.get_position("AAPL") # Returns Position or None
has = client.has_position("AAPL") # Returns bool
qty = client.get_open_position("AAPL") # Returns float (0 if none)Close Position
python
result = client.close_position("AAPL") # Market order to flattenReturns: OrderResult
Orders
python
orders = client.get_orders()
# or
orders = client.get_open_orders() # AliasReturns: List[Dict] - All orders from IBKR
python
{
'orderId': 1499005467,
'order_ref': 'AQC-PNDVMMR-1769445542279',
'description1': 'NVDA',
'side': 'SELL',
'orderType': 'Market',
'status': 'Filled',
'filledQuantity': 6.0,
'remainingQuantity': 0.0,
'avgPrice': '186.90',
'price': ''
}Common fields:
| Field | Type | Description |
|---|---|---|
orderId | int | IBKR order ID |
order_ref | str | cOID with strategy ID |
description1 | str | Symbol |
side | str | BUY / SELL |
orderType | str | Market / Limit / Stop |
status | str | Filled / Submitted / Cancelled |
filledQuantity | float | Filled size |
remainingQuantity | float | Remaining size |
avgPrice | str | Average fill price (string) |
Open Trades
python
open_trades = client.get_open_trades()Returns: List[OpenTrade] for working orders only (submitted/presubmitted).
python
OpenTrade(
order_id='1499005467',
symbol='NVDA',
side='SELL',
quantity=6.0,
status='Submitted',
filled_quantity=0.0,
remaining_quantity=6.0,
avg_fill_price=None,
conid=4815747,
order_ref='AQC-PNDVMMR-1769445542279'
)Trades
python
trades = client.get_trades()Returns: List[Dict] - Recent executions (fills)
python
{
'execution_id': '00025b49.697429fe.01.01',
'order_id': 1499005467,
'order_ref': 'AQC-PNDVMMR-1769445542279',
'symbol': 'NVDA',
'side': 'B',
'size': 6.0,
'price': '186.90',
'commission': '1.79',
'trade_time': '20260126-16:39:02',
'exchange': 'NASDAQ.NMS',
'conid': 4815747
}| Field | Type | Description |
|---|---|---|
execution_id | str | Unique execution ID |
order_id | int | Parent order ID |
order_ref | str | cOID with strategy ID |
side | str | 'B' (buy) or 'S' (sell) |
size | float | Filled quantity |
price | str | Fill price |
commission | str | Commission charged |