AI Agent
Claude-powered financial analysis engine with automated insights, trading recommendations, and alerts.
Capabilities
| Capability | Description |
|---|---|
| Spending Analysis | Categorize and analyze transaction patterns |
| Budget Monitoring | Track spending against budgets, alert on anomalies |
| Market Sentiment | Analyze economic indicators and market conditions |
| Trade Recommendations | AI-driven buy/sell suggestions with rationale |
| Natural Language | Chat 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
| Control | Default | Description |
|---|---|---|
MAX_DAILY_TRADES | $10,000 | Maximum daily trade volume |
MAX_SINGLE_TRADE | $5,000 | Maximum single trade amount |
WHITELIST_ONLY | false | Only trade whitelisted symbols |
EMERGENCY_STOP | false | Halt all trading |
REQUIRE_APPROVAL | true | Human 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:
| Channel | Service | Configuration |
|---|---|---|
| SMS | Twilio | TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN |
| SendGrid | SENDGRID_API_KEY | |
| Push | Firebase | FIREBASE_CREDENTIALS |
Scheduled Tasks
| Task | Schedule | Description |
|---|---|---|
ai_agent_analysis | Every 30 min | Run full analysis cycle |
check_market_conditions | Hourly | Update market sentiment |
generate_daily_summary | Daily @ 8 AM | Daily financial summary |
Related
- Finance - Financial data models
- Integrations - Schwab trading API
- Webapp Overview - Architecture