FinMate: AI-Powered Portfolio Advisor

Inspiration

The inspiration for FinMate came from witnessing the growing gap between sophisticated institutional portfolio management tools and the limited options available to retail investors. While hedge funds and wealth managers have access to advanced AI-driven portfolio analysis, individual investors often rely on basic spreadsheets or expensive financial advisors.

We were particularly inspired by the democratization of AI through AWS Bedrock and the potential to create an autonomous financial advisor that could:

  • Provide institutional-grade portfolio analysis to everyday investors
  • Use reasoning-first AI (not prediction models) to explain recommendations transparently
  • Operate autonomously to monitor portfolios without constant human intervention
  • Integrate real-time market data with intelligent analysis

The vision was to build something that would make sophisticated portfolio management accessible, educational, and trustworthy for the average investor.

What it does

FinMate is an autonomous AI portfolio advisor that analyzes stock portfolios, explains risks, and proposes actionable rebalancing suggestions. Here's what makes it special:

Core Capabilities:

  • Portfolio Upload & Analysis: Accepts CSV/JSON portfolios and performs comprehensive analysis
  • Real-time Market Data: Integrates with Yahoo Finance for current prices, sectors, and beta values
  • AI-Powered Insights: Uses Nova Pro to provide reasoning-backed recommendations
  • Autonomous Operation: Runs daily portfolio checks via EventBridge without user prompts
  • Professional Reports: Generates HTML reports with interactive charts and downloadable links

Key Features:

  • Risk assessment and portfolio health scoring
  • Sector exposure analysis and concentration warnings
  • Position sizing recommendations with rationale
  • Beta-weighted portfolio analysis
  • Diversification optimization suggestions

Technical Architecture:

  • AWS Bedrock Agent: Real agent resource with autonomous tool orchestration
  • AgentCore Primitives: Agent decides which tools to call and analyzes results
  • Serverless Design: Lambda functions, S3 storage, API Gateway, DynamoDB
  • External Integrations: Market data APIs, report generation, caching

How we built it

We built FinMate using a reasoning-first approach with AWS Bedrock Agent at its core:

1. Infrastructure as Code (CDK)

// Real Bedrock Agent with AgentCore primitives
const bedrockAgent = new bedrock.CfnAgent(this, 'FinMateAgent', {
  agentName: 'finmate-portfolio-advisor',
  foundationModel: 'amazon.nova-pro-v1:0',
  instruction: 'You are a sophisticated AI financial advisor...'
});

2. Agent Tool Orchestration

The Bedrock Agent autonomously calls three specialized tools:

  • get_market_data: Fetches real-time quotes via Yahoo Finance API
  • compute_metrics: Calculates portfolio weights, P&L, sector exposure, beta
  • write_report: Generates professional HTML reports with charts

3. Python Market Data Integration

def get_yahoo_chart_price(session, ticker, max_retries=3):
    """Direct Yahoo Finance Chart API with endpoint rotation and backoff"""
    for attempt in range(max_retries):
        endpoint = random.choice(ENDPOINTS)
        url = f"https://{endpoint}.finance.yahoo.com/v8/finance/chart/{ticker}"
        # Robust error handling and retry logic

4. Autonomous Operation

// EventBridge triggers daily analysis without user input
const dailyCheckRule = new events.Rule(this, 'DailyCheckRule', {
  schedule: events.Schedule.cron({ hour: '9', minute: '0' }),
});

5. Modern Web Interface

Built a responsive React-like interface with drag-and-drop portfolio upload and real-time analysis results.

Challenges we ran into

1. Bedrock Agent Circular Dependencies

Challenge: CDK couldn't create the Bedrock Agent due to circular dependencies with Lambda functions.

Solution: Implemented a hybrid approach:

  • CDK creates all infrastructure except the agent
  • Manual agent creation using AWS CLI scripts
  • Environment variables for agent IDs after deployment

2. Market Data API Reliability

Challenge: Yahoo Finance API rate limiting and inconsistent responses.

Solution: Built robust error handling:

  • Multiple endpoint rotation (query1, query2)
  • Exponential backoff with jitter
  • User-Agent rotation to avoid detection
  • S3 caching for 15-minute TTL

3. Agent Tool Parameter Parsing

