A professional-grade Multi-Agent System that acts as an autonomous financial analyst. This project orchestrates a team of AI Agentsโa Technical Analyst, a News Journalist, and a Chief Investment Officer (Supervisor)โto analyze real-time stock market data and generate investment decisions.
(Note: The app supports BYOK (Bring Your Own Key) for security. If you don't have a key, it runs in Simulation Mode to demonstrate functionality.)
This system is not just a chatbot. It is an Agentic Workflow built on the "Boardroom Pattern":
Instead of one general AI doing everything, we split the logic into specialized roles to prevent hallucinations and increase accuracy.
- ๐ Agent A: The Quantitative Analyst ("The Quant")
- Role: Mathematics & Trends.
- Tools: Fetches raw price data via
yfinance(Open, Close, Moving Averages). - Logic: Analyzes volatility, percentage changes, and price momentum. It effectively ignores news to remain objective.
- ๐ฐ Agent B: The Financial Journalist ("The Sentiment Scout")
- Role: Sentiment & Context.
- Tools: Fetches live news headlines via
yfinance. - Logic: Reads headlines to determine market mood (Fear vs. Greed). It effectively ignores charts to focus on the narrative.
- ๐ Agent C: The Chief Investment Officer (CIO)
- Role: Synthesis & Final Decision.
- Mechanism: Uses A2A (Agent-to-Agent) Communication. The CIO receives the conflicting reports from the Quant and the Journalist.
- Logic: "If Technicals say BUY but News says PENDING LAWSUIT, override to HOLD." It applies high-level reasoning to resolve conflicts.
- Simulation Fallback: If the Google Gemini API hits a rate limit (429 Error), the system automatically switches to a "Simulation Mode," generating mock data to ensure the application UI never crashes during a presentation.
- Brain:
google-genai(Gemini 1.5 Flash) - Chosen for high speed and low latency. - Frontend:
Streamlit- For a responsive, interactive web dashboard. - Data Feed:
yfinance- Real-time stock market data and news. - Orchestration: Custom Python Agent Classes (State Management & Retry Logic).
- Notifications:
smtplib- Real-time email alert system using Gmail SMTP.
We designed this agent with specific safeguards for competition environments and scalability.
Instead of hardcoding our API credentials, the app requires users to input their own Google Gemini API Key.
- Why? To prevent quota exhaustion during public demos and ensure security best practices.
- How: The key is stored temporarily in the session state and is never saved to a database.
We implemented a robust fallback mechanism to handle the Google Gemini Free Tier limits (429 Too Many Requests).
- The Problem: In a hackathon demo, if 10 judges click "Analyze" simultaneously, the API quota will crash the app.
- Our Solution: If the API fails, the agent automatically switches to Simulation Mode. It generates a pre-scripted "Mock Decision" to ensure the UI flow (Charts โ Analysis โ Email) completes successfully without an error screen.
- User Feedback: A warning banner
โ ๏ธ API busy, using simulation dataappears so the user knows exactly what is happening.
The agent features a dual-mode notification system for "Buy/Sell" signals.
- Mode A (Visual Simulation - Default): Uses
st.toastpopup notifications to simulate an alert being sent.- Reasoning: To protect user privacy and avoid triggering Gmail's anti-spam blockers during repeated testing.
- Mode B (Real SMTP - Configurable): The backend supports full SMTP integration (
smtplib).- How to Enable: Users can open the sidebar expander "๐ Email Config" and enter their own Gmail App Password to enable real-world emailing. This proves the backend logic is fully functional while keeping the default experience safe.
We have architected this system to scale from a single-user demo to a production SaaS platform.
-
Automated Cron Jobs (The "Watchdog" Feature):
- Current State: User clicks to run.
- Future State: Deploy via GitHub Actions or AWS Lambda to auto-run every morning at 9:00 AM EST. The agent will proactively email users only when a critical "Strong Buy/Sell" signal is detected.
-
Portfolio Memory (SQL Database):
- Current State: Stateless analysis.
- Future State: Integrate PostgreSQL (Supabase) to store user portfolios. The agent will calculate actual P&L (Profit & Loss) and remember previous recommendations to track its own accuracy over time.
-
Multi-Ticker Analysis (S&P 500 Scanner):
- Current State: Analyzes one specific ticker deeply.
- Future State: Implement Python Asyncio to scan 500+ tickers in parallel, filtering for high-RSI opportunities and presenting the "Top 3 Picks of the Day" automatically.
AI-Hedge-Fund/
โโโ capstone.ipynb # experimenting the process and logics before the main application
โโโ app.py # The Main Application (Logic + UI)
โโโ requirements.txt # Dependencies for Cloud Deployment
โโโ README.md # Documentation
---