Skip to main content
Glama
knishioka

IB Analytics MCP Server

by knishioka
README.mdβ€’28.6 kB
# .claude/ Directory - Advanced Development Automation This directory powers **Mode 3** of IB Analytics: **Development Automation** with AI-powered workflows. ## 🎯 What You Get with Mode 3 **For Investors & Analysts**: - ⚑ **95% faster investment strategy generation** (6-8 hours β†’ 15-20 minutes) - πŸ“Š **Parallel market analysis** of all holdings simultaneously - 🎯 **Consolidated multi-account view** with accurate portfolio metrics - πŸ“ˆ **Professional-grade options strategies** with specific strikes and Greeks - πŸ’° **Tax-optimized execution plans** across multiple accounts **For Developers**: - πŸ€– **90% faster issue resolution** (80 minutes β†’ 8 minutes) - βœ… **Automated quality gates** (black, ruff, mypy, pytest) - πŸ”„ **Complete TDD workflow** (tests β†’ code β†’ PR) - πŸ“ **Auto-generated PR descriptions** with comprehensive context - πŸ”§ **7 specialized AI agents** for different domains **Time Savings Summary**: | Task | Manual | Automated | Savings | |------|--------|-----------|---------| | Investment Strategy | 6-8 hours | 15-20 min | **95%** | | Stock Analysis | 1-2 hours | 2-3 min | **97%** | | Options Strategy | 45-60 min | 3-5 min | **93%** | | Portfolio Analysis | 3-4 hours | 5 min | **95%** | | GitHub Issue β†’ PR | 80 min | 8 min | **90%** | | Quality Checks | 15 min | 2 min | **87%** | ## πŸ“ Directory Structure ``` .claude/ β”œβ”€β”€ CLAUDE.md # Main project context (auto-loaded) β”œβ”€β”€ README.md # This file β”œβ”€β”€ settings.local.json # Local settings (gitignored) β”œβ”€β”€ agents/ # Specialized sub-agents (7 agents) β”‚ β”œβ”€β”€ test-runner.md β”‚ β”œβ”€β”€ data-analyzer.md β”‚ β”œβ”€β”€ api-debugger.md β”‚ β”œβ”€β”€ code-reviewer.md β”‚ β”œβ”€β”€ performance-optimizer.md β”‚ β”œβ”€β”€ issue-analyzer.md # NEW: GitHub issue analysis β”‚ └── code-implementer.md # NEW: Code implementation └── commands/ # Custom slash commands (12 commands) β”œβ”€β”€ fetch-latest.md β”œβ”€β”€ debug-api.md β”œβ”€β”€ test.md β”œβ”€β”€ quality-check.md β”œβ”€β”€ optimize-portfolio.md β”œβ”€β”€ compare-periods.md β”œβ”€β”€ tax-report.md β”œβ”€β”€ add-test.md β”œβ”€β”€ benchmark.md β”œβ”€β”€ validate-data.md β”œβ”€β”€ mcp-status.md └── resolve-gh-issue.md # NEW: Complete GitHub issue resolution ``` ## πŸ€– Sub-Agents (Specialized AI Experts) Specialized AI assistants that handle specific tasks in their own context window, keeping the main conversation focused. ### Available Sub-Agents (10 Total) #### πŸ“Š **Investment Analysis Agents** (NEW!) ##### **strategy-coordinator** 🎯 **Purpose**: Investment strategy orchestration and synthesis **When to use**: Comprehensive investment planning, multi-account optimization **Key Features**: - **Parallel market analysis**: Analyzes 5-10 stocks simultaneously (80-90% time reduction) - **Multi-agent coordination**: Delegates to data-analyzer + market-analyst - **Consolidated portfolio view**: True portfolio-level analysis across ALL accounts - **Actionable priorities**: Urgent β†’ High β†’ Medium β†’ Monitoring **Time Savings**: 6-8 hours β†’ 15-20 minutes (95% reduction) ##### **market-analyst** πŸ“ˆ **Purpose**: Stock and options market specialist **When to use**: Technical analysis, options strategies, entry/exit timing **Tools**: All Yahoo Finance MCP tools, technical indicators, Greeks calculations **Key Features**: - Multi-timeframe analysis (daily/weekly/monthly confluence) - Support/resistance levels with entry/exit signals - Options Greeks, IV Rank/Percentile, Max Pain - News sentiment and catalysts - **Buy/Sell/Hold ratings** with conviction (1-10) **Time Savings**: - Stock analysis: 1-2 hours β†’ 2-3 minutes (97% reduction) - Options strategy: 45-60 minutes β†’ 3-5 minutes (93% reduction) ##### **data-analyzer** πŸ“Š **Purpose**: Financial data analysis specialist for IB trading data **When to use**: Deep portfolio analysis, performance metrics, tax planning **Tools**: All MCP analysis tools, Python, Read **Key Features**: - **Consolidated multi-account analysis** (accurate portfolio-level metrics) - Performance, tax, cost, risk, bond analytics - Time-series position tracking - Cross-account tax optimization **Auto-activates**: On portfolio/analysis queries **Time Savings**: 3-4 hours β†’ 5 minutes (95% reduction) #### πŸ’» **Development Agents** ##### **test-runner** πŸ§ͺ **Purpose**: Testing specialist for pytest, coverage, and quality assurance **When to use**: After code changes, before commits, for coverage analysis **Tools**: pytest, pytest-cov, Read, Write, Grep **Auto-activates**: On test-related queries ##### **code-implementer** πŸ’» **Purpose**: Python implementation specialist with financial software expertise **When to use**: Implementing features, writing analyzers, TDD development **Tools**: Edit, MultiEdit, Write, Read, WebSearch, TodoWrite, Python tools **Model**: opus (for complex implementations) **Key Features**: - Follows existing codebase patterns - Enforces Decimal precision for financial calculations - Implements Pydantic v2 models correctly - Writes comprehensive docstrings - Test-Driven Development (TDD) workflow - WebSearch for best practices research **Auto-activates**: Via `/resolve-gh-issue` command ##### **code-reviewer** πŸ“ **Purpose**: Code quality and standards enforcement **When to use**: Before commits, PR reviews, quality checks **Tools**: black, ruff, mypy, Read, Grep **Auto-activates**: PROACTIVE before commits **Time Savings**: 15 minutes β†’ 2 minutes (87% reduction) ##### **performance-optimizer** ⚑ **Purpose**: Performance analysis and optimization **When to use**: Profiling, benchmarking, bottleneck identification **Tools**: cProfile, timeit, tracemalloc, Read **Auto-activates**: On performance queries ##### **api-debugger** πŸ”§ **Purpose**: IB Flex Query API troubleshooting specialist **When to use**: API connectivity issues, credential validation, debugging **Tools**: curl, Python, grep, MCP fetch tools **Auto-activates**: On API error queries ##### **issue-analyzer** πŸ” **Purpose**: GitHub issue analysis and requirement extraction **When to use**: Analyzing GitHub issues, extracting acceptance criteria, planning implementation **Tools**: gh CLI, Read, WebSearch, TodoWrite, Grep **Model**: opus (for high precision) **Key Features**: - Extracts structured requirements from GitHub issues - Identifies acceptance criteria and technical scope - Flags financial code requirements (Decimal precision, etc.) - Generates implementation checklists - Never hallucinates - always uses actual GitHub data **Auto-activates**: Via `/resolve-gh-issue` command **Time Savings**: 20 minutes analysis β†’ 3 minutes (85% reduction) ### How Sub-Agents Work **Automatic Delegation**: ``` You: "Run tests with coverage" Claude: [Delegates to test-runner sub-agent] test-runner: [Executes pytest in isolated context] test-runner: [Returns results to main thread] Claude: [Presents formatted results] ``` **Explicit Invocation**: ``` You: "Use the data-analyzer subagent to analyze my portfolio" Claude: [Explicitly delegates to data-analyzer] ``` **Benefits**: - βœ… **Context Isolation**: Each sub-agent has dedicated context window - βœ… **Specialization**: Expert knowledge for specific domains - βœ… **Parallel Work**: Multiple sub-agents can work simultaneously - βœ… **Clean Main Thread**: Main conversation stays focused on high-level tasks ## πŸ“‹ Slash Commands (Automated Workflows) Pre-configured prompts for common operations. Type `/` in Claude Code to see all available commands. ### πŸ“Š Investment Analysis Commands (NEW!) #### `/investment-strategy [--save]` **Master command** for comprehensive investment planning Delegates to: **strategy-coordinator** β†’ **data-analyzer** + **market-analyst** (parallel) **What it does**: - **Consolidated portfolio analysis** across ALL accounts (not per-account) - **Parallel market analysis** of all holdings (5-10 stocks simultaneously) - **2-year chart context** for every position with entry/exit scenarios - **Options strategies** with specific strikes, premiums, Greeks - **Tax-optimized execution** plans per account - **Actionable priorities**: Urgent (this week) β†’ High (this month) β†’ Medium (this quarter) **Performance Optimization**: - **Parallel sub-agent execution**: 80-90% time reduction - Sequential: N stocks Γ— 2 min = 10-20 min - Parallel: max(2 min) = 2 min **Time Savings**: 6-8 hours manual research β†’ **15-20 minutes** (95% reduction) ```bash /investment-strategy # Generate comprehensive strategy /investment-strategy --save # Save to data/processed/ ``` #### `/analyze-symbol SYMBOL` Comprehensive symbol analysis with technical, fundamental, and options (stocks, ETFs, crypto, forex) Delegates to: **market-analyst** sub-agent **What it does**: - Multi-timeframe technical analysis (daily/weekly/monthly) - Support/resistance levels with entry/exit signals - Options market analysis (IV Rank, Greeks, Max Pain) - when available - News sentiment and catalysts - **Buy/Sell/Hold rating** with conviction level (1-10) **Time Savings**: 1-2 hours research β†’ **2-3 minutes** (97% reduction) ```bash /analyze-symbol AAPL # Stock /analyze-symbol VOO # ETF /analyze-symbol BTC-USD # Crypto /analyze-symbol USDJPY=X # Forex ``` #### `/options-strategy SYMBOL` Detailed options strategy analysis Delegates to: **market-analyst** sub-agent **What it does**: - IV environment assessment (buy vs sell premium) - Greeks analysis with risk assessment - 2-3 specific strategy recommendations with exact strikes - Max profit/loss, breakeven, probability of profit - Risk/reward comparison with best strategy selection **Time Savings**: 45-60 minutes β†’ **3-5 minutes** (93% reduction) ```bash /options-strategy AAPL /options-strategy SPY ``` ### πŸ“ˆ Portfolio Analysis Commands #### `/optimize-portfolio [csv-file-path]` Comprehensive portfolio analysis with recommendations Delegates to: **data-analyzer** sub-agent **Time Savings**: 3-4 hours β†’ **5 minutes** (95% reduction) ```bash /optimize-portfolio # Use latest CSV /optimize-portfolio data/raw/U1234567_*.csv # Specific file ``` #### `/compare-periods period1-start period1-end period2-start period2-end` Compare performance across two time periods Delegates to: **data-analyzer** sub-agent ```bash /compare-periods 2025-01-01 2025-03-31 2025-04-01 2025-06-30 /compare-periods --ytd # Compare YTD vs previous YTD /compare-periods --quarter # Current vs previous quarter ``` #### `/tax-report [--year YYYY|--ytd|--save]` Generate comprehensive tax analysis report Delegates to: **data-analyzer** sub-agent ```bash /tax-report # Current year /tax-report --year 2024 # Specific year /tax-report --save # Save to file ``` ### πŸ”§ Development Commands #### `/test [--coverage|--verbose|--failed|pattern]` Run pytest test suite with coverage reporting Delegates to: **test-runner** sub-agent ```bash /test # Full test suite with coverage /test --verbose # Verbose output /test --coverage # Quick coverage check /test --failed # Re-run failed tests only /test performance # Run tests matching "performance" ``` #### `/quality-check [--fix|--strict]` Run full quality gate: format, lint, type, test Delegates to: **code-reviewer** sub-agent ```bash /quality-check # Check all quality gates /quality-check --fix # Auto-fix issues /quality-check --strict # Strict mode for CI/CD ``` #### `/add-test module-name [--analyzer|--parser|--model]` Create comprehensive test file for module Delegates to: **test-runner** sub-agent ```bash /add-test performance --analyzer /add-test csv_parser --parser /add-test Trade --model ``` #### `/benchmark [--full|--quick|module-name]` Performance benchmarking and profiling Delegates to: **performance-optimizer** sub-agent ```bash /benchmark # Quick benchmark /benchmark --full # Full benchmark suite /benchmark bond # Benchmark specific module ``` ### Analysis Commands #### `/optimize-portfolio [csv-file-path]` Comprehensive portfolio analysis with recommendations Delegates to: **data-analyzer** sub-agent ```bash /optimize-portfolio # Use latest CSV /optimize-portfolio data/raw/U1234567_*.csv # Specific file ``` #### `/compare-periods period1-start period1-end period2-start period2-end` Compare performance across two time periods Delegates to: **data-analyzer** sub-agent ```bash /compare-periods 2025-01-01 2025-03-31 2025-04-01 2025-06-30 /compare-periods --ytd # Compare YTD vs previous YTD /compare-periods --quarter # Current vs previous quarter /compare-periods --month # Current vs previous month ``` #### `/tax-report [--year YYYY|--ytd|--save]` Generate comprehensive tax analysis report Delegates to: **data-analyzer** sub-agent ```bash /tax-report # Current year /tax-report --year 2024 # Specific year /tax-report --ytd # Year-to-date /tax-report --save # Save to file ``` #### `/validate-data [csv-file-path|--latest]` Data integrity and format validation ```bash /validate-data # Validate all CSVs /validate-data --latest # Latest file only /validate-data data/raw/file.csv # Specific file ``` ### Utility Commands #### `/mcp-status [--verbose|--test]` Check MCP server health and tool availability ```bash /mcp-status # Basic health check /mcp-status --verbose # Detailed output /mcp-status --test # Run functionality tests ``` #### `/debug-api [--verbose|--test-credentials]` Troubleshoot IB API connectivity Delegates to: **api-debugger** sub-agent ```bash /debug-api # Full diagnostic /debug-api --verbose # Detailed output /debug-api --test-credentials # Test credentials only ``` ### GitHub Workflow Commands (NEW!) #### `/resolve-gh-issue issue-number [--skip-checks|--skip-tests|--dry-run]` Complete GitHub issue resolution workflow with TDD Orchestrates: **issue-analyzer**, **test-runner**, **code-implementer**, **code-reviewer** sub-agents ```bash /resolve-gh-issue 42 # Full workflow for issue #42 /resolve-gh-issue 42 --dry-run # Show plan without executing /resolve-gh-issue 42 --skip-checks # Skip quality checks (not recommended) /resolve-gh-issue 42 --skip-tests # Create tests but don't run ``` **Complete 10-Phase Workflow**: 1. **Issue Analysis** - Extract requirements from GitHub issue (issue-analyzer) 2. **Planning** - Create task breakdown and branch (TodoWrite + git) 3. **Test Creation** - Write failing tests first (TDD via test-runner) 4. **Implementation** - Implement solution (code-implementer) 5. **Quality Assurance** - Run all quality checks (code-reviewer) 6. **Documentation** - Update docstrings and CHANGELOG 7. **Commit** - Create structured commit with issue reference 8. **Pull Request** - Generate PR with comprehensive description 9. **CI Monitoring** - Watch CI checks for failures 10. **Issue Closure** - Automatic closure when PR merges **Quality Gates**: - βœ… All acceptance criteria met - βœ… Tests created and passing (β‰₯80% coverage) - βœ… Black formatting applied - βœ… Ruff linting passed - βœ… Mypy type checking strict mode - βœ… Financial code validation (Decimal precision) - βœ… Documentation complete **Example Output**: ``` [1/10] Analyzing Issue #42... βœ“ Requirements extracted βœ“ Acceptance criteria: 4 items βœ“ Financial code: YES (Decimal required) [2/10] Creating task breakdown... βœ“ 6 tasks created in TodoList [3/10] Creating tests (TDD)... βœ“ Test file: tests/test_analyzers/test_performance_sharpe.py βœ“ 8 tests created (failing as expected) [4/10] Implementing solution... βœ“ Method: calculate_sharpe_ratio() implemented βœ“ All tests passing: 8/8 βœ“ [5/10] Running quality checks... βœ“ black, ruff, mypy all passed [6/10] Creating PR #123... βœ“ URL: https://github.com/user/repo/pull/123 βœ… Issue #42 resolved successfully! ``` ### Legacy Commands This command is still available for manual data fetching: - `/fetch-latest [--multi-account|--start-date|--end-date]` - Fetch IB data manually **Note**: For new features, use `/resolve-gh-issue` which provides a complete workflow from issue to PR. ## πŸ—οΈ Architecture Overview ### System Architecture The IB Analytics project follows a modular, layered architecture optimized for financial data processing: ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ CLI Layer β”‚ β”‚ (ib-sec-fetch, ib-sec-analyze, ib-sec-report) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ MCP Server Layer β”‚ β”‚ (FastMCP - Model Context Protocol for Claude Desktop) β”‚ β”‚ β€’ 7 Tools (fetch, analyze_*, get_portfolio_summary) β”‚ β”‚ β€’ 6 Resources (portfolio URIs, account data) β”‚ β”‚ β€’ 5 Prompts (analysis templates) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Core Analysis Layer β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Analyzers β”‚ β”‚ Aggregator β”‚ β”‚ Calculator β”‚ β”‚ β”‚ β”‚ β€’ Performanceβ”‚ β”‚ β€’ Multi-acct β”‚ β”‚ β€’ YTM β”‚ β”‚ β”‚ β”‚ β€’ Cost β”‚ β”‚ β€’ Rollup β”‚ β”‚ β€’ Duration β”‚ β”‚ β”‚ β”‚ β€’ Bond β”‚ β”‚ β€’ Reporting β”‚ β”‚ β€’ Tax β”‚ β”‚ β”‚ β”‚ β€’ Tax β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β€’ Risk β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Data Layer β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Parsers β”‚ β”‚ Models β”‚ β”‚ API Client β”‚ β”‚ β”‚ β”‚ β€’ CSV β”‚ β”‚ β€’ Trade β”‚ β”‚ β€’ FlexQuery β”‚ β”‚ β”‚ β”‚ β€’ XML β”‚ β”‚ β€’ Position β”‚ β”‚ β€’ Async β”‚ β”‚ β”‚ β”‚ β€’ Multi-sect β”‚ β”‚ β€’ Account β”‚ β”‚ β€’ Retry β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β€’ Portfolio β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ (Pydantic v2)β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ External Services β”‚ β”‚ β€’ IB Flex Query API (Interactive Brokers) β”‚ β”‚ β€’ GitHub API (via gh CLI) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` ### Data Flow 1. **Data Ingestion**: Flex Query API β†’ CSV Parser β†’ Pydantic Models 2. **Analysis**: Models β†’ Analyzers β†’ AnalysisResult 3. **Reporting**: AnalysisResult β†’ Report Renderer β†’ Console/File 4. **Integration**: MCP Server β†’ Claude Desktop β†’ User Interaction ### Key Design Principles - **Type Safety**: Pydantic v2 models with strict validation - **Financial Accuracy**: Decimal precision throughout (never float) - **Modularity**: Pluggable analyzers and reports - **Async Support**: Async API client for multi-account operations - **Error Handling**: Custom exceptions with detailed context ### Claude Code Integration ``` User Query β†’ Claude Code β†’ MCP Server β†’ IB Analytics Library β†’ Results β”‚ β”‚ └──────────────────────────┴→ Sub-Agents: β€’ issue-analyzer (GitHub) β€’ code-implementer (TDD) β€’ test-runner (pytest) β€’ code-reviewer (quality) β€’ data-analyzer (portfolio) β€’ api-debugger (diagnostics) β€’ performance-optimizer (profiling) ``` ## πŸš€ Quick Start Guide ### 1. First-Time Setup ```bash # Verify MCP server /mcp-status # Fetch latest data /fetch-latest # Run quality check /quality-check ``` ### 2. Daily Development Workflow ```bash # Before coding /quality-check # Ensure clean baseline # During coding # [Make changes] # Before commit /quality-check --fix # Auto-fix issues /test # Run tests ``` ### 3. Portfolio Analysis Workflow ```bash # Get latest data /fetch-latest # Validate data /validate-data --latest # Comprehensive analysis /optimize-portfolio # Tax planning /tax-report --save ``` ### 4. Performance Optimization Workflow ```bash # Benchmark current state /benchmark --full # Profile specific module /benchmark bond # [Make optimizations] # Verify improvements /benchmark --full ``` ## πŸ“š Best Practices ### Using Sub-Agents **When to delegate to sub-agents**: - βœ… Complex, specialized tasks (testing, profiling, analysis) - βœ… Tasks requiring isolated context (prevent main thread pollution) - βœ… Repetitive workflows that benefit from expertise **When NOT to delegate**: - ❌ Simple one-off tasks - ❌ Tasks requiring main context awareness - ❌ Quick questions or clarifications ### Using Slash Commands **Create new commands when**: - βœ… Repeating the same workflow 3+ times - βœ… Task has consistent structure and arguments - βœ… Team members would benefit from standardization **Don't create commands for**: - ❌ One-time operations - ❌ Highly variable workflows - ❌ Tasks that need human judgment ### Context Management **Project Context** (`.claude/CLAUDE.md`): - Project-specific conventions - Architecture decisions - Common workflows - Team standards **User Context** (`~/.claude/CLAUDE.md`): - Personal preferences - Global coding style - Cross-project patterns **Sub-Agent Context** (`.claude/agents/*.md`): - Specialized knowledge - Domain expertise - Tool configurations ## πŸ”§ Maintenance ### Regular Updates **Weekly**: - Review sub-agent performance - Update command arguments if needed **Monthly**: - Review CLAUDE.md for accuracy - Add new commands for emerging patterns - Archive unused commands **After Major Changes**: - Update CLAUDE.md with new conventions - Add commands for new workflows - Update sub-agent tools/permissions ### Quality Checks ```bash # Verify all commands work /mcp-status # Test sub-agents /test --verbose /quality-check /benchmark --quick # Validate data pipeline /validate-data --latest ``` ## πŸ“– Additional Resources ### Documentation - [Claude Code Best Practices](https://www.anthropic.com/engineering/claude-code-best-practices) - [Sub-Agents Guide](https://docs.claude.com/en/docs/claude-code/sub-agents) - [Slash Commands Guide](https://docs.claude.com/en/docs/claude-code/slash-commands) ### Examples - See `WORKFLOWS.md` for complete workflow examples - Check individual command files for usage examples - Review sub-agent files for specialization details --- ## πŸ“š Additional Resources ### Documentation - [Main README](../README.md): User documentation and 3 usage modes - [Project CLAUDE.md](../CLAUDE.md): General development guide - [.claude/CLAUDE.md](CLAUDE.md): Claude Code extensions - [SUB_AGENTS.md](SUB_AGENTS.md): Detailed sub-agent development guide - [SLASH_COMMANDS.md](SLASH_COMMANDS.md): Detailed slash command development guide ### Quick Links - [Claude Code Best Practices](https://www.anthropic.com/engineering/claude-code-best-practices) - [Sub-Agents Guide](https://docs.claude.com/en/docs/claude-code/sub-agents) - [Slash Commands Guide](https://docs.claude.com/en/docs/claude-code/slash-commands) --- ## 🎯 Quick Start Examples ### For Investors **Comprehensive Investment Strategy** (95% time savings): ```bash /investment-strategy --save # Analyzes ALL accounts + holdings in parallel β†’ 15-20 minutes # Manual equivalent: 6-8 hours of research ``` **Individual Symbol Analysis** (97% time savings): ```bash /analyze-symbol PG # Multi-timeframe technicals + options + news β†’ 2-3 minutes # Manual equivalent: 1-2 hours of research ``` **Options Strategy** (93% time savings): ```bash /options-strategy SPY # IV environment + Greeks + strategies β†’ 3-5 minutes # Manual equivalent: 45-60 minutes ``` ### For Developers **GitHub Issue Resolution** (90% time savings): ```bash /resolve-gh-issue 42 # Issue β†’ Tests β†’ Code β†’ Quality β†’ PR β†’ 8 minutes # Manual equivalent: 80 minutes ``` **Quality Check** (87% time savings): ```bash /quality-check --fix # black + ruff + mypy + pytest β†’ 2 minutes # Manual equivalent: 15 minutes ``` --- **Last Updated**: 2025-10-16 **Maintained By**: Development Team **New in this version (v3.0)** - Investment Analysis Automation: - ✨ **3 new investment agents**: strategy-coordinator, market-analyst, data-analyzer - πŸ“Š **Parallel market analysis**: 80-90% time reduction for multi-stock analysis - 🎯 **Consolidated multi-account view**: True portfolio-level metrics - πŸ“ˆ **3 new slash commands**: /investment-strategy, /analyze-symbol, /options-strategy - πŸ’° **Professional options analysis**: Greeks, IV metrics, Max Pain, specific strategies - πŸ“‰ **Multi-timeframe technical analysis**: Daily/weekly/monthly confluence - πŸ”„ **2-year chart context**: For every position with entry/exit scenarios - πŸ—οΈ **Time savings documentation**: 95-97% reduction for investment workflows **Version v2.1** (Previous): - 7 specialized sub-agents (issue-analyzer, code-implementer added) - 12 slash commands (removed 3 obsolete, added /resolve-gh-issue) - Complete Test-Driven Development (TDD) workflow - GitHub integration: issue β†’ branch β†’ tests β†’ code β†’ PR β†’ CI **Version v2.0**: - 7 sub-agents, 15 slash commands - Initial GitHub workflow integration **Version v1.0**: - 5 sub-agents, 14 slash commands - Basic portfolio analysis 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/knishioka/ib-sec-mcp'

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