Challenge: Bedrock Agent passes complex nested JSON structures that were difficult to parse.

Solution: Created flexible parameter extraction:

// Handle both parameter formats from agent
if (requestBody.content['application/json']?.properties) {
  const properties = requestBody.content['application/json'].properties;
  const tickersProp = properties.find(p => p.name === 'tickers');
  // Parse both array and string formats
}

4. Rate Limiting and Quotas

Challenge: Bedrock API quotas and yfinance rate limits.

Solution: Implemented comprehensive rate limiting:

  • Bedrock rate limiter with token tracking
  • Random User calls yfinance
  • S3 caching to reduce API calls
  • Graceful degradation when limits hit

5. Async Analysis Complexity

Challenge: Portfolio analysis takes 30-60 seconds, but API Gateway has 30-second timeout.

Solution: Implemented async job pattern:

  • Immediate job ID return (202 Accepted)
  • DynamoDB job tracking
  • Background Lambda processing
  • Status polling endpoint

Accomplishments that we're proud of

1. Real AWS Bedrock Agent Implementation

We successfully created an actual Bedrock Agent resource (not simulated) that appears in the AWS Console. The agent autonomously orchestrates tool calls and makes reasoning-based decisions.

2. Production-Ready Architecture

Built a complete serverless architecture with:

  • Proper error handling and retry logic
  • Security best practices (IAM roles, S3 encryption)
  • Cost optimization (under $50/month for MVP)
  • Monitoring and logging

3. Sophisticated Market Data Integration

Created a robust Python Lambda that handles:

  • Multiple API endpoints with failover
  • Rate limiting and caching
  • Error recovery and data validation
  • Real-time price fetching for 100+ tickers

4. Educational AI Approach

Unlike prediction-based models, our AI explains every recommendation with:

  • Clear rationale backed by portfolio data
  • Risk assessment with specific metrics
  • Alternative options when confidence is low
  • Proper financial disclaimers

5. Autonomous Operation

Implemented true autonomy with:

  • EventBridge daily scheduling
  • Agent-driven analysis without user prompts
  • Background job processing
  • Automated report generation

What we learned

1. AWS Bedrock Agent Architecture

  • AgentCore primitives enable sophisticated tool orchestration
  • Agent memory and session management for complex workflows
  • OpenAPI schema design for tool integration
  • IAM role configuration for agent permissions

2. Serverless Best Practices

  • Async patterns for long-running operations
  • Proper error handling and retry strategies
  • Cost optimization through caching and rate limiting
  • Security through least-privilege IAM roles

3. AI Integration Challenges

  • Prompt engineering for consistent JSON responses
  • Handling AI model limitations and fallbacks
  • Balancing AI reasoning with rule-based logic
  • Ensuring transparency in AI decision-making

4. Financial Data Integration

  • Market data API reliability and rate limiting
  • Data validation and error handling
  • Caching strategies for performance
  • Real-time vs. batch processing trade-offs

5. User Experience Design

  • Progressive disclosure of complex financial concepts
  • Real-time feedback during analysis
  • Mobile-responsive design principles
  • Accessibility considerations

What's next for FinMate

Short-term (Next 3 months)

  • Brokerage Integration: Connect with Alpaca for paper trading
  • Advanced Risk Models: Implement VaR and Monte Carlo simulations
  • Mobile App: React Native app for portfolio monitoring
  • Real-time Alerts: SNS notifications for significant portfolio changes

Medium-term (6-12 months)

  • Multi-currency Support: International portfolio analysis
  • Tax Optimization: Tax-loss harvesting and optimization
  • Social Features: Portfolio sharing and community insights
  • Advanced Analytics: Factor analysis and attribution

Long-term Vision

  • Institutional Features: Support for larger portfolios and complex instruments
  • AI Model Improvements: Fine-tuned models for specific market conditions
  • Regulatory Compliance: SEC registration for financial advisory services
  • Global Expansion: Multi-market support and localization

Technical Roadmap

  • Microservices Architecture: Break down monolith into specialized services
  • Real-time Streaming: WebSocket connections for live updates
  • Advanced Caching: Redis for high-performance data access
  • ML Pipeline: Custom models for portfolio optimization
Share this project:

Updates