A multi-agent AI system built with CrewAI that autonomously analyzes stock markets and provides Buy/Sell/Hold recommendations.
- Multi-Agent Architecture: Three specialized AI agents work collaboratively
- Quantitative Analysis: Real-time stock data from Yahoo Finance
- Sentiment Analysis: News scraping and sentiment assessment
- Strategic Recommendations: Synthesized insights with confidence scores
- Modular Design: Clean separation of agents, tasks, and tools
-
Market Data Analyst ๐
- Role: Expert technical analyst
- Tool: Yahoo Finance API
- Output: Price metrics, volume analysis, momentum indicators
-
Financial News Sentinel ๐ฐ
- Role: Investigative financial journalist
- Tool: DuckDuckGo Search
- Output: News sentiment, catalyst identification
-
Investment Strategist ๐ผ
- Role: Senior portfolio manager
- Input: Data from both analysts
- Output: Buy/Sell/Hold recommendation with justification
StocksProj/
โโโ main.py # Entry point - orchestrates the crew
โโโ agents.py # Agent definitions with roles and goals
โโโ tasks.py # Task definitions for each agent
โโโ tools.py # Custom tools (Yahoo Finance)
โโโ requirements.txt # Python dependencies
โโโ .env.example # Template for API keys
โโโ README.md # This file
cd "C:\Users\Joel\Desktop\Weaver\StocksProj"python -m venv venv
.\venv\Scripts\activatepip install -r requirements.txt-
Copy the example environment file:
copy .env.example .env
-
Edit
.envand add your API key:ANTHROPIC_API_KEY=sk-ant-api03-your-actual-key-hereor
OPENAI_API_KEY=sk-proj-your-actual-key-here
python main.pyWhen prompted, enter ticker symbols (comma-separated):
๐ฏ Tickers: AAPL, TSLA, NVDA
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
INVESTMENT RECOMMENDATION: AAPL
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ DECISION: Buy
๐ CONFIDENCE: 78/100
โฐ TIME HORIZON: Medium-term
๐ฏ KEY REASONING:
โข Strong technical momentum - trading near 52-week highs
โข Positive news sentiment around new product launches
โข Volume analysis shows institutional accumulation
โ ๏ธ RISK FACTORS:
โข Market volatility due to macroeconomic uncertainty
โข High valuation relative to historical P/E ratio
๐ก STRATEGY:
Consider entry on dips below $180 with stop-loss at $170
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
ANTHROPIC_API_KEY=sk-ant-api03-...OPENAI_API_KEY=sk-proj-...The system automatically detects which API key is available and uses the appropriate LLM.
- User Input: Enter ticker symbols to analyze
- Data Collection: Market Data Analyst fetches stock metrics
- Sentiment Analysis: News Sentinel searches recent news
- Synthesis: Investment Strategist combines insights
- Recommendation: Final Buy/Sell/Hold decision with reasoning
This tool generates analytical assessments based on available data. It is:
- โ NOT a substitute for professional financial advice
- โ NOT guaranteed to be accurate or profitable
- โ NOT responsible for investment losses
- Hallucinations: AI may generate plausible-sounding but incorrect information
- Bias: Models can reflect biases in training data
- Timeliness: News and data may be outdated
- Context: AI lacks human judgment about market nuance
- โ Always verify data manually before making trades
- โ Consult with licensed financial advisors
- โ Understand the risks of investing
- โ Never invest more than you can afford to lose
โ ERROR: No API key found!
Solution: Check that your .env file exists and contains a valid API key.
Error: No data available for ticker 'XYZ'
Solution: Verify the ticker symbol is correct. Use symbols from major exchanges (NYSE, NASDAQ).
Error fetching data: Connection timeout
Solution: Check your internet connection. Yahoo Finance and DuckDuckGo must be accessible.
ModuleNotFoundError: No module named 'crewai'
Solution: Ensure virtual environment is activated and dependencies are installed:
.\venv\Scripts\activate
pip install -r requirements.txt- Streamlit web interface
- Historical backtesting
- Portfolio optimization
- Technical indicator charting
- Real-time alerts
- Options analysis
- Crypto support
For educational and personal use only. Not for commercial distribution.
This is a personal project, but suggestions are welcome! Open an issue or submit a pull request.
Built with โค๏ธ using CrewAI and Claude 3.5 Sonnet