File size: 7,449 Bytes
6ceb32c 5ad2796 6ceb32c 5ad2796 6ceb32c 563fd53 ecc56e5 563fd53 6ceb32c 5ad2796 d9e6f5f 5ad2796 0d09fe2 563fd53 0d09fe2 563fd53 5ad2796 d9e6f5f 5ad2796 d9e6f5f 5ad2796 0d09fe2 d9e6f5f 5ad2796 0d09fe2 5ad2796 0d09fe2 5ad2796 0d09fe2 d9e6f5f 5ad2796 d9e6f5f 5ad2796 d9e6f5f 5ad2796 d9e6f5f 5ad2796 d9e6f5f 5ad2796 d9e6f5f 5ad2796 d9e6f5f 5ad2796 d9e6f5f 5ad2796 0d09fe2 5ad2796 d9e6f5f 5ad2796 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
---
title: Financial Advisory Agent
emoji: π§βπΌ
colorFrom: gray
colorTo: blue
sdk: gradio
sdk_version: 5.33.0
app_file: app.py
tags:
- agent-demo-track
- financial-analysis
- openai
- tavily
pinned: false
license: apache-2.0
short_description: Financial analysis, investments, budget planning, and more.
---
# AI Financial Advisory Agent
An intelligent financial advisory agent powered by OpenAI's GPT-4.1 and specialized financial tools. This agent provides comprehensive financial analysis, investment recommendations, budget planning, and market insights through an intuitive web interface with **advanced natural language processing**.
**Watch the demo video:** [Financial Advisory Agent Demo (Hugging Face Hackathon)](https://youtu.be/vGOSAXyrQgM)
[](https://youtu.be/vGOSAXyrQgM)
## π Features
### Core Financial Tools
- **π Investment Analyzer**: Analyze ANY stock using natural language - "Tell me about NVIDIA" or "How is Tesla doing?"
- **π° Budget Planner**: Create budgets from conversational input - "I make 6k monthly, rent is 1800, food 600"
- **π Portfolio Analyzer**: Analyze portfolios from natural descriptions - "My portfolio: Apple 100 shares, Google 50 shares"
- **π° Market Trends Analyzer**: Get optimized market research from simple queries - "What's happening in tech?"
### Advanced Features
- **π§ OpenAI Function Calling**: All tools use intelligent input extraction from natural language
- **π― Smart Response Type Detection**: Automatically detects if users want short summaries or detailed reports
- **β‘ Real-time LLM Streaming**: Live token-by-token response generation from OpenAI API
- **π Interactive Tool Results**: Collapsible sections for clean data presentation
- **π Comprehensive Data Analysis**: Enhanced insights for all financial data
- **π Universal Stock Support**: Supports analysis of ANY publicly traded stock, not just predefined ones
## π οΈ Installation
1. **Clone the repository**
```bash
git clone https://huggingface.co/spaces/Agents-MCP-Hackathon/Financial-Advisory-Agent.git
cd Financial-Advisory-Agent
```
2. **Install dependencies**
```bash
pip install -r requirements.txt
```
3. **Set up environment variables**
Set environment variables:
```bash
export OPENAI_API_KEY="your-openai-api-key"
export TAVILY_API_KEY="your-tavily-api-key"
```
4. **Run the application**
```bash
python app.py
```
## π― Response Types
The system automatically detects your preference:
### Short Response Keywords
- `quick`, `brief`, `short`, `summary`, `concise`, `simple`, `fast`, `tldr`, `bottom line`
### Detailed Response Keywords
- `detailed`, `comprehensive`, `thorough`, `in-depth`, `report`, `breakdown`, `explain`, `elaborate`, `deep dive`
### Default Behavior
- **Short responses** are the default (under 200 words)
- **Detailed responses** are triggered by specific keywords (comprehensive analysis)
## π§ Technical Architecture
- **Frontend**: Gradio web interface with real-time streaming
- **Backend**: LangChain agents with OpenAI GPT-4.1
- **AI Integration**: OpenAI function calling for intelligent input processing across all tools
- **Data Sources**:
- Yahoo Finance API for stock data (supports ALL publicly traded stocks)
- Tavily Search API for market news
- Real-time financial calculations
- **Streaming**: Direct LLM token streaming from OpenAI API
- **Tools**: Specialized financial analysis functions with natural language processing
## π Tool Capabilities
### Investment Analyzer π§
- **Natural Language Input**: "Tell me about NVIDIA", "How is Tesla doing?", "Analyze AMZN"
- **Universal Stock Support**: Works with ANY publicly traded stock symbol
- **OpenAI-Powered Extraction**: Intelligently extracts stock symbols from company names
- Real-time stock prices and historical data
- Technical indicators (RSI, MACD, Bollinger Bands, Moving Averages)
- Risk assessment (volatility, VaR, beta analysis)
- Fundamental analysis (P/E, P/B ratios, dividend yield)
- Buy/Hold/Sell recommendations with confidence scores
### Budget Planner π§
- **Conversational Input**: "I make 6k monthly, rent 1800, food 600", "Help budget my 4500 salary"
- **OpenAI Data Extraction**: Automatically parses income and expenses from natural language
- 50/30/20 rule implementation
- Emergency fund calculations
- Debt-to-income ratio analysis
- Savings optimization recommendations
- Expense category warnings
### Market Trends Analyzer π§
- **Query Optimization**: Converts "What's happening in tech?" to optimized search queries
- **OpenAI-Enhanced Search**: Automatically improves search terms for better results
- Real-time market news via Tavily Search
- Major index tracking (S&P 500, NASDAQ)
- Market sentiment analysis
- Key theme extraction
- Economic trend identification
### Portfolio Analyzer π§
- **Natural Portfolio Input**: "My portfolio: Apple 100 shares, Google 50 shares"
- **Smart Format Detection**: Handles both share counts and percentages automatically
- **OpenAI JSON Conversion**: Converts natural descriptions to structured data
- Diversification scoring
- Sector allocation analysis
- Concentration risk assessment
- Rebalancing recommendations
- Performance metrics
## π Recent Updates
### Latest (v2.0) - OpenAI Function Calling Integration π§
- β
**Universal Stock Support**: Removed hardcoded stock limitations - now supports ANY publicly traded stock
- β
**OpenAI-Powered Input Extraction**: All tools now use OpenAI function calling for intelligent data extraction
- β
**Natural Language Processing**:
- Investment: "Tell me about NVIDIA" β Automatically extracts "NVDA"
- Budget: "I make 6k monthly, rent 1800" β Extracts structured JSON
- Portfolio: "Apple 100 shares, Google 50 shares" β Converts to holdings format
- Market: "What's happening in tech?" β Optimizes to targeted search query
- β
**Enhanced Example Queries**: Updated with NVIDIA and natural language examples
### Previous Updates
- β
**Smart Response Detection**: Automatically detects if users want short or detailed responses
- β
**Real LLM Streaming**: Genuine token-by-token streaming from OpenAI API
- β
**Improved Data Analysis**: Comprehensive insights
- β
**Optimized Performance**: Faster tool execution and response times
- β
**Collapsible Results**: Clean, organized tool output presentation
## π API Keys Required
- **OpenAI API Key**: For language model
- **Tavily API Key**: For real-time market news and trends
## π‘ Example Natural Language Queries
### Investment Analysis
- "Tell me about NVIDIA stocks"
- "How is Tesla performing?"
- "Should I invest in Apple?"
- "Analyze AMZN for me"
- "What's the latest on Microsoft stock?"
### Budget Planning
- "I make $6000 monthly, rent is $1800, food $600, help me budget"
- "Help budget my $4500 salary, utilities cost $150"
- "Create a budget: income 5k, rent 1500, groceries 400"
### Portfolio Analysis
- "My portfolio: Apple 100 shares, Google 50 shares, Microsoft 25 shares"
- "I have 40% AAPL, 30% MSFT, 30% TSLA"
- "Analyze portfolio with Tesla 200 shares and Amazon 25%"
### Market Trends
- "What's happening in tech stocks?"
- "Tell me about today's market"
- "How is the crypto market doing?"
- "What are the latest NVIDIA trends?"
## π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
|