Skip to main content

AI Agent

Claude-powered financial analysis engine with automated insights, trading recommendations, and alerts.

Capabilities

CapabilityDescription
Spending AnalysisCategorize and analyze transaction patterns
Budget MonitoringTrack spending against budgets, alert on anomalies
Market SentimentAnalyze economic indicators and market conditions
Trade RecommendationsAI-driven buy/sell suggestions with rationale
Natural LanguageChat interface for financial queries

Analysis Cycle

Every 30 Minutes:

├─▶ Fetch Recent Transactions
│ │
│ ▼
├─▶ Analyze Spending Patterns
│ │
│ ▼
├─▶ Check Budget Thresholds
│ │
│ ▼
├─▶ Generate Insights
│ │
│ ▼
└─▶ Send Notifications (if needed)

Data Models

AIInsight

Generated insights and recommendations.

class AIInsight:
insight_type: str # spending, budget, market, recommendation
title: str
content: str # Detailed analysis
severity: str # info, warning, critical
category: Category # Related category (optional)
data: dict # Supporting data
created_at: datetime
acknowledged: bool

TradeRecommendation

AI-suggested trades with full rationale.

class TradeRecommendation:
symbol: str # Stock ticker
action: str # buy, sell, hold
quantity: int
target_price: Decimal
rationale: str # AI explanation
confidence: float # 0-1 confidence score
market_conditions: dict
status: str # pending, approved, executed, rejected

TradeExecution

Record of executed trades.

class TradeExecution:
recommendation: TradeRecommendation
executed_at: datetime
executed_price: Decimal
executed_quantity: int
fees: Decimal
status: str # success, failed, partial
schwab_order_id: str

SpendingAlert

Automated spending alerts.

class SpendingAlert:
alert_type: str # large_transaction, budget_warning, unusual
category: Category
amount: Decimal
threshold: Decimal
message: str
sent_via: list[str] # sms, email, push

Alert Thresholds

Configure in environment:

# Large transaction alert
LARGE_TRANSACTION_THRESHOLD=500

# Unusual spending (X times normal)
UNUSUAL_SPEND_MULTIPLIER=2.0

# Budget warnings
BUDGET_WARNING_PERCENTAGE=75
BUDGET_CRITICAL_PERCENTAGE=90

Trading Safety Controls

ControlDefaultDescription
MAX_DAILY_TRADES$10,000Maximum daily trade volume
MAX_SINGLE_TRADE$5,000Maximum single trade amount
WHITELIST_ONLYfalseOnly trade whitelisted symbols
EMERGENCY_STOPfalseHalt all trading
REQUIRE_APPROVALtrueHuman approval for trades

API Endpoints

Insights

GET  /api/ai/insights/           # Recent insights
GET /api/ai/insights/{id}/ # Insight details
POST /api/ai/insights/{id}/ack/ # Acknowledge insight

Recommendations

GET  /api/ai/recommendations/    # Trade recommendations
GET /api/ai/recommendations/{id}/ # Details
POST /api/ai/execute-trade/ # Execute trade

Chat

POST /api/ai/chat/               # Chat with AI

Request:

{
"message": "What were my biggest expenses last month?"
}

Response:

{
"response": "Your biggest expenses last month were...",
"data": {
"categories": [...],
"total": 2500.00
}
}

Notifications

When alerts are triggered, notifications are sent via configured channels:

ChannelServiceConfiguration
SMSTwilioTWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN
EmailSendGridSENDGRID_API_KEY
PushFirebaseFIREBASE_CREDENTIALS

Scheduled Tasks

TaskScheduleDescription
ai_agent_analysisEvery 30 minRun full analysis cycle
check_market_conditionsHourlyUpdate market sentiment
generate_daily_summaryDaily @ 8 AMDaily financial summary