Fetch trade executions from Interactive Brokers filtered by account, date range, or symbol. Supports live API (~7 days history) and FlexReport (full history). Use when user asks about their trades, executions, or transaction history. Requires TWS or IB Gateway running locally.
npx skills add https://github.com/staskh/trading_skills --skill ib-trades-history
Fetch trade executions from Interactive Brokers.
TWS or IB Gateway must be running locally with API enabled:
IB_PORT env var — default port when --port is omitted (e.g. IB_PORT=4001 for a Gateway container). Precedence: --port flag > IB_PORT > built-in default. Set it in the shell or a .env file.Port fallback: If the configured port fails, automatically retry on the other port.
If the retry succeeds, save to memory which account type worked (live/paper) and reuse it for all IB skill calls in this and future sessions — until the user explicitly asks for the other account.
If both ports fail, ask the user to verify that TWS or IB Gateway is running with API access enabled.
For full trade history beyond ~7 days, the user needs a Flex Web Service token and a pre-configured Trade query in IBKR Account Management.
> Note: If uv is not installed or pyproject.toml is not found, replace uv run python with python in all commands below.
# Recent trades (last ~7 days via API)
uv run python .claude/skills/ib-trades-history/scripts/trades.py --all-accounts
# Filter by symbol
uv run python .claude/skills/ib-trades-history/scripts/trades.py --all-accounts --symbol AAPL
# Full history via FlexReport
uv run python .claude/skills/ib-trades-history/scripts/trades.py --all-accounts --flex-token YOUR_TOKEN --flex-query-id YOUR_QUERY_ID
# Custom date range (FlexReport)
uv run python .claude/skills/ib-trades-history/scripts/trades.py --all-accounts --flex-token TOKEN --flex-query-id QID --start-date 2025-01-01 --end-date 2025-12-31
# Multiple queries (e.g., one per year to exceed 365-day limit)
uv run python .claude/skills/ib-trades-history/scripts/trades.py --all-accounts --flex-token TOKEN --flex-query-id QID_2025 --flex-query-id QID_2026 --start-date 2025-01-01 --end-date 2026-12-31
# From local FlexReport XML files (no TWS/Gateway needed)
uv run python .claude/skills/ib-trades-history/scripts/trades.py --file trades_2024.xml --file trades_2025.xml --symbol TSLA
# Mix files with date filtering
uv run python .claude/skills/ib-trades-history/scripts/trades.py --file exports/2025.xml --start-date 2025-06-01 --end-date 2025-12-31
--port - IB port (default: 7497 for paper trading)--account - Specific account ID to filter--all-accounts - Fetch trades for all managed accounts--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 (enables extended history)--flex-query-id - FlexReport query ID (repeatable — pass multiple to merge queries spanning different periods)--file - Local FlexReport XML file path (repeatable — pass multiple to merge files). No TWS/Gateway neededDefault behavior (no flags): fetches trades for the first managed account from the live API (~7 days).
Always use --all-accounts unless the user asks for a specific account.
| Scenario | Source | Date Range |
|---|---|---|
| No flex args | reqExecutionsAsync | ~last 7 days |
| --flex-token + --flex-query-id | FlexReport (web) | As configured in query |
| --file | file (local XML) | Full file contents |
When using the live API, a data_limitation warning is included in the output.
Returns JSON with:
connected - Whether connection succeededsource - Data source used (reqExecutionsAsync or FlexReport)filters - Applied filters (dates, symbol, account)data_limitation - Warning about API date limits (only when using live API)execution_count - Total number of executions returnedexecutions - List of individual trade executionssummary - Aggregated stats per symbol (bought, sold, commission, realized P&L)If not connected, explain that TWS/Gateway needs to be running.
ib-asyncGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
Automatically creates user-facing changelogs from git commits by analyzing commit history, categorizing changes, and transforming technical commits into clear, customer-friendly release notes. Turns hours of manual changelog writing into minutes of automated generation.
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
Take staskh/ib-trades-history from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.