Position P&L
get_position_pnlRetrieve live daily, unrealized, realized P&L and market value for a single position by contract ID. Get exact figures for any held instrument through IB Gateway.
Instructions
Return the live P&L of one position: daily, unrealized, realized and market value.
Pass the position's con_id (from get_positions) for an exact match. Waits a few
seconds at most for IBKR's first update. Errors: not_found when the account has no
position and no P&L today in that contract; ambiguous_contract lists candidates;
invalid_request for a combo (BAG: ask per leg); request_timeout when IBKR sends nothing.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account | No | IBKR account id, e.g. DU1234567. Omit to use the default account; list_accounts shows which accounts are allowed. | |
| contract | Yes | The instrument. A con_id alone is unambiguous; otherwise give symbol and sec_type, plus expiry, strike and right for options. | |
| model_code | No | Financial-advisor model code, to scope the result to one model portfolio. Omit for the whole account (normal for non-advisor accounts). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| as_of | Yes | When this server read the values (UTC); IBKR refreshes P&L about every second. | |
| account | Yes | ||
| contract | Yes | ||
| position | No | Quantity held; 0 if closed today. | |
| daily_pnl | No | P&L since the start of today's session. | |
| model_code | No | ||
| market_value | No | Current market value of the position. | |
| realized_pnl | No | ||
| unrealized_pnl | No |