IBKR Trade Analyzer

A Claude Code plugin for analyzing Interactive Brokers trading history — read-only, zero risk.
What It Does
This plugin connects to your IBKR account (via the read-only Flex Web Service API) or reads local CSV/XML exports, then generates comprehensive trading analysis reports covering:
| Dimension | Details |
|---|
| Trading Patterns | Frequency, holding periods, time-of-day patterns, win rate, profit factor |
| P&L Performance | Realized P&L, equity curve, Sharpe ratio, max drawdown, monthly returns |
| Portfolio Structure | Asset allocation, sector concentration, long/short ratio, position sizing |
| Cost Basis (3 methods) | Breakeven/保本价 (Futu method), FIFO, LIFO — side-by-side comparison |
| Fees & Cash Flow | Commissions, interest, dividends, financing costs, fee-to-PnL ratio |
| Cash & Currency | Multi-currency balances, FX conversion rates (1 USD = X FCY), liquidity ratio |
| Trading Style Profile | Auto-generated qualitative summary (day/swing/position trader, bias, risk) |
| Risk Assessment | Scored 0-100 across 6 dimensions with specific warnings |
| Price Charts | Historical price data with buy/sell trade markers overlaid |
What's New in v2.2.1
- All holdings in portfolio views — portfolio analysis, command guidance, and generated reports now show every holding sorted by portfolio percentage instead of limiting output to a top-10 subset.
- China tax content consistency — documentation and MCP schema references now consistently describe opt-in realized P&L parameters:
include_realized_pnl, realized_pnl_asset_types, and china_iit_property_transfer_rate.
- Release documentation sync — README, README-zh, CHANGELOG, plugin manifest, and marketplace metadata now all point at v2.2.1.
v2.2.0
- Date-aware session cache — long-lived MCP sessions now reuse in-memory IBKR data only when it was loaded today; stale sessions fall through to today's XML cache or one Flex API refresh.
- Portfolio force refresh —
/ibkr-trade-analyzer:portfolio --ff forces ibkr_fetch_data(mode="flex", force_refresh=true) before calculating holdings.
- Regression coverage — server tests now cover stale session refresh, force refresh bypass, timestamp updates, and portfolio command documentation.
v2.1.0
- Workflow commands — adds account summary, portfolio, cash/FX, report generation, and targeted analysis command workflows.
- Improved skill routing — maps natural-language IBKR requests to focused read-only MCP workflows.
- Stronger command validation — packaging tests now verify command frontmatter and allowed MCP tool references.
v1.2.0
- Breakeven cost (保本价/摊薄成本) — Futu-style breakeven price: profitable sells reduce remaining cost, losses raise it. Commission tracked separately (not folded into cost)
- LIFO lot matching — Last In, First Out cost basis as a comparison method (one of IBKR's 7 Tax Optimizer methods)
- Three-way cost comparison — Breakeven vs FIFO vs LIFO shown side-by-side for each symbol
- Per-symbol deep dive —
--symbol AMZN,BRK B generates detailed trade history with cost evolution per method
diluted_cost analyzer section — new --analyzers diluted_cost option; included in default "all" run
Installation
Method 1: Claude Code Marketplace
First, add this repository as a marketplace source:
/plugin marketplace add Esonhugh/Marketplace
Then install the plugin:
/plugin install ibkr-trade-analyzer
Or with the claude CLI:
claude plugin marketplace add Esonhugh/Marketplace
claude plugin install ibkr-trade-analyzer
Method 2: Clone from GitHub
Clone the entire marketplace repo and point Claude Code to the plugin directory:
git clone https://github.com/Esonhugh/Marketplace.git
claude --plugin-dir ./Marketplace/plugins/ibkr-trade-analyzer
Or clone just the plugin into your plugins directory:
git clone --depth 1 --filter=blob:none --sparse \
https://github.com/Esonhugh/Marketplace.git /tmp/marketplace
cd /tmp/marketplace && git sparse-checkout set plugins/ibkr-trade-analyzer
cp -r plugins/ibkr-trade-analyzer ~/.claude/plugins/ibkr-trade-analyzer
Usage
Once installed, simply tell Claude:
Analyze my IBKR trading history
The assistant will guide you through:
- Choose data source — Flex Web Service (online) or local file (offline)
- Provide credentials — Flex Token + Query ID, or a file path
- Run analysis — automated, produces Markdown + interactive HTML reports
- Review results — discuss findings interactively
Workflow Commands
The plugin also exposes command-style workflows for common reviews: