-
-
Notifications
You must be signed in to change notification settings - Fork 33
Description
π Feature Request Summary
Add persistent portfolio management with intelligent AI integration, enabling users to store their investment holdings locally and receive personalized, context-aware analysis from AI agents across all MaverickMCP tools.
π° Financial Disclaimer Acknowledgment
- β I understand this is educational software and not financial advice
- β This feature request is for educational/technical purposes, not investment recommendations
- β I understand that any financial analysis features will include appropriate disclaimers
π― Problem/Use Case
What problem does this feature solve?
Currently, MaverickMCP has excellent portfolio analysis tools (risk_adjusted_analysis
, portfolio_correlation_analysis
, compare_tickers
, backtest_portfolio
), but they have a critical limitation: users must manually specify tickers every single time. There's no persistent storage of holdings, cost basis, or purchase history.
This creates friction:
- β "Analyze correlation in my portfolio" β User must list all tickers again
- β AI agents don't know what the user actually owns
- β No tracking of cost basis, entry dates, or position notes
- β Risk analysis can't reference actual holdings
- β Repetitive ticker entry for every analysis request
Who would benefit from this feature?
- β Individual traders learning technical analysis (primary)
- β MCP developers building financial tools
- β Educational institutions teaching finance
- β Open source contributors
- β Other: ___________
π‘ Proposed Solution
Describe your ideal solution:
A two-phase implementation that transforms MaverickMCP into a truly personalized AI financial assistant:
Phase 1: Persistent Portfolio Storage (Foundation)
4 new MCP tools for portfolio management:
add_portfolio_position()
- Store positions with cost basis averagingget_my_portfolio()
- View all holdings with summary statisticsremove_portfolio_position()
- Remove specific positionsclear_my_portfolio()
- Clear all positions (with confirmation)
MCP Resource:
portfolio://my-holdings
- Makes portfolio automatically available as AI context
Data tracked per position:
- Ticker symbol
- Number of shares
- Cost basis (with automatic averaging for additional purchases)
- Purchase date (earliest for averaged positions)
- Optional notes (investment thesis, reminders)
Phase 2: Intelligent Integration (Transformation)
Enhance existing tools to auto-use stored portfolio:
Risk-Adjusted Analysis Enhancement
- Automatically detect if user owns the analyzed stock
- Display current P&L, position size vs. portfolio
- Personalized recommendations based on actual holdings
Correlation Analysis Enhancement
portfolio_correlation_analysis()
with no arguments β uses stored holdings- No more manually listing tickers
- "How correlated is my portfolio?" just works
Comparison Tools Enhancement
compare_tickers()
with no arguments β compares YOUR holdings- Automatic filtering of owned stocks in screening results
AI Context Enhancement
- Portfolio resource includes live P&L calculations
- Current values, unrealized gains/losses
- Position percentages, diversification metrics
- AI agents automatically reference holdings in all analysis
Alternative approaches you've considered:
1. External portfolio tracking integration (Rejected)
- Pros: Professional features, live sync
- Cons: Privacy concerns, API complexity, against MaverickMCP's local-first philosophy
2. Simple CSV import/export (Rejected as primary)
- Pros: Simple implementation
- Cons: Poor UX, no persistence, no AI integration
3. Separate portfolio database (Rejected)
- Pros: Clean separation
- Cons: Doesn't integrate with existing tools, defeats purpose
π§ Technical Details
Component Area:
- β Data fetching (current price lookups for P&L)
- β Portfolio analysis (risk metrics, optimization)
- β MCP tools (new tools, tool improvements)
- β Database/Caching (portfolio storage)
- β Claude Desktop integration (AI context injection)
Implementation Complexity:
- β Simple
- β Medium (new functionality, moderate effort)
- β Complex
- β I'm not sure
Phase 1 Complexity: Medium (2-3 days)
- Domain entities following existing DDD patterns
- Database models with SQLAlchemy
- Alembic migration
- MCP tools and resource
- Comprehensive tests
Phase 2 Complexity: Medium (1-2 days)
- Modify 3-4 existing tools
- Enhance portfolio resource with live data
- Integration tests
- Documentation updates
Dependencies:
- β No new external APIs required
- β Uses existing DataService for price lookups
- β Follows existing SQLAlchemy/Alembic patterns
- β Compatible with current DDD architecture
π Examples/Mockups
Phase 1: Portfolio Management
# Natural language with Claude Desktop:
"Add 10 shares of AAPL to my portfolio at $150 purchased on 2024-01-15"
# β add_portfolio_position("AAPL", 10, 150.00, "2024-01-15")
"Add 10 more AAPL shares at $170 on 2024-02-01"
# β Automatically averages: 20 shares @ $160.00 cost basis
"Show me my portfolio"
# β Returns:
{
"name": "My Portfolio",
"total_positions": 3,
"total_invested": 12500.00,
"positions": [
{
"ticker": "AAPL",
"shares": 20,
"cost_basis": 160.00,
"total_cost": 3200.00,
"purchase_date": "2024-01-15",
"notes": "Long-term hold"
},
# ... more positions
]
}
"Remove MSFT from my portfolio"
# β remove_portfolio_position("MSFT")
Phase 2: Intelligent Integration
# BEFORE (current behavior):
"Analyze correlation in my portfolio"
# β β Error: "Please provide ticker symbols"
# AFTER (with integration):
"Analyze correlation in my portfolio"
# β β
portfolio_correlation_analysis() automatically uses stored holdings
# β Analyzes correlation between AAPL, MSFT, NVDA, GOOGL (your holdings)
# BEFORE:
"Compare my tech stocks"
# β β User must manually specify: compare_tickers(["AAPL", "MSFT", "GOOGL"])
# AFTER:
"Compare my tech stocks"
# β β
AI agent queries portfolio, filters tech sector, auto-compares
# Risk analysis with position awareness:
"Analyze MARA with my risk profile"
# β Returns:
{
"symbol": "MARA",
"risk_analysis": {...},
"your_position": {
"owned": true,
"shares": 50,
"cost_basis": 18.50,
"current_price": 22.30,
"current_value": 1115.00,
"unrealized_pnl": 190.00,
"pnl_percentage": 20.54,
"position_size_vs_portfolio": "8.9%"
},
"recommendations": "Consider taking partial profits given 20%+ gain..."
}
AI Context Enhancement
# What AI agents automatically see:
USER PORTFOLIO CONTEXT (for personalized analysis):
Portfolio: My Portfolio
Total Positions: 4
Total Invested: $12,500.00
Current Value: $13,750.00
Total P&L: +$1,250.00 (+10.0%)
Current Holdings:
β’ AAPL: 20 shares @ $160.00 cost basis
Current: $175.50 | Value: $3,510.00 | P&L: +$310.00 (+9.7%)
Notes: Long-term hold, core position
β’ MARA: 50 shares @ $18.50 cost basis
Current: $22.30 | Value: $1,115.00 | P&L: +$190.00 (+20.5%)
Notes: Bitcoin mining exposure
β’ NVDA: 5 shares @ $450.00 cost basis
Current: $520.00 | Value: $2,600.00 | P&L: +$350.00 (+15.6%)
β’ RIOT: 100 shares @ $12.00 cost basis
Current: $13.50 | Value: $1,350.00 | P&L: +$150.00 (+12.5%)
Portfolio Metrics:
- Sector Exposure: Technology 72%, Bitcoin Mining 28%
- Largest Position: AAPL (25.5% of portfolio)
- Best Performer: MARA (+20.5%)
- Average Position Return: +12.4%
When providing analysis, reference the user's actual holdings and provide
personalized insights based on their specific portfolio composition, risk
exposure, and performance metrics.
Reference implementations:
- Personal Capital's portfolio tracking (but local-first)
- Fidelity's position tracking (but simplified)
- Interactive Brokers' portfolio view (but educational focus)
π Educational Value
Learning objectives:
- Cost basis management - Understanding average cost calculation
- Position sizing - How much capital in each holding
- Diversification analysis - Sector concentration, correlation
- Risk management - Position size relative to portfolio
- Performance tracking - Unrealized P&L, percentage gains
- Portfolio construction - Building balanced portfolios over time
What financial concepts would this help users learn?
- Cost basis averaging (dollar-cost averaging effects)
- Portfolio diversification principles
- Position sizing strategies
- Risk-adjusted returns in context of actual holdings
- Correlation and how different assets move together
- Sector exposure and concentration risk
What technical skills would developers gain?
- Domain-Driven Design (DDD) architecture
- SQLAlchemy ORM with complex relationships
- Alembic migrations for schema evolution
- MCP protocol: tools + resources working together
- AI context injection and prompt engineering
- Financial calculations (P&L, averaging, percentages)
- Integration patterns between modular tools
Documentation needs:
- β Code examples needed (natural language + tool calls)
- β Tutorial/guide needed (getting started with portfolio)
- β Financial concept explanation needed (cost basis, averaging)
- β API documentation needed (tool parameters, return formats)
π€ Contribution
Are you willing to contribute to this feature?
- β Yes, I can implement this myself
- β Yes, I can help with testing/documentation
- β Yes, I can provide domain expertise
- β I can help but need guidance
- β I cannot contribute but would love to use it
Your relevant experience:
- Financial analysis background: β Understanding of portfolio management, risk analysis, cost basis accounting
- Python development experience: β Professional experience with Python, FastAPI, SQLAlchemy
- MCP protocol familiarity: β Studied MaverickMCP architecture, FastMCP patterns
- Other relevant skills:
- Domain-Driven Design (DDD) patterns
- Database design and migrations
- Testing best practices (pytest, fixtures)
- Technical documentation
β Pre-submission Checklist
- β I have searched existing issues to avoid duplicates
- β This feature aligns with educational/personal-use goals
- β I have considered the implementation complexity
- β I understand this won't provide financial advice or guarantees
- β I have provided clear examples and use cases
π·οΈ Feature Classification
Priority:
- β Critical (blocking important use cases)
- β High (significant improvement to user experience)
- β Medium (nice to have, moderate impact)
- β Low (minor enhancement)
Justification: Transforms existing tools from "good" to "great" by eliminating repetitive ticker entry and enabling true personalization. Makes AI agents context-aware of user's actual holdings.
Effort Estimate:
- β Small (1-3 days)
- β Medium (1-2 weeks)
- β Large (1+ months)
- β Unknown
Breakdown:
- Phase 1 (Storage): 2-3 days
- Phase 2 (Integration): 1-2 days
- Testing & Documentation: 1-2 days
- Total: 4-7 days (depending on thoroughness)
Release Timeline:
- β Next minor version (v0.6.0 or similar)
- β Next major version
- β Future consideration
- β No preference
π Additional Context
Related issues or discussions:
- Enhances existing portfolio tools without replacing them
- Builds on MaverickMCP's DDD architecture
- Follows established patterns in
maverick_mcp/api/routers/portfolio.py
- Complements backtesting and screening features
Financial domain considerations:
- β Educational disclaimers in all tools (required)
- β No specific investment recommendations
- β Local-first storage (privacy-respecting)
- β Cost basis averaging follows FIFO/average cost principles
- β P&L calculations for educational understanding only
β οΈ Not tax advice (users should consult tax professionals)
Community impact:
- Educational institutions: Example of portfolio management in code
- Individual learners: Hands-on portfolio tracking experience
- MCP developers: Reference implementation of stateful MCP tools
- Open source: Demonstrates AI context injection patterns
- Estimated users: All MaverickMCP users who manage multiple positions
Why this matters:
This feature represents the missing link between MaverickMCP's powerful analysis tools and real-world usage. Current tools are excellent but require users to repeatedly specify the same tickers. This creates friction that limits practical educational value.
By adding persistent portfolio storage with intelligent AI integration, MaverickMCP becomes a truly personalized AI financial assistant that:
- Remembers what you own
- Understands your positions automatically
- Personalizes every analysis to YOUR holdings
- Tracks your cost basis and performance
- Learns from your investment decisions over time
This transforms the user experience from "powerful but manual" to "intelligent and effortless."
Implementation Approach:
Following MaverickMCP's established patterns:
- Domain entities (pure business logic)
- SQLAlchemy models (data persistence)
- Alembic migrations (schema evolution)
- FastMCP tools (user interface)
- MCP resources (AI context)
- Comprehensive tests (reliability)
Privacy & Security:
- All data stored locally (SQLite/PostgreSQL)
- No external API calls for portfolio data
- User controls all data (add, view, remove, clear)
- No cloud sync or third-party sharing
π Implementation Checklist (for tracking)
Phase 1: Portfolio Storage
- β Domain entities (Portfolio, Position)
- β Database models (Portfolio, PortfolioPosition)
- β Alembic migration
- β MCP tools (add, get, remove, clear)
- β MCP resource (portfolio://my-holdings)
- β Unit tests (domain entities)
- β Integration tests (database operations)
- β Documentation (docs/PORTFOLIO.md)
Phase 2: AI Integration
- β Enhance risk_adjusted_analysis with position awareness
- β Enhance portfolio_correlation_analysis with auto-holdings
- β Enhance compare_tickers with auto-holdings
- β Enhance portfolio resource with live P&L
- β Integration tests (cross-tool functionality)
- β Update existing documentation
- β Usage examples in docs
Phase 3: Polish
- β Manual testing in Claude Desktop
- β Performance optimization
- β Error handling edge cases
- β User experience refinements
- β Final documentation review
Ready to implement! This feature has clear value, manageable scope, and follows established patterns. Will submit pull request after development complete.
Questions for Maintainers
- Approval to proceed? Does this align with MaverickMCP's roadmap?
- Architectural review? Any concerns with the proposed DDD structure?
- Phase 2 integration? Should Phase 2 be in same PR or separate?
- Naming conventions? Confirm
mcp_portfolios
andmcp_portfolio_positions
table names? - User identification? Using "default" user_id for now, should this be configurable?
Thank you for considering this feature request! Happy to answer any questions or provide additional details.