Skip to main content
Glama
staskh

trading-skills

by staskh

ib_trades_history

Retrieve Interactive Brokers trade executions with fills, commissions, realized P&L, and symbol-aggregated summaries. Use FlexReport tokens for full history beyond the ~7-day live API window.

Instructions

Fetch trade executions from Interactive Brokers.

Returns individual trade executions with fills, commissions, and realized P&L, plus aggregated summary by symbol. Uses live API (~7 days history) by default, or FlexReport for full history when token and query ID are provided. Requires TWS or IB Gateway running locally.

Args: port: IB port (7496 for live, 7497 for paper) account: Specific account ID (optional, fetches all if not specified) symbol: Filter trades by symbol (e.g., AAPL) start_date: Start date in YYYY-MM-DD format (default: Jan 1 of current year) end_date: End date in YYYY-MM-DD format (default: today) flex_token: FlexReport token for extended history beyond ~7 days flex_query_id: FlexReport query ID (required with flex_token). Pass a list of IDs to merge and deduplicate results from multiple queries — useful for spans exceeding the FlexReport 365-day per-query limit.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
portNo
symbolNo
accountNo
end_dateNo
flex_tokenNo
start_dateNo
flex_query_idNo
Behavior4/5

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

With no annotations, the description carries full weight for behavioral disclosure. It covers key behaviors: the 7-day default limit, the FlexReport fallback, the local gateway requirement, and the merging/deduplication of multiple query IDs. However, it doesn't mention error conditions or authentication details, though 'Fetch' implies a read-only operation.

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 well-structured: a one-sentence purpose, a brief summary of return content, a concise explanation of data sources, and a clear Args block. It is front-loaded with the action and avoids fluff, with each sentence providing necessary information.

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?

Despite no output schema, no annotations, and 7 parameters, the description is remarkably complete. It explains the two modes, all parameter defaults and formats, the local gateway prerequisite, and the edge case of 365-day limits per FlexReport query. Missing pieces like exact return structure are not critical given the absence of an output schema, and the description provides enough context for correct invocation.

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

Parameters5/5

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

Schema description coverage is 0%, but the description's Args section fully compensates by explaining every parameter: port numbers for live/paper, account behavior when omitted, symbol filtering with example, date formats with defaults, and flex_token/flex_query_id semantics including list merging for 365-day limits. This adds substantial meaning beyond the bare schema.

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 'Fetch trade executions from Interactive Brokers,' clearly stating a specific verb and resource. It further distinguishes itself by detailing the return content (fills, commissions, realized P&L, aggregated summary) and the two data-source modes (live API vs FlexReport), making it distinct from sibling tools like ib_portfolio_action_report.

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?

The description explains when to use the live API (~7 days history) versus FlexReport (full history) with token and query ID. It also notes the prerequisite of TWS/IB Gateway running locally. While it doesn't explicitly exclude alternatives or compare to siblings, it gives clear context for choosing the appropriate execution path.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/staskh/trading_skills'

If you have feedback or need assistance with the MCP directory API, please join our Discord server