Skip to content

Latest commit

ย 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Agentic Stock Analysis System

A multi-agent AI system built with CrewAI that autonomously analyzes stock markets and provides Buy/Sell/Hold recommendations.

๐ŸŽฏ Features

  • 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

๐Ÿ—๏ธ Architecture

The Agent Crew

  1. Market Data Analyst ๐Ÿ“Š

    • Role: Expert technical analyst
    • Tool: Yahoo Finance API
    • Output: Price metrics, volume analysis, momentum indicators
  2. Financial News Sentinel ๐Ÿ“ฐ

    • Role: Investigative financial journalist
    • Tool: DuckDuckGo Search
    • Output: News sentiment, catalyst identification
  3. Investment Strategist ๐Ÿ’ผ

    • Role: Senior portfolio manager
    • Input: Data from both analysts
    • Output: Buy/Sell/Hold recommendation with justification

File Structure

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

๐Ÿš€ Installation

Step 1: Navigate to Project Directory

cd "C:\Users\Joel\Desktop\Weaver\StocksProj"

Step 2: Create Virtual Environment

python -m venv venv
.\venv\Scripts\activate

Step 3: Install Dependencies

pip install -r requirements.txt

Step 4: Configure API Keys

  1. Copy the example environment file:

    copy .env.example .env
  2. Edit .env and add your API key:

    ANTHROPIC_API_KEY=sk-ant-api03-your-actual-key-here
    

    or

    OPENAI_API_KEY=sk-proj-your-actual-key-here
    

๐ŸŽฎ Usage

Basic Usage

python main.py

When prompted, enter ticker symbols (comma-separated):

๐ŸŽฏ Tickers: AAPL, TSLA, NVDA

Example Output

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
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

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ”ง Configuration

Using Claude (Anthropic)

ANTHROPIC_API_KEY=sk-ant-api03-...

Using GPT-4 (OpenAI)

OPENAI_API_KEY=sk-proj-...

The system automatically detects which API key is available and uses the appropriate LLM.


๐Ÿ“Š How It Works

  1. User Input: Enter ticker symbols to analyze
  2. Data Collection: Market Data Analyst fetches stock metrics
  3. Sentiment Analysis: News Sentinel searches recent news
  4. Synthesis: Investment Strategist combines insights
  5. Recommendation: Final Buy/Sell/Hold decision with reasoning

โš ๏ธ Important Disclaimers

Not Financial Advice

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

AI Limitations

  • 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

Your Responsibility

  • โœ… 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

๐Ÿ› ๏ธ Troubleshooting

API Key Errors

โŒ ERROR: No API key found!

Solution: Check that your .env file exists and contains a valid API key.

Ticker Not Found

Error: No data available for ticker 'XYZ'

Solution: Verify the ticker symbol is correct. Use symbols from major exchanges (NYSE, NASDAQ).

Network Issues

Error fetching data: Connection timeout

Solution: Check your internet connection. Yahoo Finance and DuckDuckGo must be accessible.

Import Errors

ModuleNotFoundError: No module named 'crewai'

Solution: Ensure virtual environment is activated and dependencies are installed:

.\venv\Scripts\activate
pip install -r requirements.txt

๐Ÿ”ฎ Future Enhancements

  • Streamlit web interface
  • Historical backtesting
  • Portfolio optimization
  • Technical indicator charting
  • Real-time alerts
  • Options analysis
  • Crypto support

๐Ÿ“š Resources


๐Ÿ“ License

For educational and personal use only. Not for commercial distribution.


๐Ÿค Contributing

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

About

Agentic Stock Analyst powered by CrewAI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages