Skip to main content
Glama
aiordanescu

ib-gateway-mcp

by aiordanescu

Position P&L

get_position_pnl
Read-only

Retrieve 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

TableJSON Schema
NameRequiredDescriptionDefault
accountNoIBKR account id, e.g. DU1234567. Omit to use the default account; list_accounts shows which accounts are allowed.
contractYesThe instrument. A con_id alone is unambiguous; otherwise give symbol and sec_type, plus expiry, strike and right for options.
model_codeNoFinancial-advisor model code, to scope the result to one model portfolio. Omit for the whole account (normal for non-advisor accounts).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
as_ofYesWhen this server read the values (UTC); IBKR refreshes P&L about every second.
accountYes
contractYes
positionNoQuantity held; 0 if closed today.
daily_pnlNoP&L since the start of today's session.
model_codeNo
market_valueNoCurrent market value of the position.
realized_pnlNo
unrealized_pnlNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond the readOnlyHint and openWorldHint annotations, the description discloses useful runtime behavior: 'Waits a few seconds at most for IBKR's first update' and enumerates four distinct error modes with their triggers (not_found, ambiguous_contract, invalid_request, request_timeout). This gives the agent realistic expectations about latency and failure handling.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is four sentences, front-loaded with purpose, followed by the key input trick, the latency behavior, and a compact error list. Every sentence contributes meaning; there is no filler or repetition of schema content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that an output schema exists (return values are covered there) and annotations declare read-only behavior, the description covers the remaining needs: what the tool does, how to identify the position, expected latency, and possible errors. For a read-only single-position query tool, nothing essential is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description adds value by instructing the agent to pass the position's con_id 'from get_positions' for an exact match, which is a workflow hint beyond the schema's generic ContractSpec description. It also clarifies combo handling with 'ask per leg'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Return the live P&L of one position' and enumerates the components (daily, unrealized, realized, market value). This clearly distinguishes it from siblings like get_pnl (portfolio-level) and get_positions (positions list).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives concrete usage guidance: pass the con_id from get_positions for an exact match, and it warns that combos (BAG) trigger invalid_request, implying an alternative approach per leg. However, it does not explicitly name alternative tools for aggregate P&L or when not to use this tool beyond the combo case, so it stops short of a full 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.