IB Analytics
Interactive Brokers portfolio analytics library with multi-account support.
Features
š Multi-Account Support: Analyze multiple IB accounts simultaneously
š Flex Query API Integration: Automated data fetching via IB Flex Query API v3
š Comprehensive Analysis: Performance, tax, cost, risk, and bond analytics
šÆ Type-Safe: Built with Pydantic v2 for robust data validation
ā” Async Support: Parallel data fetching for multiple accounts
š Rich Reports: Console, HTML, and optional PDF reporting
Installation
Quick Start
1. Configuration
Create a .env
file with your IB Flex Query credentials:
2. Fetch Data
3. Run Analysis
4. Generate Reports
Programmatic Usage
Project Structure
Available Analyzers
PerformanceAnalyzer: Overall trading performance metrics
TaxAnalyzer: Tax liability calculations (OID, capital gains)
CostAnalyzer: Commission and cost efficiency analysis
RiskAnalyzer: Interest rate and market risk scenarios
BondAnalyzer: Bond-specific analytics (YTM, duration, etc.)
MCP Server Integration
IB Analytics provides a Model Context Protocol (MCP) server for integration with Claude Desktop and other MCP clients.
Quick Start
Features
7 Tools: Fetch IB data, run performance/cost/bond/tax/risk analysis, get portfolio summary
6 Resources: Access portfolio data, account info, trades, and positions via URI patterns
5 Prompts: Pre-configured analysis templates for common workflows
Claude Desktop Setup
Add to ~/Library/Application Support/Claude/claude_desktop_config.json
:
See .claude/CLAUDE.md for detailed MCP documentation.
Development
Requirements
Python 3.9+
Interactive Brokers account with Flex Query access
Dependencies
requests (2.32.5+): HTTP client for API calls
pandas (2.2.3+): Data analysis and manipulation
pydantic (2.10.0+): Data validation and settings management
httpx (0.27.0+): Async HTTP client for parallel requests
rich (13.7.0+): Beautiful console output
typer (0.12.0+): CLI framework
License
MIT
Author
Kenichiro Nishioka
Support
For issues and questions, please check the IB Flex Query documentation.
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Enables comprehensive analysis of Interactive Brokers portfolios through automated data fetching and multi-dimensional analytics. Provides performance, tax, cost, risk, and bond analysis across multiple accounts with rich reporting capabilities.